mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-13 01:22:26 -06:00
Fix #2771
This commit is contained in:
parent
c131e6ad9b
commit
5e61fa785e
@ -218,6 +218,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
$return = [];
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
|
||||
$single = [
|
||||
'type' => strtolower($recurrence->transactionType->type),
|
||||
'date' => $date,
|
||||
@ -242,8 +243,8 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
'recurrence_id' => (int)$recurrence->id,
|
||||
'order' => $index,
|
||||
'notes' => (string)trans('firefly.created_from_recurrence', ['id' => $recurrence->id, 'title' => $recurrence->title]),
|
||||
'tags' => $this->repository->getTags($recurrence),
|
||||
'piggy_bank_id' => null,
|
||||
'tags' => $this->repository->getTags($transaction),
|
||||
'piggy_bank_id' => $this->repository->getPiggyBank($transaction),
|
||||
'piggy_bank_name' => null,
|
||||
'bill_id' => null,
|
||||
'bill_name' => null,
|
||||
@ -324,7 +325,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
Log::info(sprintf('Created new transaction group #%d', $group->id));
|
||||
|
||||
// link to piggy:
|
||||
$this->linkGroupToPiggies($recurrence, $group);
|
||||
//$this->linkGroupToPiggies($recurrence, $group);
|
||||
|
||||
// trigger event:
|
||||
event(new StoredTransactionGroup($group, $recurrence->apply_rules));
|
||||
|
@ -28,7 +28,6 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\RecurrenceFactory;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Models\RecurrenceMeta;
|
||||
@ -253,19 +252,17 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
* @param RecurrenceTransaction $transaction
|
||||
*
|
||||
* @return PiggyBank|null
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPiggyBank(Recurrence $recurrence): ?PiggyBank
|
||||
public function getPiggyBank(RecurrenceTransaction $transaction): ?int
|
||||
{
|
||||
$meta = $recurrence->recurrenceMeta;
|
||||
/** @var RecurrenceMeta $metaEntry */
|
||||
$meta = $transaction->recurrenceTransactionMeta;
|
||||
/** @var RecurrenceTransactionMeta $metaEntry */
|
||||
foreach ($meta as $metaEntry) {
|
||||
if ('piggy_bank_id' === $metaEntry->name) {
|
||||
$piggyId = (int)$metaEntry->value;
|
||||
|
||||
return $this->user->piggyBanks()->where('piggy_banks.id', $piggyId)->first(['piggy_banks.*']);
|
||||
return (int)$metaEntry->value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,15 +272,15 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
/**
|
||||
* Get the tags from the recurring transaction.
|
||||
*
|
||||
* @param Recurrence $recurrence
|
||||
* @param RecurrenceTransaction $transaction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTags(Recurrence $recurrence): array
|
||||
public function getTags(RecurrenceTransaction $transaction): array
|
||||
{
|
||||
$tags = [];
|
||||
/** @var RecurrenceMeta $meta */
|
||||
foreach ($recurrence->recurrenceMeta as $meta) {
|
||||
foreach ($transaction->recurrenceTransactionMeta as $meta) {
|
||||
if ('tags' === $meta->name && '' !== $meta->value) {
|
||||
$tags = explode(',', $meta->value);
|
||||
}
|
||||
|
@ -120,19 +120,19 @@ interface RecurringRepositoryInterface
|
||||
public function getOccurrencesInRange(RecurrenceRepetition $repetition, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
* @return PiggyBank|null
|
||||
* @param RecurrenceTransaction $transaction
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPiggyBank(Recurrence $recurrence): ?PiggyBank;
|
||||
public function getPiggyBank(RecurrenceTransaction $transaction): ?int;
|
||||
|
||||
/**
|
||||
* Get the tags from the recurring transaction.
|
||||
*
|
||||
* @param Recurrence $recurrence
|
||||
* @param RecurrenceTransaction $transaction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTags(Recurrence $recurrence): array;
|
||||
public function getTags(RecurrenceTransaction $transaction): array;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
|
Loading…
Reference in New Issue
Block a user