Skip to content

Commit

Permalink
Merge pull request #19634 from eileenmcnaughton/iif
Browse files Browse the repository at this point in the history
dev/financial#166 Clean up money formatting in iif
  • Loading branch information
seamuslee001 authored Feb 19, 2021
2 parents b8449b8 + e2caefd commit 60c7b41
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions CRM/Financial/BAO/ExportFormat/IIF.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function makeExport($export) {
'trxn_date' => $this->format($dao->trxn_date, 'date'),
'trxn_id' => $this->format($dao->trxn_id),
'account_name' => $this->format($dao->to_account_name),
'amount' => $this->format($dao->debit_total_amount, 'money'),
'amount' => $this->formatMoney($dao->debit_total_amount),
'contact_name' => $this->format($dao->contact_to_name),
'payment_instrument' => $this->format($dao->payment_instrument),
'check_number' => $this->format($dao->check_number),
Expand Down Expand Up @@ -262,7 +262,7 @@ public function makeExport($export) {
'trxn_date' => $this->format($itemDAO->transaction_date, 'date'),
'spl_id' => $this->format($itemDAO->financial_item_id),
'account_name' => $this->format($itemDAO->account_name),
'amount' => '-' . $this->format($itemDAO->amount, 'money'),
'amount' => '-' . $this->formatMoney($itemDAO->amount),
'contact_name' => $this->format($itemDAO->contact_name),
'payment_instrument' => $this->format($itemDAO->payment_instrument),
'description' => $this->format($itemDAO->description),
Expand All @@ -277,7 +277,7 @@ public function makeExport($export) {
'trxn_date' => $this->format($dao->trxn_date, 'date'),
'spl_id' => $this->format($dao->financial_trxn_id),
'account_name' => $this->format($dao->from_account_name),
'amount' => '-' . $this->format($dao->debit_total_amount, 'money'),
'amount' => '-' . $this->formatMoney($dao->debit_total_amount),
'contact_name' => $this->format($dao->contact_from_name),
'description' => $this->format($dao->item_description),
'payment_instrument' => $this->format($dao->payment_instrument),
Expand Down Expand Up @@ -329,6 +329,17 @@ public function getHookedTemplateFileName() {
return 'CRM/Financial/ExportFormat/IIF.tpl';
}

/**
* Format money.
*
* @param float $amount
*
* @return mixed|string
*/
public function formatMoney($amount) {
return CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency(trim($amount));
}

/**
* @param string $s
* the input string
Expand All @@ -350,10 +361,6 @@ public static function format($s, $type = 'string') {
$sout = CRM_Utils_Date::customFormat($s1, $dateFormat);
break;

case 'money':
$sout = CRM_Utils_Money::format($s, NULL, NULL, TRUE);
break;

case 'string':
case 'notepad':
$s2 = str_replace("\n", '\n', $s1);
Expand Down

0 comments on commit 60c7b41

Please sign in to comment.