From e7bce1a306028f1a89c4da2341b102cca054126f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 17 Jun 2022 17:05:56 +1200 Subject: [PATCH] Swap out some additional assigns for tokens, improve tests --- CRM/Contribute/Form/Task/Invoice.php | 9 ++++++++- .../CRM/Contribute/Form/Task/InvoiceTest.php | 20 +++++++++++++++++-- .../contribution_invoice_receipt_html.tpl | 16 +++++++-------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index bf112af0386f..d50f2b571f2e 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -367,9 +367,11 @@ public static function printPDF($contribIDs, &$params, $contactIds) { // @todo not used in shipped template for a very long time, if ever, remove // token is available. 'id' => $contribution->id, + // @todo not used in shipped template from 5.52 'source' => $source, // @todo not used in shipped template from 5.52 'invoice_number' => $contribution->invoice_number, + // @todo not used in shipped template from 5.52 'invoice_id' => $contribution->invoice_id, 'resourceBase' => $config->userFrameworkResourceURL, // @todo not used in shipped template for a long time @@ -382,9 +384,13 @@ public static function printPDF($contribIDs, &$params, $contactIds) { 'notes' => $invoiceNotes, 'lineItem' => $lineItem, 'dataArray' => $dataArray, + // @todo not used in shipped template from 5.52 'refundedStatusId' => $refundedStatusId, + // @todo not used in shipped template from 5.52 'pendingStatusId' => $pendingStatusId, + // @todo not used in shipped template from 5.52 'cancelledStatusId' => $cancelledStatusId, + // @todo not used in shipped template from 5.52 'contribution_status_id' => $contribution->contribution_status_id, // @todo not used in shipped template for a long time 'contributionStatusName' => CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution->contribution_status_id), @@ -401,8 +407,9 @@ public static function printPDF($contribIDs, &$params, $contactIds) { // Kept for backwards compatibility 'stateProvinceAbbreviation' => $billingAddress['state_province_abbreviation'] ?? NULL, 'country' => $billingAddress['country'] ?? NULL, - 'is_pay_later' => $contribution->is_pay_later, // @todo not used in shipped template from 5.52 + 'is_pay_later' => $contribution->is_pay_later, + // @todo not used in shipped template from 5.52 - from here down 'organization_name' => $contribution->_relatedObjects['contact']->organization_name, 'domain_organization' => $domain->name, 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])), diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index 1af09ca4934d..832f87728401 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -44,11 +44,22 @@ public function testInvoiceForDueDate(): void { 'forPage' => 1, ]; - $this->_individualId = $this->individualCreate(); + $contactID = $this->individualCreate(); + $this->callAPISuccess('Address', 'create', [ + 'contact_id' => $contactID, + 'street_address' => '9 Downing Street', + 'state_province_id' => 'Maine', + 'supplemental_address_1' => 'Back Alley', + 'supplemental_address_2' => 'Left corner', + 'postal_code' => 90990, + 'city' => 'Auckland', + 'country_id' => 'US', + ]); $contributionParams = [ - 'contact_id' => $this->_individualId, + 'contact_id' => $contactID, 'total_amount' => 100, 'financial_type_id' => 'Donation', + 'source' => 'Donor gift', ]; $result = $this->callAPISuccess('Contribution', 'create', $contributionParams); @@ -75,6 +86,11 @@ public function testInvoiceForDueDate(): void { $this->assertStringNotContainsString('Due Date', $invoiceHTML[$result['id']]); $this->assertStringNotContainsString('PAYMENT ADVICE', $invoiceHTML[$result['id']]); $this->assertStringContainsString('Mr. Anthony Anderson II', $invoiceHTML[$result['id']]); + $this->assertStringContainsString('Left corner ME', $invoiceHTML[$result['id']]); + $this->assertStringContainsString('9 Downing Street Back Alley', $invoiceHTML[$result['id']]); + $this->assertStringContainsString('Auckland 90990', $invoiceHTML[$result['id']]); + $this->assertStringContainsString('United States', $invoiceHTML[$result['id']]); + $this->assertStringContainsString('Donor gift', $invoiceHTML[$result['id']]); $this->assertStringContainsString('Due Date', $invoiceHTML[$contribution['id']]); $this->assertStringContainsString('PAYMENT ADVICE', $invoiceHTML[$contribution['id']]); diff --git a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl index b3a3cac9f3e6..97afc1cfb9df 100644 --- a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl @@ -127,7 +127,7 @@ - {if $contribution_status_id == $refundedStatusId} + {if '{contribution.contribution_status_id:name}' == 'Refunded'} {ts}Amount Credited{/ts} {else} {ts}Amount Paid{/ts} @@ -150,7 +150,7 @@ - {if $contribution_status_id == $pendingStatusId && $is_pay_later == 1} + {if '{contribution.contribution_status_id:name}' == 'Pending' && '{contribution.is_pay_later}' == 1} {ts 1=$dueDate}DUE DATE: %1{/ts} @@ -161,7 +161,7 @@ - {if $contribution_status_id == $pendingStatusId && $is_pay_later == 1} + {if '{contribution.contribution_status_id:name}' == 'Pending' && '{contribution.is_pay_later}' == 1} @@ -212,7 +212,7 @@
{/if} - {if $contribution_status_id == $refundedStatusId || $contribution_status_id == $cancelledStatusId} + {if '{contribution.contribution_status_id:name}' === 'Refunded' || '{contribution.contribution_status_id:name}' === 'Cancelled'} {if $config->empoweredBy} @@ -249,7 +249,7 @@ - + - + - {if $is_pay_later == 0} + {if '{contribution.is_pay_later}' == 0} @@ -404,7 +404,7 @@ - +
{$supplemental_address_2} {$stateProvinceAbbreviation}{$creditnote_id}{contribution.creditnote_id} {domain.city} @@ -268,7 +268,7 @@
{$source}{contribution.source} {domain.email} @@ -355,7 +355,7 @@ {ts 1=$currency}TOTAL %1{/ts} {$amount|crmMoney:$currency}
{ts}LESS Credit to invoice(s){/ts}
{ts}Credit Note#:{/ts}{$creditnote_id}{contribution.creditnote_id}