mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #2513
This commit is contained in:
parent
30fc56a0d7
commit
8246d901e7
@ -94,6 +94,79 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the audit report.
|
||||||
|
*
|
||||||
|
* @param Account $account
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function getAuditReport(Account $account, Carbon $date): array
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
$accountRepository->setUser($account->user);
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $journalRepository */
|
||||||
|
$journalRepository = app(JournalRepositoryInterface::class);
|
||||||
|
$journalRepository->setUser($account->user);
|
||||||
|
|
||||||
|
/** @var GroupCollectorInterface $collector */
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation();
|
||||||
|
$journals = $collector->getExtractedJournals();
|
||||||
|
$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
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($journals as $index => $journal) {
|
||||||
|
$journals[$index]['balance_before'] = $startBalance;
|
||||||
|
$transactionAmount = $journal['amount'];
|
||||||
|
|
||||||
|
// make sure amount is in the right "direction".
|
||||||
|
if ($account->id === $journal['destination_account_id']) {
|
||||||
|
$transactionAmount = app('steam')->positive($journal['amount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($currency->id === $journal['foreign_currency_id']) {
|
||||||
|
$transactionAmount = $journal['foreign_amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$newBalance = bcadd($startBalance, $transactionAmount);
|
||||||
|
$journals[$index]['balance_after'] = $newBalance;
|
||||||
|
$startBalance = $newBalance;
|
||||||
|
|
||||||
|
// add meta dates for each journal.
|
||||||
|
$journals[$index]['interest_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'interest_date');
|
||||||
|
$journals[$index]['book_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'book_date');
|
||||||
|
$journals[$index]['process_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'process_date');
|
||||||
|
$journals[$index]['due_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'due_date');
|
||||||
|
$journals[$index]['payment_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'payment_date');
|
||||||
|
$journals[$index]['invoice_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'invoice_date');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = [
|
||||||
|
'journals' => $journals,
|
||||||
|
'exists' => count($journals) > 0,
|
||||||
|
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
|
||||||
|
'endBalance' => app('steam')->balance($account, $this->end),
|
||||||
|
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
|
||||||
|
'dayBeforeBalance' => $dayBeforeBalance,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account collection setter.
|
* Account collection setter.
|
||||||
*
|
*
|
||||||
@ -191,71 +264,4 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the audit report.
|
|
||||||
*
|
|
||||||
* @param Account $account
|
|
||||||
* @param Carbon $date
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getAuditReport(Account $account, Carbon $date): array
|
|
||||||
{
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
|
||||||
$accountRepository->setUser($account->user);
|
|
||||||
|
|
||||||
/** @var JournalRepositoryInterface $journalRepository */
|
|
||||||
$journalRepository = app(JournalRepositoryInterface::class);
|
|
||||||
$journalRepository->setUser($account->user);
|
|
||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
|
||||||
$collector = app(GroupCollectorInterface::class);
|
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)
|
|
||||||
->withAccountInformation();
|
|
||||||
$journals = $collector->getExtractedJournals();
|
|
||||||
$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
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($journals as $index => $journal) {
|
|
||||||
$journals[$index]['balance_before'] = $startBalance;
|
|
||||||
$transactionAmount = $journal['amount'];
|
|
||||||
|
|
||||||
if ($currency->id === $journal['foreign_currency_id']) {
|
|
||||||
$transactionAmount = $journal['foreign_amount'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$newBalance = bcadd($startBalance, $transactionAmount);
|
|
||||||
$journals[$index]['balance_after'] = $newBalance;
|
|
||||||
$startBalance = $newBalance;
|
|
||||||
|
|
||||||
// add meta dates for each journal.
|
|
||||||
$journals[$index]['interest_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'interest_date');
|
|
||||||
$journals[$index]['book_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'book_date');
|
|
||||||
$journals[$index]['process_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'process_date');
|
|
||||||
$journals[$index]['due_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'due_date');
|
|
||||||
$journals[$index]['payment_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'payment_date');
|
|
||||||
$journals[$index]['invoice_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'invoice_date');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$return = [
|
|
||||||
'journals' => $journals,
|
|
||||||
'exists' => count($journals) > 0,
|
|
||||||
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
|
|
||||||
'endBalance' => app('steam')->balance($account, $this->end),
|
|
||||||
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
|
|
||||||
'dayBeforeBalance' => $dayBeforeBalance,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="box-body table-responsive no-padding">
|
<div class="box-body table-responsive no-padding">
|
||||||
|
<p style="padding:10px;">
|
||||||
|
{{ trans('firefly.audit_end_balance',
|
||||||
|
{
|
||||||
|
account_name: account.name|escape,
|
||||||
|
url: url,
|
||||||
|
end: auditData[account.id].dayBefore,
|
||||||
|
balance: formatAmountByAccount(account, auditData[account.id].dayBeforeBalance)
|
||||||
|
})|raw }}
|
||||||
|
</p>
|
||||||
|
{% include 'reports.partials.journals-audit' with {'journals': auditData[account.id].journals,'account':account} %}
|
||||||
|
|
||||||
<p style="padding:10px;">
|
<p style="padding:10px;">
|
||||||
|
|
||||||
{{ trans('firefly.audit_end_balance',
|
{{ trans('firefly.audit_end_balance',
|
||||||
@ -61,17 +72,6 @@
|
|||||||
end: auditData[account.id].end,
|
end: auditData[account.id].end,
|
||||||
balance: formatAmountByAccount(account,auditData[account.id].endBalance)
|
balance: formatAmountByAccount(account,auditData[account.id].endBalance)
|
||||||
})|raw }}
|
})|raw }}
|
||||||
<!-- TODO VERIFY THAT STEAM BALANCE ACTUALLY WORKS -->
|
|
||||||
</p>
|
|
||||||
{% include 'reports.partials.journals-audit' with {'journals': auditData[account.id].journals,'account':account} %}
|
|
||||||
<p style="padding:10px;">
|
|
||||||
{{ trans('firefly.audit_end_balance',
|
|
||||||
{
|
|
||||||
account_name: account.name|escape,
|
|
||||||
url: url,
|
|
||||||
end: auditData[account.id].dayBefore,
|
|
||||||
balance: formatAmountByAccount(account, auditData[account.id].dayBeforeBalance)
|
|
||||||
})|raw }}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -57,11 +57,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if journal.transaction_type_type == 'Reconciliation' %}
|
{% if journal.transaction_type_type == 'Reconciliation' %}
|
||||||
XX
|
<i class="fa-fw fa fa-calculator" title="{{ trans('firefly.reconciliation_transaction') }}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if journal.transaction_type_type == 'Opening balance' %}
|
{% if journal.transaction_type_type == 'Opening balance' %}
|
||||||
XX
|
<i class="fa-fw fa fa-star-o" title="{{ trans('firefly.Opening balance') }}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@ -80,7 +80,12 @@
|
|||||||
{{ formatAmountBySymbol(journal.balance_before, journal.currency_symbol, journal.currency_decimal_places) }}
|
{{ formatAmountBySymbol(journal.balance_before, journal.currency_symbol, journal.currency_decimal_places) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="hide-amount" style="text-align: right;">
|
<td class="hide-amount" style="text-align: right;">
|
||||||
|
{% 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) }}
|
||||||
|
{% else %}
|
||||||
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
|
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="hide-balance_after" style="text-align: right;">
|
<td class="hide-balance_after" style="text-align: right;">
|
||||||
|
Loading…
Reference in New Issue
Block a user