Various code cleanup and fixed alignments.

This commit is contained in:
James Cole
2024-01-01 14:43:56 +01:00
parent 1368aafe5f
commit f963ac63f1
443 changed files with 3668 additions and 3672 deletions

View File

@@ -69,12 +69,12 @@ class CreateRecurringTransactions implements ShouldQueue
*/
public function __construct(?Carbon $date)
{
$newDate = new Carbon();
$newDate = new Carbon();
$newDate->startOfDay();
$this->date = $newDate;
$this->date = $newDate;
if (null !== $date) {
$newDate = clone $date;
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
@@ -118,7 +118,7 @@ class CreateRecurringTransactions implements ShouldQueue
app('log')->debug(sprintf('Count of collection is %d', $count));
// filter recurrences:
$filtered = $this->filterRecurrences($this->recurrences);
$filtered = $this->filterRecurrences($this->recurrences);
app('log')->debug(sprintf('Left after filtering is %d', $filtered->count()));
/** @var Recurrence $recurrence */
@@ -134,7 +134,7 @@ class CreateRecurringTransactions implements ShouldQueue
app('preferences')->setForUser($recurrence->user, 'lastActivity', microtime());
app('log')->debug(sprintf('Now at recurrence #%d of user #%d', $recurrence->id, $recurrence->user_id));
$createdReps = $this->handleRepetitions($recurrence);
$createdReps = $this->handleRepetitions($recurrence);
app('log')->debug(sprintf('Done with recurrence #%d', $recurrence->id));
$result[$recurrence->user_id] = $result[$recurrence->user_id]->merge($createdReps);
++$this->executed;
@@ -154,7 +154,7 @@ class CreateRecurringTransactions implements ShouldQueue
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
@@ -313,12 +313,12 @@ class CreateRecurringTransactions implements ShouldQueue
// add two days to $this->date, so we always include the weekend.
$includeWeekend = clone $this->date;
$includeWeekend->addDays(2);
$occurrences = $this->repository->getOccurrencesInRange($repetition, $recurrence->first_date, $includeWeekend);
$occurrences = $this->repository->getOccurrencesInRange($repetition, $recurrence->first_date, $includeWeekend);
unset($includeWeekend);
$result = $this->handleOccurrences($recurrence, $repetition, $occurrences);
$collection = $collection->merge($result);
$result = $this->handleOccurrences($recurrence, $repetition, $occurrences);
$collection = $collection->merge($result);
}
return $collection;
@@ -358,7 +358,7 @@ class CreateRecurringTransactions implements ShouldQueue
app('log')->debug(sprintf('%s IS today (%s)', $date->format('Y-m-d'), $this->date->format('Y-m-d')));
// count created journals on THIS day.
$journalCount = $this->repository->getJournalCount($recurrence, $date, $date);
$journalCount = $this->repository->getJournalCount($recurrence, $date, $date);
if ($journalCount > 0 && false === $this->force) {
app('log')->info(sprintf('Already created %d journal(s) for date %s', $journalCount, $date->format('Y-m-d')));
@@ -376,8 +376,8 @@ class CreateRecurringTransactions implements ShouldQueue
}
// create transaction array and send to factory.
$groupTitle = null;
$count = $recurrence->recurrenceTransactions->count();
$groupTitle = null;
$count = $recurrence->recurrenceTransactions->count();
if ($count > 1) {
/** @var RecurrenceTransaction $first */
$first = $recurrence->recurrenceTransactions()->first();
@@ -389,14 +389,14 @@ class CreateRecurringTransactions implements ShouldQueue
return null;
}
$array = [
$array = [
'user' => $recurrence->user_id,
'group_title' => $groupTitle,
'transactions' => $this->getTransactionData($recurrence, $repetition, $date),
];
/** @var TransactionGroup $group */
$group = $this->groupRepository->store($array);
$group = $this->groupRepository->store($array);
++$this->created;
app('log')->info(sprintf('Created new transaction group #%d', $group->id));
@@ -422,8 +422,8 @@ class CreateRecurringTransactions implements ShouldQueue
$transactions = $recurrence->recurrenceTransactions()->get();
/** @var RecurrenceTransaction $first */
$first = $transactions->first();
$return = [];
$first = $transactions->first();
$return = [];
/** @var RecurrenceTransaction $transaction */
foreach ($transactions as $index => $transaction) {