Auto commit for release 'develop' on 2024-11-03

This commit is contained in:
github-actions
2024-11-03 09:01:53 +01:00
parent 2c1b9534f3
commit ab31a72199
11 changed files with 315 additions and 299 deletions

View File

@@ -66,9 +66,9 @@ class RecurringRepository implements RecurringRepositoryInterface
// if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.
$set
= TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void {
$q1->where('name', 'recurrence_id');
$q1->where('data', json_encode((string) $recurrence->id));
})->get(['journal_meta.transaction_journal_id']);
$q1->where('name', 'recurrence_id');
$q1->where('data', json_encode((string) $recurrence->id));
})->get(['journal_meta.transaction_journal_id']);
// there are X journals made for this recurrence. Any of them meant for today?
foreach ($set as $journalMeta) {
@@ -78,8 +78,9 @@ class RecurringRepository implements RecurringRepositoryInterface
$q2->where('name', 'recurrence_date');
$q2->where('data', json_encode($string));
})
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
->count();
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
->count()
;
if ($count > 0) {
app('log')->debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
@@ -96,11 +97,12 @@ class RecurringRepository implements RecurringRepositoryInterface
public function get(): Collection
{
return $this->user->recurrences()
->with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
->orderBy('active', 'DESC')
->orderBy('transaction_type_id', 'ASC')
->orderBy('title', 'ASC')
->get();
->with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
->orderBy('active', 'DESC')
->orderBy('transaction_type_id', 'ASC')
->orderBy('title', 'ASC')
->get()
;
}
/**
@@ -126,9 +128,10 @@ class RecurringRepository implements RecurringRepositoryInterface
{
// grab ALL recurring transactions:
return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
->orderBy('active', 'DESC')
->orderBy('title', 'ASC')
->get();
->orderBy('active', 'DESC')
->orderBy('title', 'ASC')
->get()
;
}
public function getBillId(RecurrenceTransaction $recTransaction): ?int
@@ -203,10 +206,11 @@ class RecurringRepository implements RecurringRepositoryInterface
{
Log::debug(sprintf('Now in getJournalCount(#%d, "%s", "%s")', $recurrence->id, $start?->format('Y-m-d H:i:s'), $end?->format('Y-m-d H:i:s')));
$query = TransactionJournal::leftJoin('journal_meta', 'journal_meta.transaction_journal_id', '=', 'transaction_journals.id')
->where('transaction_journals.user_id', $recurrence->user_id)
->whereNull('transaction_journals.deleted_at')
->where('journal_meta.name', 'recurrence_id')
->where('journal_meta.data', '"' . $recurrence->id . '"');
->where('transaction_journals.user_id', $recurrence->user_id)
->whereNull('transaction_journals.deleted_at')
->where('journal_meta.name', 'recurrence_id')
->where('journal_meta.data', '"'.$recurrence->id.'"')
;
if (null !== $start) {
$query->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'));
}
@@ -215,6 +219,7 @@ class RecurringRepository implements RecurringRepositoryInterface
}
$count = $query->count('transaction_journals.id');
Log::debug(sprintf('Count is %d', $count));
return $count;
}
@@ -224,10 +229,11 @@ class RecurringRepository implements RecurringRepositoryInterface
public function getJournalIds(Recurrence $recurrence): array
{
return TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->where('transaction_journals.user_id', $this->user->id)
->where('journal_meta.name', '=', 'recurrence_id')
->where('journal_meta.data', '=', json_encode((string) $recurrence->id))
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
->where('transaction_journals.user_id', $this->user->id)
->where('journal_meta.name', '=', 'recurrence_id')
->where('journal_meta.data', '=', json_encode((string) $recurrence->id))
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray()
;
}
/**
@@ -275,28 +281,30 @@ class RecurringRepository implements RecurringRepositoryInterface
public function getTransactionPaginator(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator
{
$journalMeta = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray();
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
foreach ($journalMeta as $journalId) {
$search[] = (int) $journalId;
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector->setUser($recurrence->user);
$collector->withCategoryInformation()->withBudgetInformation()->setLimit($pageSize)->setPage($page)
->withAccountInformation();
->withAccountInformation()
;
$collector->setJournalIds($search);
return $collector->getPaginatedGroups();
}
public function setUser(null | Authenticatable | User $user): void
public function setUser(null|Authenticatable|User $user): void
{
if ($user instanceof User) {
$this->user = $user;
@@ -306,11 +314,12 @@ class RecurringRepository implements RecurringRepositoryInterface
public function getTransactions(Recurrence $recurrence): Collection
{
$journalMeta = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray();
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
foreach ($journalMeta as $journalId) {
@@ -321,7 +330,7 @@ class RecurringRepository implements RecurringRepositoryInterface
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector->setUser($recurrence->user);
$collector->withCategoryInformation()->withBudgetInformation()->withAccountInformation();
@@ -464,21 +473,21 @@ class RecurringRepository implements RecurringRepositoryInterface
);
}
if ('ndom' === $repetition->repetition_type) {
$parts = explode(',', $repetition->repetition_moment);
$parts = explode(',', $repetition->repetition_moment);
// first part is number of week, second is weekday.
$dayOfWeek = trans(sprintf('config.dow_%s', $parts[1]), [], $language);
return (string) trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $parts[0]], $language);
}
if ('yearly' === $repetition->repetition_type) {
$today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
$today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
if (null === $repDate) {
$repDate = clone $today;
}
$diffInYears = (int) $today->diffInYears($repDate, true);
$repDate->addYears($diffInYears); // technically not necessary.
$string = $repDate->isoFormat((string) trans('config.month_and_day_no_year_js'));
$string = $repDate->isoFormat((string) trans('config.month_and_day_no_year_js'));
return (string) trans('firefly.recurring_yearly', ['date' => $string], $language);
}
@@ -493,7 +502,8 @@ class RecurringRepository implements RecurringRepositoryInterface
$search->whereLike('recurrences.title', sprintf('%%%s%%', $query));
}
$search
->orderBy('recurrences.title', 'ASC');
->orderBy('recurrences.title', 'ASC')
;
return $search->take($limit)->get(['id', 'title', 'description']);
}
@@ -539,7 +549,7 @@ class RecurringRepository implements RecurringRepositoryInterface
$occurrences = [];
$mutator = clone $start;
$mutator->startOfDay();
$skipMod = $repetition->repetition_skip + 1;
$skipMod = $repetition->repetition_skip + 1;
app('log')->debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type));
app('log')->debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d')));