Merge pull request #14452 from eileenmcnaughton/payment_activity
authorMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 12 Jun 2019 14:14:46 +0000 (15:14 +0100)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2019 14:14:46 +0000 (15:14 +0100)
Create payment activity when creating a payment via the api, test

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

index be7c9042585ed21a1b1105fb82f69eac53da6a0d..d08e9c827df1d388fe61780ce9a4fb1ced10bb3b 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);
   }
 
   /**