Skip to content

Commit

Permalink
Merge pull request #23829 from eileenmcnaughton/inv_lines
Browse files Browse the repository at this point in the history
Replace more assigns with tokens in invoice, add tests
  • Loading branch information
demeritcowboy authored Jun 23, 2022
2 parents 8c371c3 + e7bce1a commit 2032f3e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
9 changes: 8 additions & 1 deletion CRM/Contribute/Form/Task/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand All @@ -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'])),
Expand Down
20 changes: 18 additions & 2 deletions tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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']]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<tr>
<td colspan="3"></td>
<td style="text-align:right;white-space: nowrap"><font size="1">
{if $contribution_status_id == $refundedStatusId}
{if '{contribution.contribution_status_id:name}' == 'Refunded'}
{ts}Amount Credited{/ts}
{else}
{ts}Amount Paid{/ts}
Expand All @@ -150,7 +150,7 @@
<tr>
<td colspan="5"></td>
</tr>
{if $contribution_status_id == $pendingStatusId && $is_pay_later == 1}
{if '{contribution.contribution_status_id:name}' == 'Pending' && '{contribution.is_pay_later}' == 1}
<tr>
<td colspan="3"><b><font size="1" align="center">{ts 1=$dueDate}DUE DATE: %1{/ts}</font></b></td>
<td colspan="2"></td>
Expand All @@ -161,7 +161,7 @@
</tr>
</table>

{if $contribution_status_id == $pendingStatusId && $is_pay_later == 1}
{if '{contribution.contribution_status_id:name}' == 'Pending' && '{contribution.is_pay_later}' == 1}
<table style="margin-top:5px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="{$resourceBase}/i/contribute/cut_line.png" height="15"></td>
Expand Down Expand Up @@ -212,7 +212,7 @@
</table>
{/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}
<table style="margin-top:2px;padding-left:7px;page-break-before: always;">
<tr>
Expand Down Expand Up @@ -249,7 +249,7 @@
</tr>
<tr>
<td style="padding-left:17px;"><font size="1" align="center">{$supplemental_address_2} {$stateProvinceAbbreviation}</font></td>
<td style="padding-left:30px;"><font size="1" align="right">{$creditnote_id}</font></td>
<td style="padding-left:30px;"><font size="1" align="right">{contribution.creditnote_id}</font></td>
<td>
<font size="1" align="right">
{domain.city}
Expand All @@ -268,7 +268,7 @@
</tr>
<tr>
<td></td>
<td style="padding-left:30px;"><font size="1" align="right">{$source}</font></td>
<td style="padding-left:30px;"><font size="1" align="right">{contribution.source}</font></td>
<td>
<font size="1" align="right">
{domain.email}
Expand Down Expand Up @@ -355,7 +355,7 @@
<td style="padding-left:28px;text-align:right;"><b><font size="1">{ts 1=$currency}TOTAL %1{/ts}</font></b></td>
<td style="padding-left:28px;text-align:right;"><font size="1">{$amount|crmMoney:$currency}</font></td>
</tr>
{if $is_pay_later == 0}
{if '{contribution.is_pay_later}' == 0}
<tr>
<td colspan="3"></td>
<td style="padding-left:28px;text-align:right;"><font size="1">{ts}LESS Credit to invoice(s){/ts}</font></td>
Expand Down Expand Up @@ -404,7 +404,7 @@
<tr>
<td colspan="2"></td>
<td><font size="1" align="right" style="font-weight:bold;">{ts}Credit Note#:{/ts}</font></td>
<td><font size="1" align="right">{$creditnote_id}</font></td>
<td><font size="1" align="right">{contribution.creditnote_id}</font></td>
</tr>
<tr><td colspan="5"style="color:#F5F5F5;"><hr></hr></td></tr>
<tr>
Expand Down

0 comments on commit 2032f3e

Please sign in to comment.