Change in parameter and code cleanup.

This commit is contained in:
James Cole
2023-10-14 07:13:35 +02:00
parent c1107fe854
commit 58848caf30
19 changed files with 47 additions and 46 deletions

View File

@@ -665,13 +665,17 @@ class BillRepository implements BillRepositoryInterface
*/
public function sumUnpaidInRange(Carbon $start, Carbon $end): array
{
app('log')->debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
$bills = $this->getActiveBills();
$return = [];
/** @var Bill $bill */
foreach ($bills as $bill) {
app('log')->debug(sprintf('Processing bill #%d ("%s")', $bill->id, $bill->name));
$dates = $this->getPayDatesInRange($bill, $start, $end);
$count = $bill->transactionJournals()->after($start)->before($end)->count();
$total = $dates->count() - $count;
app('log')->debug(sprintf('Pay dates: %d, count: %d, left: %d', $dates->count(), $count, $total));
app('log')->debug('dates', $dates->toArray());
if ($total > 0) {
$currency = $bill->transactionCurrency;