James Cole
2024-07-06 18:50:33 +02:00
parent dc675707f9
commit 84a1a876e1

View File

@@ -361,11 +361,17 @@ class CreateRecurringTransactions implements ShouldQueue
// create transaction array and send to factory. // create transaction array and send to factory.
$groupTitle = null; $groupTitle = null;
$count = $recurrence->recurrenceTransactions->count(); $count = $recurrence->recurrenceTransactions->count();
if ($count > 1) { // #8844, if there is one recurrence transaction, use the first title as the title.
if (1 === $count) {
/** @var RecurrenceTransaction $first */ /** @var RecurrenceTransaction $first */
$first = $recurrence->recurrenceTransactions()->first(); $first = $recurrence->recurrenceTransactions()->first();
$groupTitle = $first->description; $groupTitle = $first->description;
} }
// #8844, if there are more, use the recurrence transaction itself.
if ($count > 1) {
$groupTitle = $recurrence->title;
}
if (0 === $count) { if (0 === $count) {
app('log')->error('No transactions to be created in this recurrence. Cannot continue.'); app('log')->error('No transactions to be created in this recurrence. Cannot continue.');
@@ -411,12 +417,12 @@ class CreateRecurringTransactions implements ShouldQueue
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$single = [ $single = [
'type' => null === $first->transactionType ? strtolower($recurrence->transactionType->type) : strtolower($first->transactionType->type), 'type' => null === $transaction?->transactionType?->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type),
'date' => $date, 'date' => $date,
'user' => $recurrence->user_id, 'user' => $recurrence->user_id,
'currency_id' => $transaction->transaction_currency_id, 'currency_id' => $transaction->transaction_currency_id,
'currency_code' => null, 'currency_code' => null,
'description' => $first->description, 'description' => $transaction->description,
'amount' => $transaction->amount, 'amount' => $transaction->amount,
'budget_id' => $this->repository->getBudget($transaction), 'budget_id' => $this->repository->getBudget($transaction),
'budget_name' => null, 'budget_name' => null,