mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code optimizations.
This commit is contained in:
@@ -136,21 +136,8 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function getBillsForAccounts(Collection $accounts): Collection
|
||||
{
|
||||
$fields = ['bills.id',
|
||||
'bills.created_at',
|
||||
'bills.updated_at',
|
||||
'bills.deleted_at',
|
||||
'bills.user_id',
|
||||
'bills.name',
|
||||
'bills.match',
|
||||
'bills.amount_min',
|
||||
'bills.amount_max',
|
||||
'bills.date',
|
||||
'bills.repeat_freq',
|
||||
'bills.skip',
|
||||
'bills.automatch',
|
||||
'bills.active',
|
||||
'bills.name_encrypted',
|
||||
$fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.match', 'bills.amount_min',
|
||||
'bills.amount_max', 'bills.date', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active', 'bills.name_encrypted',
|
||||
'bills.match_encrypted',];
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$set = $this->user->bills()
|
||||
@@ -336,28 +323,22 @@ class BillRepository implements BillRepositoryInterface
|
||||
public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$set = new Collection;
|
||||
Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
|
||||
// Start at 2016-10-01, see when we expect the bill to hit:
|
||||
$currentStart = clone $start;
|
||||
Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
|
||||
|
||||
while ($currentStart <= $end) {
|
||||
Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));
|
||||
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
|
||||
Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
// If nextExpectedMatch is after end, we continue:
|
||||
if ($nextExpectedMatch > $end) {
|
||||
if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue
|
||||
Log::debug(
|
||||
sprintf('nextExpectedMatch %s is after %s, so we skip this bill now.', $nextExpectedMatch->format('Y-m-d'), $end->format('Y-m-d'))
|
||||
);
|
||||
break;
|
||||
}
|
||||
// add to set
|
||||
$set->push(clone $nextExpectedMatch);
|
||||
Log::debug(sprintf('Now %d dates in set.', $set->count()));
|
||||
|
||||
// add day if necessary.
|
||||
$nextExpectedMatch->addDay();
|
||||
|
||||
Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
|
Reference in New Issue
Block a user