Answers.Body: <p>I am not sure if Civirules does it(pretty sure it doesn't). Through an extension i would use pre hook to check and create contribution recur when a contribution is created. Here is small snippet </p>
  
  <pre><code>function extension_civicrm_pre($op, $objectName, $id, &amp;$params) {
    if ($objectName == 'Contribution' &amp;&amp; $op == 'create') {
      $bankTransferFinancialTypeId = civicrm_api3('FinancialType', 'getvalue', [
        'return' =&gt; "id",
        'name' =&gt; "Bank Transfer",
      ]);
      if ($bankTransferFinancialTypeId == $params['financial_type_id']) {
        // perform checks if contribution recur exists
        try {
          $recurringcontributionId = civicrm_api3('ContributionRecur', 'getvalue', [
            'return' =&gt; "id",
            'contact_id' =&gt; $params['contact_id'],
            'amount' =&gt; $params['total_amount'],
            'contribution_status_id' =&gt; ['IN' =&gt; ["Pending", "In Progress"]],
            'options' =&gt; ['limit' =&gt; 1],
          ]);
        }
        catch (CiviCRM_API3_Exception $e) {
          $recurringcontribution = civicrm_api3('ContributionRecur', 'create', [
            'contact_id' =&gt; $params['contact_id'],
            'installments' =&gt; '12',
            'frequency_interval' =&gt; '1',
            'amount' =&gt; $params['total_amount'],
            'contribution_status_id' =&gt; 'In Progress',
            'start_date' =&gt; date('YmdHis'),
            'currency' =&gt; 'USD',
            'frequency_unit' =&gt; 'month',
          ]);
          $recurringcontributionId = $recurringcontribution['id'];
        }
        $params['contribution_recur_id'] = $recurringcontributionId;
      }
    }
  }
  </code></pre>
  
  <blockquote>
    <p>Note: This snippet is not tested since i have just created it and is
    pure blind coding.</p>
  </blockquote>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-25T09:18:09.993Z
Answers.Text: Thanks pradeep, I should have been clearer: the code itself wasn't the question, but more how to do it as one of the matcher/analyser plugins in civibanking. This being said, your idea of using a pre-hook is a nice workaround!
Answers.UserDisplayName: Xavier
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-25T09:11:04.370Z
Answers.LastActivityDate: 2018-07-25T09:11:04.370Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm using the wonderful civibanking extension to import the bank statments, including creating the contributions from the donors that directly wire money to our bank account</p>
  
  <p>for the "normal" bank transfers (one off) it works great, we lookup the donor, create a new contribution and all is well</p>
  
  <p>However, we have some donors that sends the same amount every month. They have a different transfer type (one of the column in the bank statement), so we can identify them.</p>
  
  <p>Instead of "simply" creating a contribution, we'd like to 
  1) check if there is an active recurring contribution of type "bank transfer", if not, create it
  2) add the contribution as one linked with that recurring contribution</p>
  
  <p>Is this possible to do out of the box? Any guidance on how to code it?</p>
  
Tags: <civicontribute><recurring-contributions><civibanking>
Title: Automatically create recurring donations from bank statements
ThreadText: # Automatically create recurring donations from bank statements
  
  (Asked by: username_0 on 2018-07-25)
  
  I'm using the wonderful civibanking extension to import the bank statments, including creating the contributions from the donors that directly wire money to our bank account
  
  for the "normal" bank transfers (one off) it works great, we lookup the donor, create a new contribution and all is well
  
  However, we have some donors that sends the same amount every month. They have a different transfer type (one of the column in the bank statement), so we can identify them.
  
  Instead of "simply" creating a contribution, we'd like to
  1) check if there is an active recurring contribution of type "bank transfer", if not, create it
  2) add the contribution as one linked with that recurring contribution
  
  Is this possible to do out of the box? Any guidance on how to code it?
  
  **Tags:** civicontribute, recurring-contributions, civibanking
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-25. Score: 1 | Accepted answer
  
  I am not sure if Civirules does it(pretty sure it doesn't). Through an extension i would use pre hook to check and create contribution recur when a contribution is created. Here is small snippet 
  function extension_civicrm_pre($op, $objectName, $id, &$params) {
    if ($objectName == 'Contribution' && $op == 'create') {
      $bankTransferFinancialTypeId = civicrm_api3('FinancialType', 'getvalue', [
        'return' => "id",
        'name' => "Bank Transfer",
      ]);
      if ($bankTransferFinancialTypeId == $params['financial_type_id']) {
        // perform checks if contribution recur exists
        try {
          $recurringcontributionId = civicrm_api3('ContributionRecur', 'getvalue', [
            'return' => "id",
            'contact_id' => $params['contact_id'],
            'amount' => $params['total_amount'],
            'contribution_status_id' => ['IN' => ["Pending", "In Progress"]],
            'options' => ['limit' => 1],
          ]);
        }
        catch (CiviCRM_API3_Exception $e) {
          $recurringcontribution = civicrm_api3('ContributionRecur', 'create', [
            'contact_id' => $params['contact_id'],
            'installments' => '12',
            'frequency_interval' => '1',
            'amount' => $params['total_amount'],
            'contribution_status_id' => 'In Progress',
            'start_date' => date('YmdHis'),
            'currency' => 'USD',
            'frequency_unit' => 'month',
          ]);
          $recurringcontributionId = $recurringcontribution['id'];
        }
        $params['contribution_recur_id'] = $recurringcontributionId;
      }
    }
  }
  
  
  Note: This snippet is not tested since i have just created it and is
    pure blind coding.
  
  HTH
  Pradeep
  
  > **Comments:**
  > **username_0**: Thanks pradeep, I should have been clearer: the code itself wasn't the question, but more how to do it as one of the matcher/analyser plugins in civibanking. This being said, your idea of using a pre-hook is a nice workaround!  
  
  ---
  
  