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