diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index d8cb8d1ddf..0d2dc4332b 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -119,15 +119,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation()
->withBudgetInformation()->withCategoryInformation()->withBillInformation();
$journals = $collector->getExtractedJournals();
- $journals = array_reverse($journals, true);
-
+ $journals = array_reverse($journals, true);
$dayBeforeBalance = app('steam')->balance($account, $date);
$startBalance = $dayBeforeBalance;
- $currency = $accountRepository->getAccountCurrency($account);
-
- if (null === $currency) {
- throw new FireflyException('Unexpected NULL value in account currency preference.'); // @codeCoverageIgnore
- }
+ $defaultCurrency = app('amount')->getDefaultCurrencyByUser($account->user);
+ $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
foreach ($journals as $index => $journal) {
$journals[$index]['balance_before'] = $startBalance;
@@ -140,6 +136,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
if ($currency->id === $journal['foreign_currency_id']) {
$transactionAmount = $journal['foreign_amount'];
+ if ($account->id === $journal['destination_account_id']) {
+ $transactionAmount = app('steam')->positive($journal['foreign_amount']);
+ }
}
$newBalance = bcadd($startBalance, $transactionAmount);
@@ -158,6 +157,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$return = [
'journals' => $journals,
+ 'currency' => $currency,
'exists' => count($journals) > 0,
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'endBalance' => app('steam')->balance($account, $this->end),
diff --git a/resources/views/v1/reports/partials/journals-audit.twig b/resources/views/v1/reports/partials/journals-audit.twig
index 88389d5e03..3272acc386 100644
--- a/resources/views/v1/reports/partials/journals-audit.twig
+++ b/resources/views/v1/reports/partials/journals-audit.twig
@@ -77,21 +77,38 @@
- {{ formatAmountBySymbol(journal.balance_before, journal.currency_symbol, journal.currency_decimal_places) }}
+ {{ formatAmountBySymbol(journal.balance_before, auditData[account.id].currency.symbol, auditData[account.id].currency.decimal_places) }}
|
- {% if account.id == journal.destination_account_id and journal.transaction_type_type == 'Opening balance' %}
- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
- {% elseif account.id == journal.destination_account_id and journal.transaction_type_type == 'Deposit' %}
- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
- {% else %}
- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
+
+ {% if auditData[account.id].currency.id == journal.currency_id %}
+ {% if account.id == journal.destination_account_id and journal.transaction_type_type == 'Opening balance' %}
+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
+ {% elseif account.id == journal.destination_account_id and journal.transaction_type_type == 'Deposit' %}
+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
+ {% elseif account.id == journal.destination_account_id and journal.transaction_type_type == 'Transfer' %}
+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
+ {% else %}
+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
+ {% endif %}
+ {% endif %}
+
+ {% if auditData[account.id].currency.id == journal.foreign_currency_id %}
+ {% if account.id == journal.destination_account_id and journal.transaction_type_type == 'Opening balance' %}
+ {{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}
+ {% elseif account.id == journal.destination_account_id and journal.transaction_type_type == 'Deposit' %}
+ {{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}
+ {% elseif account.id == journal.destination_account_id and journal.transaction_type_type == 'Transfer' %}
+ {{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}
+ {% else %}
+ {{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}
+ {% endif %}
{% endif %}
|
- {{ formatAmountBySymbol(journal.balance_after, journal.currency_symbol, journal.currency_decimal_places) }}
+ {{ formatAmountBySymbol(journal.balance_after, auditData[account.id].currency.symbol, auditData[account.id].currency.decimal_places) }}
|
{{ journal.date.formatLocalized(monthAndDayFormat) }} |