'resourceBase' => $config->userFrameworkResourceURL,
'defaultCurrency' => $config->defaultCurrency,
'amount' => $contribution->total_amount,
+ 'currency' => $contribution->currency,
'amountDue' => $amountDue,
'amountPaid' => $amountPaid,
'invoice_date' => $invoiceDate,
}
+ /**
+ * Test invoices if payment is made with different currency.
+ *
+ * https://lab.civicrm.org/dev/core/issues/2269
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testThatInvoiceShowTheActuallContributionCurrencyInsteadOfTheDefaultOne() {
+ $this->setDefaultCurrency('USD');
+
+ $this->_individualId = $this->individualCreate();
+
+ $contributionParams = [
+ 'contact_id' => $this->_individualId,
+ 'total_amount' => 100,
+ 'currency' => 'GBP',
+ 'financial_type_id' => 'Donation',
+ 'contribution_status_id' => 1,
+ ];
+
+ $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
+
+ $params = [
+ 'output' => 'pdf_invoice',
+ 'forPage' => 1,
+ ];
+
+ $invoiceHTML = CRM_Contribute_Form_Task_Invoice::printPDF([$contribution['id']], $params, [$this->_individualId]);
+
+ $this->assertNotContains('$', $invoiceHTML);
+ $this->assertNotContains('Amount USD', $invoiceHTML);
+ $this->assertNotContains('TOTAL USD', $invoiceHTML);
+ $this->assertContains('£ 0.00', $invoiceHTML);
+ $this->assertContains('£ 100.00', $invoiceHTML);
+ $this->assertContains('Amount GBP', $invoiceHTML);
+ $this->assertContains('TOTAL GBP', $invoiceHTML);
+
+ }
+
}
<th style="text-align:right;font-weight:bold;white-space: nowrap"><font size="1">{ts}Quantity{/ts}</font></th>
<th style="text-align:right;font-weight:bold;white-space: nowrap"><font size="1">{ts}Unit Price{/ts}</font></th>
<th style="text-align:right;font-weight:bold;white-space: nowrap"><font size="1">{$taxTerm}</font></th>
- <th style="text-align:right;font-weight:bold;white-space: nowrap"><font size="1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
+ <th style="text-align:right;font-weight:bold;white-space: nowrap"><font size="1">{ts 1=$currency}Amount %1{/ts}</font></th>
</tr>
{foreach from=$lineItem item=value key=priceset name=taxpricevalue}
{if $smarty.foreach.taxpricevalue.index eq 0}
{/foreach}
<tr>
<td colspan="3"></td>
- <td style="text-align:right;white-space: nowrap"><b><font size="1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
+ <td style="text-align:right;white-space: nowrap"><b><font size="1">{ts 1=$currency}TOTAL %1{/ts}</font></b></td>
<td style="text-align:right;"><font size="1">{$amount|crmMoney:$currency}</font></td>
</tr>
<tr>
<th style="padding-left:28px;text-align:right;font-weight:bold;"><font size="1">{ts}Quantity{/ts}</font></th>
<th style="padding-left:28px;text-align:right;font-weight:bold;"><font size="1">{ts}Unit Price{/ts}</font></th>
<th style="padding-left:28px;text-align:right;font-weight:bold;"><font size="1">{$taxTerm}</font></th>
- <th style="padding-left:28px;text-align:right;font-weight:bold;"><font size="1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
+ <th style="padding-left:28px;text-align:right;font-weight:bold;"><font size="1">{ts 1=$currency}Amount %1{/ts}</font></th>
</tr>
{foreach from=$lineItem item=value key=priceset name=pricevalue}
{if $smarty.foreach.pricevalue.index eq 0}
</tr>
<tr>
<td colspan="3"></td>
- <td style="padding-left:28px;text-align:right;"><b><font size="1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
+ <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}