From 434546ac867d731bdfd00e4e9d387f0af6e3d2d7 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 16 Feb 2019 07:07:18 +1300 Subject: [PATCH] Payment.sendconfirmation api - add further tpl variables. This is a continuance of the introduction of this api --- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Financial/BAO/Payment.php | 9 ++++++--- tests/phpunit/api/v3/PaymentTest.php | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index dc7a4f208f..1a444fcc62 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4832,7 +4832,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) $balanceTrxnParams['from_financial_account_id'] = $fromFinancialAccountId; $balanceTrxnParams['total_amount'] = $params['total_amount']; $balanceTrxnParams['contribution_id'] = $params['contribution_id']; - $balanceTrxnParams['trxn_date'] = !empty($params['contribution_receive_date']) ? $params['contribution_receive_date'] : date('YmdHis'); + $balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis'))); $balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params); $balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('total_amount', $params); $balanceTrxnParams['currency'] = $contribution['currency']; diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 2897ee1526..c0fa6d83db 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -212,6 +212,9 @@ class CRM_Financial_BAO_Payment { 'paymentAmount' => $entities['payment']['total_amount'], 'event' => NULL, 'component' => 'contribution', + 'checkNumber' => CRM_Utils_Array::value('check_number', $entities['payment']), + 'receive_date' => $entities['payment']['trxn_date'], + 'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']), ]; if (!empty($entities['event'])) { $templateVariables['component'] = 'event'; @@ -240,6 +243,9 @@ class CRM_Financial_BAO_Payment { 'paymentAmount', 'event', 'component', + 'checkNumber', + 'receive_date', + 'paidBy', ]; // Need to do these before switching the form over... $todoParams = [ @@ -247,9 +253,6 @@ class CRM_Financial_BAO_Payment { 'totalPaid', 'refundAmount', 'paymentsComplete', - 'receive_date', - 'paidBy', - 'checkNumber', 'contributeMode', 'isAmountzero', 'billingName', diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 5585a58f6b..b4e94d656f 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -113,6 +113,8 @@ class api_v3_PaymentTest extends CiviUnitTestCase { $params = array( 'contribution_id' => $contribution['id'], 'total_amount' => 50, + 'check_number' => '345', + 'trxn_date' => '2018-08-13 17:57:56', ); $payment = $this->callAPISuccess('payment', 'create', $params); $this->checkPaymentResult($payment, [ @@ -133,6 +135,9 @@ class api_v3_PaymentTest extends CiviUnitTestCase { 'This Payment Amount: $ 50.00', 'Balance Owed: $ 100.00', //150 was paid in the 1st payment. 'Event Information and Location', + 'Paid By: Check', + 'Check Number: 345', + 'Transaction Date: August 13th, 2018 5:57 PM', )); $mut->stop(); } -- 2.25.1