Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Improve report boxes one by one #2428
James Coled8eb59736e34
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.phpindex 72f197bc0d..8cafe310a3 100644--- a/app/Http/Controllers/Report/OperationsController.php+++ b/app/Http/Controllers/Report/OperationsController.php@@ -78,10 +78,10 @@ class OperationsController extends Controllerif ($cache->has()) {return $cache->get(); // @codeCoverageIgnore}- $entries = $this->tasker->getExpenseReport($start, $end, $accounts);- $type = 'expense-entry';+ $report = $this->tasker->getExpenseReport($start, $end, $accounts);+ $type = 'expense-entry';try {- $result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();+ $result = view('reports.partials.income-expenses', compact('report', 'type'))->render();// @codeCoverageIgnoreStart} catch (Throwable $e) {Log::debug(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage()));@@ -113,17 +113,16 @@ class OperationsController extends Controllerif ($cache->has()) {return $cache->get(); // @codeCoverageIgnore}- $entries = $this->tasker->getIncomeReport($start, $end, $accounts);- $type = 'income-entry';+ $report = $this->tasker->getIncomeReport($start, $end, $accounts);+ $type = 'income-entry';try {- $result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();+ $result = view('reports.partials.income-expenses', compact('report', 'type'))->render();// @codeCoverageIgnoreStart} catch (Throwable $e) {Log::debug(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage()));$result = 'Could not render view.';}// @codeCoverageIgnoreEnd-$cache->store($result);return $result;@@ -150,32 +149,34 @@ class OperationsController extends Controllerreturn $cache->get(); // @codeCoverageIgnore}- $incomes = $this->tasker->getIncomeReport($start, $end, $accounts);- $expenses = $this->tasker->getExpenseReport($start, $end, $accounts);- $incomeSum = array_sum(- array_map(- static function ($item) {- return $item['sum'];- },- $incomes- )- );+ $incomes = $this->tasker->getIncomeReport($start, $end, $accounts);+ $expenses = $this->tasker->getExpenseReport($start, $end, $accounts);+ $sums = [];+ $keys = array_unique(array_merge(array_keys($incomes['sums']), array_keys($expenses['sums'])));++ /** @var int $currencyId */+ foreach ($keys as $currencyId) {+ $currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId];+ $sums[$currencyId] = $sums[$currencyId] ?? [+ 'currency_id' => $currencyId,+ 'currency_name' => $currencyInfo['currency_name'],+ 'currency_code' => $currencyInfo['currency_code'],+ 'currency_symbol' => $currencyInfo['currency_symbol'],+ 'currency_decimal_places' => $currencyInfo['currency_decimal_places'],+ 'in' => $incomes['sums'][$currencyId]['sum'] ?? '0',+ 'out' => $expenses['sums'][$currencyId]['sum'] ?? '0',+ 'sum' => '0',+ ];+ $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['in'], $sums[$currencyId]['out']);+ }- $expensesSum = array_sum(- array_map(- static function ($item) {- return $item['sum'];- },- $expenses- )- );- try {- $result = view('reports.partials.operations', compact('incomeSum', 'expensesSum'))->render();+ //try {+ $result = view('reports.partials.operations', compact('sums'))->render();// @codeCoverageIgnoreStart- } catch (Throwable $e) {- Log::debug(sprintf('Could not render reports.partials.operations: %s', $e->getMessage()));- $result = 'Could not render view.';- }+// } catch (Throwable $e) {+// Log::debug(sprintf('Could not render reports.partials.operations: %s', $e->getMessage()));+// $result = 'Could not render view.';+// }// @codeCoverageIgnoreEnd$cache->store($result);diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 2f4c3b1ed5..7966641d4f 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -304,7 +304,7 @@ class CreateRecurringTransactions implements ShouldQueueLog::debug(sprintf('Now at date %s.', $date->format('Y-m-d')));$date->startOfDay();if ($date->ne($this->date)) {- Log::debug(sprintf('%s is not not today (%s)', $date->format('Y-m-d'), $this->date->format('Y-m-d')));+ Log::debug(sprintf('%s is not today (%s)', $date->format('Y-m-d'), $this->date->format('Y-m-d')));return null;}diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.phpindex fa75324ce8..99ef2f8adb 100644--- a/app/Repositories/Account/AccountTasker.php+++ b/app/Repositories/Account/AccountTasker.php@@ -55,7 +55,6 @@ class AccountTasker implements AccountTaskerInterface* @param Carbon $end** @return array- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array{@@ -63,36 +62,42 @@ class AccountTasker implements AccountTaskerInterface$yesterday->subDay();$startSet = app('steam')->balancesByAccounts($accounts, $yesterday);$endSet = app('steam')->balancesByAccounts($accounts, $end);-Log::debug('Start of accountreport');/** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);-- /** @var CurrencyRepositoryInterface $currencyRepository */- $currencyRepository = app(CurrencyRepositoryInterface::class);- $defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);+ $repository = app(AccountRepositoryInterface::class);+ $defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);$return = [- 'currencies' => [],- 'start' => '0',- 'end' => '0',- 'difference' => '0',- 'accounts' => [],+ 'accounts' => [],+ 'sums' => [],];/** @var Account $account */foreach ($accounts as $account) {- $id = $account->id;- $currencyId = (int)$repository->getMetaValue($account, 'currency_id');- $currency = $currencyRepository->findNull($currencyId);- $return['currencies'][] = $currencyId;- $entry = [- 'name' => $account->name,- 'id' => $account->id,- 'currency' => $currency ?? $defaultCurrency,- 'start_balance' => '0',- 'end_balance' => '0',+ $id = $account->id;+ $currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;+ $return['sums'][$currency->id] = $return['sums'][$currency->id] ?? [+ 'start' => '0',+ 'end' => '0',+ 'difference' => '0',+ 'currency_id' => $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_name' => $currency->name,+ 'currency_decimal_places' => $currency->decimal_places,];+++ $entry = [+ 'name' => $account->name,+ 'id' => $account->id,+ 'currency_id' => $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_name' => $currency->name,+ 'currency_decimal_places' => $currency->decimal_places,+ 'start_balance' => '0',+ 'end_balance' => '0',];// get first journal date:@@ -106,13 +111,14 @@ class AccountTasker implements AccountTaskerInterface$entry['start_balance'] = $first->transactions()->where('account_id', $account->id)->first()->amount;Log::debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));}- $return['start'] = bcadd($return['start'], $entry['start_balance']);- $return['end'] = bcadd($return['end'], $entry['end_balance']);+ $return['sums'][$currency->id]['start'] = bcadd($return['sums'][$currency->id]['start'], $entry['start_balance']);+ $return['sums'][$currency->id]['end'] = bcadd($return['sums'][$currency->id]['end'], $entry['end_balance']);+ $return['accounts'][$id] = $entry;+ }- $return['accounts'][$id] = $entry;+ foreach (array_keys($return['sums']) as $index) {+ $return['sums'][$index]['difference'] = bcsub($return['sums'][$index]['end'], $return['sums'][$index]['start']);}- $return['currencies'] = count(array_unique($return['currencies']));- $return['difference'] = bcsub($return['end'], $return['start']);return $return;}@@ -135,21 +141,21 @@ class AccountTasker implements AccountTaskerInterface$collector->setSourceAccounts($accounts)->setRange($start, $end);$collector->excludeDestinationAccounts($accounts);- $collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])- ->withAccountInformation();+ $collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])->withAccountInformation();$journals = $collector->getExtractedJournals();- $expenses = $this->groupExpenseByDestination($journals);-- // sort the result- // Obtain a list of columns- $sum = [];- foreach ($expenses as $accountId => $row) {- $sum[$accountId] = (float)$row['sum'];- }-- array_multisort($sum, SORT_ASC, $expenses);-- return $expenses;+ $report = $this->groupExpenseByDestination($journals);++ // TODO sorting+// // sort the result+// // Obtain a list of columns+// $sum = [];+// foreach ($expenses as $accountId => $row) {+// $sum[$accountId] = (float)$row['sum'];+// }+//+// array_multisort($sum, SORT_ASC, $expenses);++ return $report;}/**@@ -169,20 +175,20 @@ class AccountTasker implements AccountTaskerInterface$collector = app(GroupCollectorInterface::class);$collector->setDestinationAccounts($accounts)->setRange($start, $end);$collector->excludeSourceAccounts($accounts);- $collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])- ->withAccountInformation();- $income = $this->groupIncomeBySource($collector->getExtractedJournals());+ $collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])->withAccountInformation();+ $report = $this->groupIncomeBySource($collector->getExtractedJournals());// sort the result// Obtain a list of columns- $sum = [];- foreach ($income as $accountId => $row) {- $sum[$accountId] = (float)$row['sum'];- }-- array_multisort($sum, SORT_DESC, $income);-- return $income;+ // $sum = [];+ // foreach ($report['income'] as $accountId => $row) {+ // $sum[$accountId] = (float)$row['sum'];+ // }+ // TODO proper sorting.+ //array_multisort($sum, SORT_DESC, $report);+ // var_dump($report);exit;++ return $report;}/**@@ -204,51 +210,52 @@ class AccountTasker implements AccountTaskerInterface/** @var CurrencyRepositoryInterface $currencyRepos */$currencyRepos = app(CurrencyRepositoryInterface::class);$currencies = [$defaultCurrency->id => $defaultCurrency,];- $expenses = [];- $countAccounts = []; // if count remains 0 use original name, not the name with the currency.+ $report = [+ 'accounts' => [],+ 'sums' => [],+ ];/** @var array $journal */foreach ($array as $journal) {- $destinationId = (int)$journal['destination_account_id'];- $currencyId = (int)$journal['currency_id'];- $key = sprintf('%s-%s', $destinationId, $currencyId);- $name = sprintf('%s (%s)', $journal['destination_account_name'], $journal['currency_name']);- $countAccounts[$destinationId] = isset($countAccounts[$destinationId]) ? $countAccounts[$destinationId] + 1 : 1;-- if (!isset($expenses[$key])) {- $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);- $expenses[$key] = [- 'id' => $destinationId,- 'name' => $name,- 'original' => $journal['destination_account_name'],- 'sum' => '0',- 'average' => '0',- 'currencies' => [],- 'single_currency' => $currencies[$currencyId],- 'count' => 0,+ $sourceId = (int)$journal['destination_account_id'];+ $currencyId = (int)$journal['currency_id'];+ $key = sprintf('%s-%s', $sourceId, $currencyId);+ if (!isset($report['accounts'][$key])) {+ $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);+ $report['accounts'][$key] = [+ 'id' => $sourceId,+ 'name' => $journal['destination_account_name'],+ 'sum' => '0',+ 'average' => '0',+ 'count' => 0,+ 'currency_id' => $currencies[$currencyId]->id,+ 'currency_name' => $currencies[$currencyId]->name,+ 'currency_symbol' => $currencies[$currencyId]->symbol,+ 'currency_code' => $currencies[$currencyId]->code,+ 'currency_decimal_places' => $currencies[$currencyId]->decimal_places,];}- $expenses[$key]['currencies'][] = (int)$journal['currency_id'];- $expenses[$key]['sum'] = bcadd($expenses[$key]['sum'], $journal['amount']);- ++$expenses[$key]['count'];+ $report['accounts'][$key]['sum'] = bcadd($report['accounts'][$key]['sum'], $journal['amount']);+ ++$report['accounts'][$key]['count'];}- // do averages:- $keys = array_keys($expenses);- foreach ($keys as $key) {- $opposingId = $expenses[$key]['id'];- if (1 === $countAccounts[$opposingId]) {- $expenses[$key]['name'] = $expenses[$key]['original'];+ // do averages and sums.+ foreach (array_keys($report['accounts']) as $key) {+ if ($report['accounts'][$key]['count'] > 1) {+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);}-- if ($expenses[$key]['count'] > 1) {- $expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], (string)$expenses[$key]['count']);- }- $expenses[$key]['currencies'] = count(array_unique($expenses[$key]['currencies']));- $expenses[$key]['all_currencies'] = count($currencies);+ $currencyId = $report['accounts'][$key]['currency_id'];+ $report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [+ 'sum' => '0',+ 'currency_id' => $report['accounts'][$key]['currency_id'],+ 'currency_name' => $report['accounts'][$key]['currency_name'],+ 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],+ 'currency_code' => $report['accounts'][$key]['currency_code'],+ 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],+ ];+ $report['sums'][$currencyId]['sum'] = bcadd($report['sums'][$currencyId]['sum'], $report['accounts'][$key]['sum']);}-- return $expenses;+ return $report;}/**@@ -262,50 +269,52 @@ class AccountTasker implements AccountTaskerInterface/** @var CurrencyRepositoryInterface $currencyRepos */$currencyRepos = app(CurrencyRepositoryInterface::class);$currencies = [$defaultCurrency->id => $defaultCurrency,];- $income = [];- $countAccounts = []; // if count remains 0 use original name, not the name with the currency.+ $report = [+ 'accounts' => [],+ 'sums' => [],+ ];/** @var array $journal */foreach ($array as $journal) {$sourceId = (int)$journal['source_account_id'];$currencyId = (int)$journal['currency_id'];$key = sprintf('%s-%s', $sourceId, $currencyId);- $name = sprintf('%s (%s)', $journal['source_account_name'], $journal['currency_name']);- $countAccounts[$sourceId] = isset($countAccounts[$sourceId]) ? $countAccounts[$sourceId] + 1 : 1;-- if (!isset($income[$key])) {- $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);- $income[$key] = [- 'id' => $sourceId,- 'name' => $name,- 'original' => $journal['source_account_name'],- 'sum' => '0',- 'average' => '0',- 'currencies' => [],- 'single_currency' => $currencies[$currencyId],- 'count' => 0,+ if (!isset($report['accounts'][$key])) {+ $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);+ $report['accounts'][$key] = [+ 'id' => $sourceId,+ 'name' => $journal['source_account_name'],+ 'sum' => '0',+ 'average' => '0',+ 'count' => 0,+ 'currency_id' => $currencies[$currencyId]->id,+ 'currency_name' => $currencies[$currencyId]->name,+ 'currency_symbol' => $currencies[$currencyId]->symbol,+ 'currency_code' => $currencies[$currencyId]->code,+ 'currency_decimal_places' => $currencies[$currencyId]->decimal_places,];}- $income[$key]['currencies'][] = (int)$journal['currency_id'];- $income[$key]['sum'] = bcadd($income[$key]['sum'], bcmul($journal['amount'], '-1'));- ++$income[$key]['count'];+ $report['accounts'][$key]['sum'] = bcadd($report['accounts'][$key]['sum'], bcmul($journal['amount'], '-1'));+ ++$report['accounts'][$key]['count'];}- // do averages:- $keys = array_keys($income);- foreach ($keys as $key) {- $opposingId = $income[$key]['id'];- if (1 === $countAccounts[$opposingId]) {- $income[$key]['name'] = $income[$key]['original'];+ // do averages and sums.+ foreach (array_keys($report['accounts']) as $key) {+ if ($report['accounts'][$key]['count'] > 1) {+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);}-- if ($income[$key]['count'] > 1) {- $income[$key]['average'] = bcdiv($income[$key]['sum'], (string)$income[$key]['count']);- }- $income[$key]['currencies'] = count(array_unique($income[$key]['currencies']));- $income[$key]['all_currencies'] = count($currencies);+ $currencyId = $report['accounts'][$key]['currency_id'];+ $report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [+ 'sum' => '0',+ 'currency_id' => $report['accounts'][$key]['currency_id'],+ 'currency_name' => $report['accounts'][$key]['currency_name'],+ 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],+ 'currency_code' => $report['accounts'][$key]['currency_code'],+ 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],+ ];+ $report['sums'][$currencyId]['sum'] = bcadd($report['sums'][$currencyId]['sum'], $report['accounts'][$key]['sum']);}- return $income;+ return $report;}}diff --git a/resources/views/v1/accounts/reconcile/transactions.twig b/resources/views/v1/accounts/reconcile/transactions.twigindex 999d3d16d2..4e98432b0a 100644--- a/resources/views/v1/accounts/reconcile/transactions.twig+++ b/resources/views/v1/accounts/reconcile/transactions.twig@@ -94,9 +94,9 @@<td style="text-align: right;"><span style="margin-right:5px;">- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}</span></td>diff --git a/resources/views/v1/list/groups.twig b/resources/views/v1/list/groups.twigindex 123d82c9ac..827b7ad4ed 100644--- a/resources/views/v1/list/groups.twig+++ b/resources/views/v1/list/groups.twig@@ -25,13 +25,13 @@ TODO: hide and show columns<td colspan="2" style="border-top:1px #aaa solid;">{% for sum in group.sums %}{% if group.transaction_type == 'Deposit' %}- {{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_symbol_decimal_places) }}{% if loop.index != group.sums|length %},{% endif %}+ {{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_decimal_places) }}{% if loop.index != group.sums|length %},{% endif %}{% elseif group.transaction_type == 'Transfer' %}<span class="text-info">- {{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_symbol_decimal_places, false) }}{% if loop.index != group.sums|length %},{% endif %}X+ {{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_decimal_places, false) }}{% if loop.index != group.sums|length %},{% endif %}X</span>{% else %}- {{ formatAmountBySymbol(sum.amount, sum.currency_symbol, sum.currency_symbol_decimal_places) }}{% if loop.index != group.sums|length %},{% endif %}+ {{ formatAmountBySymbol(sum.amount, sum.currency_symbol, sum.currency_decimal_places) }}{% if loop.index != group.sums|length %},{% endif %}{% endif %}{% endfor %}</td>@@ -90,21 +90,21 @@ TODO: hide and show columns</td><td style=" {{ style|raw }}">{% if transaction.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% elseif transaction.transaction_type_type == 'Transfer' %}<span class="text-info">- {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places, false) }}+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }}){% endif %}</span>{% else %}- {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% endif %}</td>diff --git a/resources/views/v1/popup/list/journals.twig b/resources/views/v1/popup/list/journals.twigindex 62f6fd2a29..42f2a0ea59 100644--- a/resources/views/v1/popup/list/journals.twig+++ b/resources/views/v1/popup/list/journals.twig@@ -63,23 +63,23 @@<td>{% if transaction.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% set sum = (sum + (transaction.amount*-1)) %}{% elseif transaction.transaction_type_type == 'Transfer' %}<span class="text-info">- {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places, false) }}+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }}){% endif %}</span>{% set sum = (sum + transaction.amount*-1) %}{% else %}- {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% set sum = (sum + transaction.amount) %}{% endif %}diff --git a/resources/views/v1/reports/budget/month.twig b/resources/views/v1/reports/budget/month.twigindex 210dec6ec6..2d06943585 100644--- a/resources/views/v1/reports/budget/month.twig+++ b/resources/views/v1/reports/budget/month.twig@@ -250,7 +250,7 @@<td data-value="{{ row.amount}}" style="text-align: right;">- {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}</td></tr>diff --git a/resources/views/v1/reports/category/month.twig b/resources/views/v1/reports/category/month.twigindex 89be71d3b5..e5376a2b77 100644--- a/resources/views/v1/reports/category/month.twig+++ b/resources/views/v1/reports/category/month.twig@@ -283,7 +283,7 @@</a></td><td data-value="{{ row.amount }}" style="text-align: right;">- {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}</td></tr>{% endfor %}@@ -404,7 +404,7 @@</a></td><td data-value="{{ row.amount }}" style="text-align: right;">- {{ formatAmountBySymbol(row.amount*-1, row.currency_symbol, row.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(row.amount*-1, row.currency_symbol, row.currency_decimal_places) }}</td></tr>{% endfor %}diff --git a/resources/views/v1/reports/partials/accounts.twig b/resources/views/v1/reports/partials/accounts.twigindex 34ef9d6798..53a9e5e0c5 100644--- a/resources/views/v1/reports/partials/accounts.twig+++ b/resources/views/v1/reports/partials/accounts.twig@@ -14,28 +14,35 @@<a href="{{ route('accounts.show',account.id) }}" title="{{ account.name }}">{{ account.name }}</a></td><td class="hidden-xs" data-value="{{ account.start_balance }}" style="text-align: right;">- {{ formatAmountByCurrency(account.currency, account.start_balance) }}+ {{ formatAmountBySymbol(account.start_balance, account.currency_symbol, account.currency_decimal_places) }}</td><td class="hidden-xs" data-value="{{ account.end_balance }}" style="text-align: right;">- {{ formatAmountByCurrency(account.currency, account.end_balance) }}</td>+ {{ formatAmountBySymbol(account.end_balance, account.currency_symbol, account.currency_decimal_places) }}+ </td><td style="text-align: right;"data-value="{{ (account.end_balance - account.start_balance) }}">- {{ formatAmountByCurrency(account.currency, (account.end_balance - account.start_balance)) }}+ {{ formatAmountBySymbol(account.end_balance - account.start_balance, account.currency_symbol, account.currency_decimal_places) }}</td></tr>{% endfor %}- </tbody>- <tfoot><tr>- <td><em>{{ 'sumOfSums'|_ }}</em></td>- <td class="hidden-xs" style="text-align: right;">{{ accountReport.start|formatAmount }}</td>- <td class="hidden-xs" style="text-align: right;">{{ accountReport.end|formatAmount }}</td>- <td style="text-align: right;">{{ accountReport.difference|formatAmount }}</td>+ <td colspan="4"><em>{{ 'sumOfSums'|_ }}</em></td></tr>- {% if accountReport.currencies > 1 %}+ {% for sum in accountReport.sums %}<tr>- <td colspan="4"><small class="text-warning">{{ 'multi_currency_report_sum'|_ }}</small></td>+ <td>+ + </td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.start, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.end, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.difference, sum.currency_symbol, sum.currency_decimal_places) }}+ </td></tr>- {% endif %}- </tfoot>+ {% endfor %}+ </tbody></table>diff --git a/resources/views/v1/reports/partials/income-expenses.twig b/resources/views/v1/reports/partials/income-expenses.twigindex 6d804feceb..6291a6c6e1 100644--- a/resources/views/v1/reports/partials/income-expenses.twig+++ b/resources/views/v1/reports/partials/income-expenses.twig@@ -8,58 +8,54 @@</tr></thead><tbody>- {% set sum = 0 %}- {% for entry in entries %}- {% set sum = sum + entry.sum %}+ {% for account in report.accounts %}{% if loop.index > listLength %}<tr class="overListLength">{% else %}<tr>{% endif %}- <td data-value="{{ entry.name }}">- <a href="{{ route('accounts.show',entry.id) }}">{{ entry.name }}</a>- {% if entry.count > 1 %}+ <td data-value="{{ account.name }}">+ <a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a>+ {% if account.count > 1 %}<br/><small>- {{ entry.count }} {{ 'transactions'|_|lower }}+ {{ account.count }} {{ 'transactions'|_|lower }}</small>{% endif %}</td>- <td data-value="{{ entry.sum }}" style="text-align: right;">- {% if entry.currencies == 1 %}- {{ formatAmountByCurrency(entry.single_currency, entry.sum) }}- {% else %}- {{ (entry.sum)|formatAmount }}- {% endif %}+ <td data-value="{{ account.sum }}" style="text-align: right;">+ {{ formatAmountBySymbol(account.sum, account.currency_symbol, account.currency_decimal_places) }}</td><td class="hidden-xs" data-value="{{ entry.average }}" style="text-align: right;">{% if entry.count > 1 %}- {{ entry.average|formatAmount }}+ {{ formatAmountBySymbol(account.average, account.currency_symbol, account.currency_decimal_places) }}{% else %}—{% endif %}</td><td><i class="fa fa-fw text-muted fa-info-circle firefly-info-button" data-location="{{ type }}"- data-account-id="{{ entry.id }}"></i>+ data-account-id="{{ account.id }}"></i></td></tr>{% endfor %}</tbody>+<tfoot>- {% if entries|length > listLength %}+ {% if report.accounts|length > listLength %}<tr><td colspan="4" class="active"><a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a></td></tr>{% endif %}- <tr>- <td><em>{{ 'sum'|_ }}</em></td>- <td style="text-align: right;">{{ (sum)|formatAmount }}</td>- </tr>- <tr>- <td colspan="4"><small class="text-warning">{{ 'sum_in_default_currency'|_ }}</small></td>- </tr>- </tfoot>+ {% for sum in report.sums %}+ <tr>+ <td><em>{{ 'sum'|_ }} ({{ sum.currency_name }})</em></td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td> </td>+ </tr>+ {% endfor %}</table>diff --git a/resources/views/v1/reports/partials/journals-audit.twig b/resources/views/v1/reports/partials/journals-audit.twigindex fda96e3377..0310f3ca64 100644--- a/resources/views/v1/reports/partials/journals-audit.twig+++ b/resources/views/v1/reports/partials/journals-audit.twig@@ -77,14 +77,14 @@</td><td class="hide-balance_before" style="text-align: right;">- {{ formatAmountBySymbol(journal.balance_before, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.balance_before, journal.currency_symbol, journal.currency_decimal_places) }}</td><td class="hide-amount" style="text-align: right;">- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}</td><td class="hide-balance_after" style="text-align: right;">- {{ formatAmountBySymbol(journal.balance_after, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.balance_after, journal.currency_symbol, journal.currency_decimal_places) }}</td><td class="hide-date">{{ journal.date.formatLocalized(monthAndDayFormat) }}</td>diff --git a/resources/views/v1/reports/partials/operations.twig b/resources/views/v1/reports/partials/operations.twigindex b77387d38d..e0e772e938 100644--- a/resources/views/v1/reports/partials/operations.twig+++ b/resources/views/v1/reports/partials/operations.twig@@ -1,19 +1,22 @@<table class="table table-hover"><tr>- <td>{{ 'money_flowing_in'|_ }}</td>- <td style="text-align: right;">{{ incomeSum|formatAmount }}</td>+ <th>{{'currency'|_}}</th>+ <th>{{ 'money_flowing_in'|_ }}</th>+ <th>{{ 'money_flowing_out'|_ }}</th>+ <th>{{ 'difference'|_ }}</th></tr>+ {% for sum in sums %}<tr>- <td>{{ 'money_flowing_out'|_ }}</td>- <td style="text-align: right;">{{ expensesSum|formatAmount }}</td>- </tr>- <tr>- <td>{{ 'difference'|_ }}</td>- <td style="text-align: right;">{{ (incomeSum + expensesSum)|formatAmount }}</td>- </tr>- <tr>- <td colspan="2">- <small class="text-warning">{{ 'sum_in_default_currency'|_ }}</small>+ <td>{{ sum.currency_name }} ({{ sum.currency_symbol }})</td>+ <td>+ {{ formatAmountBySymbol(sum.in, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td>+ {{ formatAmountBySymbol(sum.out, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td>+ {{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}</td></tr>+ {% endfor %}</table>diff --git a/resources/views/v1/reports/partials/top-transactions.twig b/resources/views/v1/reports/partials/top-transactions.twigindex c52c4fa895..a8f6f7e85e 100644--- a/resources/views/v1/reports/partials/top-transactions.twig+++ b/resources/views/v1/reports/partials/top-transactions.twig@@ -20,9 +20,9 @@<td style="text-align: right;" data-value="{{ transaction.amount}}"><spanstyle="margin-right:5px;">- {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}</span></td></tr>diff --git a/resources/views/v1/reports/tag/month.twig b/resources/views/v1/reports/tag/month.twigindex 5d8fb2f095..a24b5f050a 100644--- a/resources/views/v1/reports/tag/month.twig+++ b/resources/views/v1/reports/tag/month.twig@@ -300,7 +300,7 @@</a></td><td data-value="{{ row.amount }}" style="text-align: right;">- {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}</td></tr>{% endfor %}diff --git a/resources/views/v1/transactions/bulk/edit.twig b/resources/views/v1/transactions/bulk/edit.twigindex e5e9bfb2e6..bff7dbf877 100644--- a/resources/views/v1/transactions/bulk/edit.twig+++ b/resources/views/v1/transactions/bulk/edit.twig@@ -43,21 +43,21 @@{{ journal.description }}</a></td><td>{% if journal.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% elseif journal.transaction_type_type == 'Transfer' %}<span class="text-info">- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places, false) }}+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }}){% endif %}</span>{% else %}- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% endif %}diff --git a/resources/views/v1/transactions/convert.twig b/resources/views/v1/transactions/convert.twigindex 768ae2e33f..7892fca981 100644--- a/resources/views/v1/transactions/convert.twig+++ b/resources/views/v1/transactions/convert.twig@@ -254,19 +254,19 @@</td><td>{% if transaction.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% elseif transaction.transaction_type_type == 'Transfer' %}- <span class="text-info">{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places, false) }}+ <span class="text-info">{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }}){% endif %}</span>{% else %}- {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }}){% endif %}{% endif %}</td>diff --git a/resources/views/v1/transactions/mass/delete.twig b/resources/views/v1/transactions/mass/delete.twigindex f7c96b4463..ce460512c3 100644--- a/resources/views/v1/transactions/mass/delete.twig+++ b/resources/views/v1/transactions/mass/delete.twig@@ -65,20 +65,20 @@</td><td>{% if journal.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% elseif journal.transaction_type_type == 'Transfer' %}- <span class="text-info">{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places, false) }}+ <span class="text-info">{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }}){% endif %}</span>{% else %}- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% endif %}</td>diff --git a/resources/views/v1/transactions/mass/edit.twig b/resources/views/v1/transactions/mass/edit.twigindex e7f95317c0..e9039cbe8c 100644--- a/resources/views/v1/transactions/mass/edit.twig+++ b/resources/views/v1/transactions/mass/edit.twig@@ -69,21 +69,21 @@<span class="text-sm">{% if journal.reconciled != false %}{% if journal.transaction_type_type == 'Deposit' %}- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% elseif journal.transaction_type_type == 'Transfer' %}<span class="text-info">- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places, false) }}+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places, false) }})+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }}){% endif %}</span>{% else %}- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}{% if null != journal.foreign_amount %}- ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})+ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}){% endif %}{% endif %}{% endif %}