/** * Get a full report on the users expenses during the period. * * @param Carbon $start * @param Carbon $end * @param boolean $shared * * @return Expense */ public function getExpenseReport($start, $end, $shared) { $object = new Expense(); $set = $this->query->expenseInPeriodCorrected($start, $end, $shared); foreach ($set as $entry) { $object->addToTotal($entry->amount); $object->addOrCreateExpense($entry); } return $object; }
/** * Get a full report on the users expenses during the period for a list of accounts. * * @param Carbon $start * @param Carbon $end * @param Collection $accounts * * @return Expense */ public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts) : Expense { $object = new Expense(); /** @var AccountRepositoryInterface $repos */ $repos = app(AccountRepositoryInterface::class); $journals = $repos->expensesInPeriod($accounts, $start, $end); /** @var TransactionJournal $entry */ foreach ($journals as $entry) { $amount = TransactionJournal::amount($entry); $object->addToTotal($amount); $object->addOrCreateExpense($entry); } return $object; }
/** * Get a full report on the users expenses during the period for a list of accounts. * * @param Carbon $start * @param Carbon $end * @param Collection $accounts * * @return Expense */ public function getExpenseReport($start, $end, Collection $accounts) { $object = new Expense(); $set = $this->query->expense($accounts, $start, $end); foreach ($set as $entry) { $object->addToTotal($entry->journalAmount); // can be positive, if it's a transfer $object->addOrCreateExpense($entry); } return $object; }