Fixed a bug that would leave all amounts at zero. #224

This commit is contained in:
James Cole
2016-03-20 16:41:48 +01:00
parent 628268d47c
commit 6698b57f52
2 changed files with 7 additions and 17 deletions

View File

@@ -70,11 +70,8 @@ class Amount
*/
public function formatJournal(TransactionJournal $journal, bool $coloured = true): string
{
$locale = setlocale(LC_MONETARY, 0);
$float = round($journal->destination_amount, 2);
if ($journal->isWithdrawal()) {
$float = round($journal->source_amount, 2);
}
$locale = setlocale(LC_MONETARY, 0);
$float = round(TransactionJournal::amount($journal), 2);
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
$currencyCode = $journal->transaction_currency_code ?? $journal->transactionCurrency->code;
$result = $formatter->formatCurrency($float, $currencyCode);