Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some undocumented changes for #2445 and #2447
James Coleecc37b2ed314
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex b089ceca6d..17bafb5796 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -413,13 +413,13 @@ class BillRepository implements BillRepositoryInterface*/public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection{- $dates = $bill->transactionJournals()->before($end)->after($start)->get(+ return $bill->transactionJournals()+ ->before($end)->after($start)->get(['transaction_journals.id', 'transaction_journals.date',+ 'transaction_journals.transaction_group_id',]- )->pluck('date', 'id');-- return $dates;+ );}/**diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 6f469b8824..c551d10fa0 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -25,6 +25,7 @@ namespace FireflyIII\Transformers;use Carbon\Carbon;use FireflyIII\Models\Bill;+use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Bill\BillRepositoryInterface;use Illuminate\Support\Collection;use Log;@@ -109,11 +110,11 @@ class BillTransformer extends AbstractTransformerif (0 === $dates->count()) {return $default; // @codeCoverageIgnore}- $latest = $dates->first();- /** @var Carbon $date */- foreach ($dates as $date) {- if ($date->gte($latest)) {- $latest = $date;+ $latest = $dates->first()->date;+ /** @var TransactionJournal $date */+ foreach ($dates as $journal) {+ if ($journal->date->gte($latest)) {+ $latest = $journal->date;}}@@ -160,11 +161,6 @@ class BillTransformer extends AbstractTransformer$set = $this->repository->getPaidDatesInRange($bill, $this->parameters->get('start'), $this->parameters->get('end'));Log::debug(sprintf('Count %d entries in getPaidDatesInRange()', $set->count()));- $simple = $set->map(- function (Carbon $date) {- return $date->format('Y-m-d');- }- );// calculate next expected match:$lastPaidDate = $this->lastPaidDate($set, $this->parameters->get('start'));@@ -173,13 +169,20 @@ class BillTransformer extends AbstractTransformer$nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip);}$end = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip);- $journalCount = $this->repository->getPaidDatesInRange($bill, $nextMatch, $end)->count();- if ($journalCount > 0) {+ if ($set->count() > 0) {$nextMatch = clone $end;}+ $result = [];+ foreach ($set as $entry) {+ $result[] = [+ 'transaction_group_id' => (int)$entry->transaction_group_id,+ 'transaction_journal_id' => (int)$entry->id,+ 'date' => $entry->date->format('Y-m-d'),+ ];+ }return [- 'paid_dates' => $simple->toArray(),+ 'paid_dates' => $result,'next_expected_match' => $nextMatch->format('Y-m-d'),];}diff --git a/resources/views/v1/list/bills.twig b/resources/views/v1/list/bills.twigindex 8937b937fa..2fb46b2748 100644--- a/resources/views/v1/list/bills.twig+++ b/resources/views/v1/list/bills.twig@@ -96,10 +96,10 @@Don't care about pay_dates.#}{% if entry.paid_dates|length > 0 and entry.active %}- <td class="paid_in_period text-success" data-value="{{ entry.paid_dates[0] }}">- {% for transaction_id, date in entry.paid_dates %}- <a href="{{ route('transactions.show',transaction_id) }}">- {{ formatDate(date, monthAndDayFormat) }}+ <td class="paid_in_period text-success" data-value="{{ entry.paid_dates[0].date }}">+ {% for currentPaid in entry.paid_dates %}+ <a href="{{ route('transactions.show',currentPaid.transaction_group_id) }}">+ {{ formatDate(currentPaid.date, monthAndDayFormat) }}</a><br/>{% endfor %}