Create payment activity when creating a payment via the api, test
authoreileen <emcnaughton@wikimedia.org>
Thu, 6 Jun 2019 05:55:21 +0000 (17:55 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 6 Jun 2019 10:31:04 +0000 (22:31 +1200)
This is a pre-requisite for switching AdditionalPayment form to the api

https://github.com/civicrm/civicrm-core/pull/14408/files

CRM/Financial/BAO/Payment.php
tests/phpunit/api/v3/PaymentTest.php

index 1683e2e31b957e3b63218fea17a314423cd1a05a..96f33fd0ad3511efccc8966c57aa29aefd2860a8 100644 (file)
@@ -102,7 +102,6 @@ class CRM_Financial_BAO_Payment {
     }
     elseif ($params['total_amount'] < 0) {
       $trxn = self::recordRefundPayment($params['contribution_id'], $params, FALSE);
-      CRM_Contribute_BAO_Contribution::recordPaymentActivity($params['contribution_id'], CRM_Utils_Array::value('participant_id', $params), $params['total_amount'], $trxn->currency, $trxn->trxn_date);
     }
 
     if ($isPaymentCompletesContribution) {
@@ -133,7 +132,7 @@ class CRM_Financial_BAO_Payment {
         ]
       );
     }
-
+    CRM_Contribute_BAO_Contribution::recordPaymentActivity($params['contribution_id'], CRM_Utils_Array::value('participant_id', $params), $params['total_amount'], $trxn->currency, $trxn->trxn_date);
     return $trxn;
   }
 
index 56fb75cad21c87315d15565c47db0ad967a00cac..5b3104cbe34f92541b12e430bfdf879e6e5a1b3b 100644 (file)
@@ -633,7 +633,9 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test create payment api for paylater contribution with partial payment.
+   * Test create payment api for pay later contribution with partial payment.
+   *
+   * @throws \Exception
    */
   public function testCreatePaymentPayLaterPartialPayment() {
     $this->createLoggedInUser();
@@ -717,7 +719,7 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
       'id' => $contribution['id'],
     ]);
     $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Completed']]);
-
+    $this->callAPISuccessGetCount('Activity', ['target_contact_id' => $this->_individualId, 'activity_type_id' => 'Payment'], 2);
   }
 
   /**