mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -61,6 +61,36 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createdPreviously(Recurrence $recurrence, Carbon $date): bool
|
||||
{
|
||||
// if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.
|
||||
$set =
|
||||
TransactionJournalMeta::where(function (Builder $q1) use ($recurrence) {
|
||||
$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) {
|
||||
$count = TransactionJournalMeta::where(function (Builder $q2) use ($date) {
|
||||
$string = (string)$date;
|
||||
Log::debug(sprintf('Search for date: %s', json_encode($string)));
|
||||
$q2->where('name', 'recurrence_date');
|
||||
$q2->where('data', json_encode($string));
|
||||
})
|
||||
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a recurring transaction.
|
||||
*
|
||||
@@ -81,6 +111,20 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
$this->user->recurrences()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ALL recurring transactions.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAll(): Collection
|
||||
{
|
||||
// grab ALL recurring transactions:
|
||||
return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
|
||||
->orderBy('active', 'DESC')
|
||||
->orderBy('title', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all of the user's recurring transactions.
|
||||
*
|
||||
@@ -96,20 +140,6 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ALL recurring transactions.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAll(): Collection
|
||||
{
|
||||
// grab ALL recurring transactions:
|
||||
return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
|
||||
->orderBy('active', 'DESC')
|
||||
->orderBy('title', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -314,6 +344,16 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
return $collector->getPaginatedGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user for in repository.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
@@ -521,16 +561,6 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
return $search->take($limit)->get(['id', 'title', 'description']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user for in repository.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
@@ -629,34 +659,4 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
|
||||
return $service->update($recurrence, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createdPreviously(Recurrence $recurrence, Carbon $date): bool
|
||||
{
|
||||
// if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.
|
||||
$set =
|
||||
TransactionJournalMeta::where(function (Builder $q1) use ($recurrence) {
|
||||
$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) {
|
||||
$count = TransactionJournalMeta::where(function (Builder $q2) use ($date) {
|
||||
$string = (string)$date;
|
||||
Log::debug(sprintf('Search for date: %s', json_encode($string)));
|
||||
$q2->where('name', 'recurrence_date');
|
||||
$q2->where('data', json_encode($string));
|
||||
})
|
||||
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user