CRM-16259, used api calling instead save()
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 11 Jan 2016 10:26:32 +0000 (15:56 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 11 Jan 2016 10:26:32 +0000 (15:56 +0530)
----------------------------------------
* CRM-16259: Create Payment API
  https://issues.civicrm.org/jira/browse/CRM-16259

CRM/Contribute/BAO/Contribution.php

index 2f1d68e2ee1cab07435e3609781b87962477c85f..2b2cd77dbc1ebf6a313ccb3e72bb7537e26ad0b1 100644 (file)
@@ -4751,18 +4751,18 @@ LIMIT 1;";
       while ($dao->fetch()) {
         $ftIds[$dao->price_field_value_id] = $dao->id;
       }
+
+      $params = array(
+        'entity_table' => 'civicrm_financial_item',
+        'financial_trxn_id' => $ftId,
+      );
       foreach ($lineItems as $key => $value) {
         $paid = $value['line_total'] * ($contribution->net_amount / $contribution->total_amount);
         // Record Entity Financial Trxn
-        $params = array(
-          'entity_table' => 'civicrm_financial_item',
-          'financial_trxn_id' => $ftId,
-          'amount' => $paid,
-          'entity_id' => $ftIds[$value['price_field_value_id']],
-        );
-        $entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
-        $entityTrxn->copyValues($params);
-        $entityTrxn->save();
+        $params['amount'] = $paid;
+        $params['entity_id'] = $ftIds[$value['price_field_value_id']];
+
+        civicrm_api3('EntityFinancialTrxn', 'create', $params);
       }
     }
   }