From a487c7b4b2f8a5f35be537c821b750e7ae1d56a0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 4 Jun 2017 23:39:26 +0200 Subject: [PATCH] Make sure amounts are formatted, and fixed some issues. --- app/Helpers/Collector/JournalCollector.php | 13 +- app/Helpers/Report/PopupReport.php | 2 +- app/Http/Controllers/JsonController.php | 27 ++-- app/Http/Controllers/PiggyBankController.php | 24 ++- .../Account/AccountRepository.php | 26 +++- app/Repositories/Journal/JournalTasker.php | 4 + .../PiggyBank/PiggyBankRepository.php | 4 +- app/Support/Amount.php | 80 +++++++++- app/Support/Twig/AmountFormat.php | 141 +++++++++++++++++- resources/views/list/journals-tiny.twig | 3 +- resources/views/list/journals.twig | 9 +- resources/views/popup/list/journals.twig | 2 +- .../reports/partials/journals-audit.twig | 3 +- resources/views/transactions/mass-delete.twig | 5 +- resources/views/transactions/show.twig | 29 +--- 15 files changed, 301 insertions(+), 71 deletions(-) diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index a85535d907..fb19073685 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -65,12 +65,22 @@ class JournalCollector implements JournalCollectorInterface 'bills.name as bill_name', 'bills.name_encrypted as bill_name_encrypted', 'transactions.id as id', - 'transactions.amount as transaction_amount', + 'transactions.description as transaction_description', 'transactions.account_id', 'transactions.identifier', 'transactions.transaction_journal_id', + + 'transactions.amount as transaction_amount', 'transaction_currencies.code as transaction_currency_code', + 'transaction_currencies.symbol as transaction_currency_symbol', + 'transaction_currencies.decimal_places as transaction_currency_dp', + + 'transactions.foreign_amount as transaction_foreign_amount', + 'foreign_currencies.code as foreign_currency_code', + 'foreign_currencies.symbol as foreign_currency_symbol', + 'foreign_currencies.decimal_places as foreign_currency_dp', + 'accounts.name as account_name', 'accounts.encrypted as account_encrypted', 'account_types.type as account_type', @@ -489,6 +499,7 @@ class JournalCollector implements JournalCollectorInterface ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id') ->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transactions.transaction_currency_id') + ->leftJoin('transaction_currencies as foreign_currencies', 'foreign_currencies.id', 'transactions.foreign_currency_id') ->whereNull('transactions.deleted_at') ->whereNull('transaction_journals.deleted_at') ->where('transaction_journals.user_id', $this->user->id) diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php index f4d0a07d17..265c930e6c 100644 --- a/app/Helpers/Report/PopupReport.php +++ b/app/Helpers/Report/PopupReport.php @@ -187,7 +187,7 @@ class PopupReport implements PopupReportInterface $journals = $journals->filter( function (Transaction $transaction) use ($report) { // get the destinations: - $destinations = $transaction->destinationAccountList($transaction->transactionJournal)->pluck('id')->toArray(); + $destinations = $transaction->transactionJournal->destinationAccountList()->pluck('id')->toArray(); // do these intersect with the current list? return !empty(array_intersect($report, $destinations)); diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index c8e916e231..4449e17b01 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -116,10 +116,11 @@ class JsonController extends Controller * Since both this method and the chart use the exact same data, we can suffice * with calling the one method in the bill repository that will get this amount. */ - $amount = $repository->getBillsPaidInRange($start, $end); // will be a negative amount. - $amount = bcmul($amount, '-1'); + $amount = $repository->getBillsPaidInRange($start, $end); // will be a negative amount. + $amount = bcmul($amount, '-1'); + $currency = Amount::getDefaultCurrency(); - $data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; + $data = ['box' => 'bills-paid', 'amount' => Amount::formatAnything($currency, $amount, false), 'amount_raw' => $amount]; return Response::json($data); } @@ -131,10 +132,11 @@ class JsonController extends Controller */ public function boxBillsUnpaid(BillRepositoryInterface $repository) { - $start = session('start', Carbon::now()->startOfMonth()); - $end = session('end', Carbon::now()->endOfMonth()); - $amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount. - $data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); + $amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount. + $currency = Amount::getDefaultCurrency(); + $data = ['box' => 'bills-unpaid', 'amount' => Amount::formatAnything($currency, $amount, false), 'amount_raw' => $amount]; return Response::json($data); } @@ -167,8 +169,9 @@ class JsonController extends Controller ->setTypes([TransactionType::DEPOSIT]) ->withOpposingAccount(); - $amount = strval($collector->getJournals()->sum('transaction_amount')); - $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; + $amount = strval($collector->getJournals()->sum('transaction_amount')); + $currency = Amount::getDefaultCurrency(); + $data = ['box' => 'in', 'amount' => Amount::formatAnything($currency, $amount, false), 'amount_raw' => $amount]; $cache->store($data); return Response::json($data); @@ -200,9 +203,9 @@ class JsonController extends Controller $collector->setAllAssetAccounts()->setRange($start, $end) ->setTypes([TransactionType::WITHDRAWAL]) ->withOpposingAccount(); - $amount = strval($collector->getJournals()->sum('transaction_amount')); - - $data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; + $amount = strval($collector->getJournals()->sum('transaction_amount')); + $currency = Amount::getDefaultCurrency(); + $data = ['box' => 'out', 'amount' => Amount::formatAnything($currency, $amount, false), 'amount_raw' => $amount]; $cache->store($data); return Response::json($data); diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 052900cba5..564ee720ae 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -276,18 +276,29 @@ class PiggyBankController extends Controller */ public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) { - $amount = $request->get('amount'); - + $amount = $request->get('amount'); + $currency = Amount::getDefaultCurrency(); if ($repository->canAddAmount($piggyBank, $amount)) { $repository->addAmount($piggyBank, $amount); - Session::flash('success', strval(trans('firefly.added_amount_to_piggy', ['amount' => Amount::format($amount, false), 'name' => $piggyBank->name]))); + Session::flash( + 'success', strval( + trans( + 'firefly.added_amount_to_piggy', + ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name] + ) + ) + ); Preferences::mark(); return redirect(route('piggy-banks.index')); } Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.'); - Session::flash('error', strval(trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::format($amount, false), 'name' => e($piggyBank->name)]))); + Session::flash( + 'error', strval( + trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]) + ) + ); return redirect(route('piggy-banks.index')); } @@ -302,10 +313,11 @@ class PiggyBankController extends Controller public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) { $amount = $request->get('amount'); + $currency = Amount::getDefaultCurrency(); if ($repository->canRemoveAmount($piggyBank, $amount)) { $repository->removeAmount($piggyBank, $amount); Session::flash( - 'success', strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::format($amount, false), 'name' => $piggyBank->name])) + 'success', strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name])) ); Preferences::mark(); @@ -314,7 +326,7 @@ class PiggyBankController extends Controller $amount = strval(round($request->get('amount'), 12)); - Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::format($amount, false), 'name' => e($piggyBank->name)]))); + Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]))); return redirect(route('piggy-banks.index')); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 7b594555b8..bb9ace5034 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -481,7 +481,6 @@ class AccountRepository implements AccountRepositoryInterface [ 'user_id' => $this->user->id, 'transaction_type_id' => $transactionType->id, - // TODO update this transaction currency reference. 'transaction_currency_id' => $currencyId, 'description' => 'Initial balance for "' . $account->name . '"', 'completed' => true, @@ -502,9 +501,23 @@ class AccountRepository implements AccountRepositoryInterface $secondAmount = $amount; } - $one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]); + $one = new Transaction( + [ + 'account_id' => $firstAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $firstAmount, + 'transaction_currency_id' => $currencyId, + ] + ); $one->save();// first transaction: from - $two = new Transaction(['account_id' => $secondAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $secondAmount]); + + $two = new Transaction( + [ + 'account_id' => $secondAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $secondAmount, + 'transaction_currency_id' => $currencyId,] + ); $two->save(); // second transaction: to Log::debug(sprintf('Stored two transactions, #%d and #%d', $one->id, $two->id)); @@ -623,18 +636,19 @@ class AccountRepository implements AccountRepositoryInterface // update date: $journal->date = $date; - // TODO update this transaction currency reference. $journal->transaction_currency_id = $currencyId; $journal->save(); // update transactions: /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { if ($account->id == $transaction->account_id) { - $transaction->amount = $amount; + $transaction->amount = $amount; + $transaction->transaction_currency_id = $currencyId; $transaction->save(); } if ($account->id != $transaction->account_id) { - $transaction->amount = bcmul($amount, '-1'); + $transaction->amount = bcmul($amount, '-1'); + $transaction->transaction_currency_id = $currencyId; $transaction->save(); } } diff --git a/app/Repositories/Journal/JournalTasker.php b/app/Repositories/Journal/JournalTasker.php index bb0c8bcdd2..5958b0ff1c 100644 --- a/app/Repositories/Journal/JournalTasker.php +++ b/app/Repositories/Journal/JournalTasker.php @@ -101,10 +101,12 @@ class JournalTasker implements JournalTaskerInterface 'destination_accounts.encrypted as destination_account_encrypted', 'destination_account_types.type as destination_account_type', 'native_currencies.id as transaction_currency_id', + 'native_currencies.decimal_places as transaction_currency_dp', 'native_currencies.code as transaction_currency_code', 'native_currencies.symbol as transaction_currency_symbol', 'foreign_currencies.id as foreign_currency_id', + 'foreign_currencies.decimal_places as foreign_currency_dp', 'foreign_currencies.code as foreign_currency_code', 'foreign_currencies.symbol as foreign_currency_symbol', @@ -142,9 +144,11 @@ class JournalTasker implements JournalTaskerInterface 'transaction_currency_id' => $entry->transaction_currency_id, 'transaction_currency_code' => $entry->transaction_currency_code, 'transaction_currency_symbol' => $entry->transaction_currency_symbol, + 'transaction_currency_dp' => $entry->transaction_currency_dp, 'foreign_currency_id' => $entry->foreign_currency_id, 'foreign_currency_code' => $entry->foreign_currency_code, 'foreign_currency_symbol' => $entry->foreign_currency_symbol, + 'foreign_currency_dp' => $entry->foreign_currency_dp, ]; if ($entry->destination_account_type === AccountType::CASH) { $transaction['destination_account_name'] = ''; diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index e721c71b63..b5807a51f9 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -240,10 +240,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface */ public function getPiggyBanksWithAmount(): Collection { + $currency = Amount::getDefaultCurrency(); $set = $this->getPiggyBanks(); foreach ($set as $piggy) { $currentAmount = $piggy->currentRelevantRep()->currentamount ?? '0'; - $piggy->name = $piggy->name . ' (' . Amount::format($currentAmount, false) . ')'; + + $piggy->name = $piggy->name . ' (' . Amount::formatAnything($currency, $currentAmount, false) . ')'; } return $set; diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 7d11d68b7d..c75630d0ab 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace FireflyIII\Support; use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Models\Transaction; +use FireflyIII\Models\Transaction as TransactionModel; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; @@ -28,6 +28,7 @@ use Preferences as Prefs; */ class Amount { + /** * bool $sepBySpace is $localeconv['n_sep_by_space'] * int $signPosn = $localeconv['n_sign_posn'] @@ -242,4 +243,81 @@ class Amount 'zero' => $positive, ]; } + + /** + * @param TransactionJournal $journal + * @param bool $coloured + * + * @return string + */ + public function journalAmount(TransactionJournal $journal, bool $coloured = true): string + { + $amounts = []; + $transactions = $journal->transactions()->where('amount', '>', 0)->get(); + /** @var TransactionModel $transaction */ + foreach ($transactions as $transaction) { + // model some fields to fit "transactionAmount()": + $transaction->transaction_amount = $transaction->amount; + $transaction->transaction_foreign_amount = $transaction->foreign_amount; + $transaction->transaction_type_type = $journal->transactionType->type; + $transaction->transaction_currency_symbol = $transaction->transactionCurrency->symbol; + $transaction->transaction_currency_dp = $transaction->transactionCurrency->decimal_places; + if (!is_null($transaction->foreign_currency_id)) { + $transaction->foreign_currency_symbol = $transaction->foreignCurrency->symbol; + $transaction->foreign_currency_dp = $transaction->foreignCurrency->decimal_places; + } + + $amounts[] = $this->transactionAmount($transaction, $coloured); + } + + return join(' / ', $amounts); + + } + + /** + * This formats a transaction, IF that transaction has been "collected" using the JournalCollector. + * + * @param TransactionModel $transaction + * @param bool $coloured + * + * @return string + */ + public function transactionAmount(TransactionModel $transaction, bool $coloured = true): string + { + $amount = bcmul(app('steam')->positive(strval($transaction->transaction_amount)), '-1'); + $format = '%s'; + + if ($transaction->transaction_type_type === TransactionType::DEPOSIT) { + $amount = bcmul($amount, '-1'); + } + + if ($transaction->transaction_type_type === TransactionType::TRANSFER) { + $amount = app('steam')->positive($amount); + $coloured = false; + $format = '%s'; + } + + $currency = new TransactionCurrency; + $currency->symbol = $transaction->transaction_currency_symbol; + $currency->decimal_places = $transaction->transaction_currency_dp; + $str = sprintf($format, $this->formatAnything($currency, $amount, $coloured)); + + + if (!is_null($transaction->transaction_foreign_amount)) { + $amount = strval($transaction->transaction_foreign_amount); + + if ($transaction->transaction_type_type === TransactionType::TRANSFER) { + $amount = app('steam')->positive($amount); + $coloured = false; + $format = '%s'; + } + + $currency = new TransactionCurrency; + $currency->symbol = $transaction->foreign_currency_symbol; + $currency->decimal_places = $transaction->foreign_currency_dp; + $str .= ' (' . sprintf($format, $this->formatAnything($currency, $amount, $coloured)) . ')'; + } + + return $str; + } } diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php index eb06a98ebf..cc4c45dc19 100644 --- a/app/Support/Twig/AmountFormat.php +++ b/app/Support/Twig/AmountFormat.php @@ -13,6 +13,7 @@ namespace FireflyIII\Support\Twig; use FireflyIII\Models\Account as AccountModel; +use FireflyIII\Models\Transaction as TransactionModel; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use Twig_Extension; @@ -45,6 +46,12 @@ class AmountFormat extends Twig_Extension { return [ $this->formatAmountByAccount(), + $this->transactionAmount(), + $this->journalAmount(), + $this->formatDestinationAfter(), + $this->formatDestinationBefore(), + $this->formatSourceAfter(), + $this->formatSourceBefore(), ]; } @@ -68,7 +75,9 @@ class AmountFormat extends Twig_Extension return new Twig_SimpleFilter( 'formatAmount', function (string $string): string { - return app('amount')->format($string); + $currency = app('amount')->getDefaultCurrency(); + + return app('amount')->formatAnything($currency, $string, true); }, ['is_safe' => ['html']] ); } @@ -102,8 +111,136 @@ class AmountFormat extends Twig_Extension return new Twig_SimpleFilter( 'formatAmountPlain', function (string $string): string { - return app('amount')->format($string, false); + $currency = app('amount')->getDefaultCurrency(); + + return app('amount')->formatAnything($currency, $string, false); }, ['is_safe' => ['html']] ); } + + /** + * @return Twig_SimpleFunction + */ + protected function formatDestinationAfter(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'formatDestinationAfter', function (array $transaction): string { + + // build fake currency for main amount. + $format = new TransactionCurrency; + $format->decimal_places = $transaction['transaction_currency_dp']; + $format->symbol = $transaction['transaction_currency_symbol']; + $string = app('amount')->formatAnything($format, $transaction['destination_account_after'], true); + + // also append foreign amount for clarity: + if (!is_null($transaction['foreign_destination_amount'])) { + // build fake currency for foreign amount + $format = new TransactionCurrency; + $format->decimal_places = $transaction['foreign_currency_dp']; + $format->symbol = $transaction['foreign_currency_symbol']; + $string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_destination_amount'], true) . ')'; + } + + + return $string; + + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function formatDestinationBefore(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'formatDestinationBefore', function (array $transaction): string { + + // build fake currency for main amount. + $format = new TransactionCurrency; + $format->decimal_places = $transaction['transaction_currency_dp']; + $format->symbol = $transaction['transaction_currency_symbol']; + + return app('amount')->formatAnything($format, $transaction['destination_account_before'], true); + + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function formatSourceAfter(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'formatSourceAfter', function (array $transaction): string { + + // build fake currency for main amount. + $format = new TransactionCurrency; + $format->decimal_places = $transaction['transaction_currency_dp']; + $format->symbol = $transaction['transaction_currency_symbol']; + $string = app('amount')->formatAnything($format, $transaction['source_account_after'], true); + + // also append foreign amount for clarity: + if (!is_null($transaction['foreign_source_amount'])) { + // build fake currency for foreign amount + $format = new TransactionCurrency; + $format->decimal_places = $transaction['foreign_currency_dp']; + $format->symbol = $transaction['foreign_currency_symbol']; + $string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_source_amount'], true) . ')'; + } + + + return $string; + + + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function formatSourceBefore(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'formatSourceBefore', function (array $transaction): string { + + // build fake currency for main amount. + $format = new TransactionCurrency; + $format->decimal_places = $transaction['transaction_currency_dp']; + $format->symbol = $transaction['transaction_currency_symbol']; + + return app('amount')->formatAnything($format, $transaction['source_account_before'], true); + + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function journalAmount(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'journalAmount', function (TransactionJournal $journal): string { + + return app('amount')->journalAmount($journal, true); + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function transactionAmount(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'transactionAmount', function (TransactionModel $transaction): string { + + return app('amount')->transactionAmount($transaction, true); + }, ['is_safe' => ['html']] + ); + } + } \ No newline at end of file diff --git a/resources/views/list/journals-tiny.twig b/resources/views/list/journals-tiny.twig index 63306fa102..ed6ee40b30 100644 --- a/resources/views/list/journals-tiny.twig +++ b/resources/views/list/journals-tiny.twig @@ -14,8 +14,7 @@ {{ transaction.description }} {% endif %} - {# TODO replace with new format code #} - XX.XX + {{ transactionAmount(transaction) }} {% endfor %} diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twig index acd95000bb..02fd791df8 100644 --- a/resources/views/list/journals.twig +++ b/resources/views/list/journals.twig @@ -62,14 +62,7 @@ - {% if transaction.transaction_type_type == 'Transfer' %} - - {# TODO format amount of transaction. #} - {# TODO format: Amount of transaction (amount in foreign) / total (total foreign) #} - XX.XX - {% else %} - XX.XX - {% endif %} + {{ transactionAmount(transaction) }} diff --git a/resources/views/popup/list/journals.twig b/resources/views/popup/list/journals.twig index 1177cce1f5..1ab88a9f32 100644 --- a/resources/views/popup/list/journals.twig +++ b/resources/views/popup/list/journals.twig @@ -46,7 +46,7 @@ {# TODO replace with new format code #} - XX.XX + {{ transactionAmount(transaction) }} {{ transaction.date.formatLocalized(monthAndDayFormat) }} diff --git a/resources/views/reports/partials/journals-audit.twig b/resources/views/reports/partials/journals-audit.twig index 48c5430658..4f0f794f96 100644 --- a/resources/views/reports/partials/journals-audit.twig +++ b/resources/views/reports/partials/journals-audit.twig @@ -59,8 +59,7 @@ {{ transaction.before|formatAmount }} - {# TODO replace with new format code #} - XX.XX + {{ transactionAmount(transaction) }} {{ transaction.after|formatAmount }} diff --git a/resources/views/transactions/mass-delete.twig b/resources/views/transactions/mass-delete.twig index 2049df92f8..864ea084ae 100644 --- a/resources/views/transactions/mass-delete.twig +++ b/resources/views/transactions/mass-delete.twig @@ -29,7 +29,7 @@   {{ trans('list.description') }} - {{ trans('list.amount') }} + {{ trans('list.total_amount') }} {{ trans('list.date') }} {{ trans('list.from') }} {{ trans('list.to') }} @@ -43,8 +43,7 @@ {{ journal.description }} - {# TODO fix amount display #} - XX.XX + {{ journalAmount(journal) }} {{ journal.date.formatLocalized(monthAndDayFormat) }} diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig index b115ca16c8..a6a7fc8876 100644 --- a/resources/views/transactions/show.twig +++ b/resources/views/transactions/show.twig @@ -37,8 +37,7 @@ {{ 'total_amount'|_ }} - {# TODO fix amount display #} - XX.XX + {{ journalAmount(journal) }} @@ -299,8 +298,7 @@ - {# TODO replace with new display: #} - XX.XX + {{ formatSourceBefore(transaction) }} → {{ formatSourceAfter(transaction) }} {% if transaction.destination_account_type == 'Cash account' %} @@ -311,29 +309,10 @@ - {# TODO replace with new format code #} - XX.XX + {{ formatDestinationBefore(transaction) }} → {{ formatDestinationAfter(transaction) }} - {% if journal.transactiontype.type == 'Deposit' %} - - {# TODO replace with new format code #} - XX.XX - - {% endif %} - {% if journal.transactiontype.type == 'Withdrawal' %} - - {# TODO replace with new format code #} - XX.XX - - {% endif %} - {% if journal.transactiontype.type == 'Transfer' %} - - - {# TODO replace with new format code #} - XX.XX - - {% endif %} + {{ journalAmount(journal) }} {{ transactionIdBudgets(transaction.source_id) }}