Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Better formatting for split transactions.
James Cole5a6967cefd02
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 6ff1bb3eb8..24e318e979 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -163,12 +163,11 @@ class ReportController extends Controller$exists = false;$journals = new Collection;$dayBeforeBalance = Steam::balance($account, $dayBefore);-/** Is there even activity on this account between the requested dates?*/if ($start->between($first, $last) || $end->between($first, $last)) {- $exists = true;+ $exists = true;$journals = $repos->journalsInPeriod($accounts, [], $start, $end);}@@ -203,7 +202,6 @@ class ReportController extends Controller$auditData[$id]['dayBeforeBalance'] = $dayBeforeBalance;}-$reportType = 'audit';$accountIds = join(',', $accounts->pluck('id')->toArray());diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex ec420ba87f..169b3fcae1 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -368,13 +368,10 @@ class AccountRepository implements AccountRepositoryInterface->sortCorrectly()->first(['transaction_journals.*']);if (is_null($journal)) {- $date = new Carbon;- $date->addYear(); // in the future.- } else {- $date = $journal->date;+ return new Carbon('1900-01-01');}- return $date;+ return $journal->date;}/**@@ -390,16 +387,15 @@ class AccountRepository implements AccountRepositoryInterface$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.account_id', $account->id)- ->orderBy('transaction_journals.date', 'DESC')+ ->orderBy('transaction_journals.date', 'ASC')+ ->orderBy('transaction_journals.order', 'DESC')+ ->orderBy('transaction_journals.id', 'ÅSC')->first(['transaction_journals.*']);if (is_null($journal)) {- $date = new Carbon;- $date->addYear(); // in the future.- } else {- $date = $journal->date;+ return new Carbon('1900-01-01');}- return $date;+ return $journal->date;}/**diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex ff505f0e12..262c5be668 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -4,6 +4,7 @@ declare(strict_types = 1);namespace FireflyIII\Support\Twig;+use Amount;use FireflyIII\Models\Account;use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;@@ -18,6 +19,28 @@ use Twig_SimpleFunction;*/class Journal extends Twig_Extension{+ /**+ * @return Twig_SimpleFunction+ */+ public function formatPerspective(): Twig_SimpleFunction+ {+ return new Twig_SimpleFunction(+ 'formatPerspective', function (TransactionJournal $journal, Account $account) {++ // get the account amount:+ $transaction = $journal->transactions()->where('transactions.account_id', $account->id)->first();+ $amount = $transaction->amount;+ if ($journal->isWithdrawal()) {+ $amount = bcmul($amount, '-1');+ }++ $formatted = Amount::format($amount, true);++ return $formatted . ' (' . Amount::formatJournal($journal) . ')';+ }+ );+ }+/*** @return Twig_SimpleFunction*/@@ -71,6 +94,7 @@ class Journal extends Twig_Extension$functions = [$this->getSourceAccount(),$this->getDestinationAccount(),+ $this->formatPerspective(),];return $functions;diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twigindex b623f6adaa..f6456825d1 100644--- a/resources/views/accounts/show.twig+++ b/resources/views/accounts/show.twig@@ -38,7 +38,7 @@<h3 class="box-title">{{ 'transactions'|_ }}</h3></div><div class="box-body">- {% include 'list.journals' with {sorting:true} %}+ {% include 'list.journals' with {sorting:true, accountPerspective: account} %}</div></div></div>diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twigindex 447a189fa5..a57becf748 100644--- a/resources/views/list/journals.twig+++ b/resources/views/list/journals.twig@@ -57,7 +57,11 @@</td><td>- {{ journal|formatJournal }}+ {% if not accountPerspective %}+ {{ journal|formatJournal }}+ {% else %}+ {{ formatPerspective(journal, accountPerspective)|raw }}+ {% endif %}</td><td class="hidden-sm hidden-xs">{{ journal.date.formatLocalized(monthAndDayFormat) }}diff --git a/resources/views/reports/index.twig b/resources/views/reports/index.twigindex bab746d9ff..62ef34f336 100644--- a/resources/views/reports/index.twig+++ b/resources/views/reports/index.twig@@ -135,6 +135,45 @@]) }}">{{ 'report_all_time_quick'|_ }}</a></li></ul>++ <h4>{{ 'quick_link_audit_report'|_ }}</h4>+ <ul>+ <li>+ <a href="{{ route('reports.report',+ ['audit',+ 'currentMonthStart',+ 'currentMonthEnd',+ accountList+ ]) }}">{{ 'report_this_month_quick'|_ }}</a>+ </li>+ <li>+ <a href="{{ route('reports.report',+ ['audit',+ 'currentYearStart',+ 'currentYearEnd',+ accountList+ ]) }}">{{ 'report_this_year_quick'|_ }}</a>+ </li>+ {% if customFiscalYear == 1 %}+ <li>+ <a href="{{ route('reports.report',+ ['audit',+ 'currentFiscalYearStart',+ 'currentFiscalYearEnd',+ accountList+ ]) }}">{{ 'report_this_fiscal_year_quick'|_ }}</a>+ </li>+ {% endif %}+ <li>+ <a href="{{ route('reports.report',+ ['audit',+ start.format('Ymd'),+ 'currentMonthEnd',+ accountList+ ]) }}">{{ 'report_all_time_quick'|_ }}</a>+ </li>+ </ul>+<p><em>{{ 'reports_can_bookmark'|_ }}</em></p>