From 00ef9b01be46fd954678fe833969824859564653 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 16 Feb 2019 09:51:51 +1300 Subject: [PATCH] Payment.sendconfirmation - add tpl var for fully paid --- CRM/Financial/BAO/Payment.php | 3 ++- tests/phpunit/api/v3/PaymentTest.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 6c6aaed7ce..cbfccbc4a4 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -228,6 +228,7 @@ class CRM_Financial_BAO_Payment { 'isRefund' => $entities['payment']['total_amount'] < 0, 'isAmountzero' => $entities['payment']['total_amount'] === 0, 'refundAmount' => ($entities['payment']['total_amount'] < 0 ? $entities['payment']['total_amount'] : NULL), + 'paymentsComplete' => ($entities['payment']['balance'] == 0), ]; return self::filterUntestedTemplateVariables($templateVariables); @@ -261,10 +262,10 @@ class CRM_Financial_BAO_Payment { 'isAmountzero', 'refundAmount', 'totalPaid', + 'paymentsComplete', ]; // Need to do these before switching the form over... $todoParams = [ - 'paymentsComplete', 'contributeMode', 'billingName', 'address', diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 1d43cf6186..737d27010e 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -147,6 +147,33 @@ class api_v3_PaymentTest extends CiviUnitTestCase { $mut->clearMessages(); } + /** + * Test email receipt for partial payment. + */ + public function testPaymentEmailReceiptFullyPaid() { + $mut = new CiviMailUtils($this); + list($lineItems, $contribution) = $this->createParticipantWithContribution(); + + $params = [ + 'contribution_id' => $contribution['id'], + 'total_amount' => 150, + ]; + $payment = $this->callAPISuccess('payment', 'create', $params); + + $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]); + $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']); + $mut->checkMailLog(array( + 'Dear Mr. Anthony Anderson II', + 'A payment has been received.', + 'Total Fees: $ 300.00', + 'This Payment Amount: $ 150.00', + 'Balance Owed: $ 0.00', + 'Thank you for completing payment.', + )); + $mut->stop(); + $mut->clearMessages(); + } + /** * Test email receipt for partial payment. * @@ -186,6 +213,7 @@ class api_v3_PaymentTest extends CiviUnitTestCase { $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']); $mut->checkMailLog(array( 'Dear Mr. Anthony Anderson II', + 'A refund has been issued based on changes in your registration selections.', 'Total Fees: $ 300' . $decimalSeparator . '00', 'Refund Amount: $ -30' . $decimalSeparator . '00', 'Event Information and Location', -- 2.25.1