This commit is contained in:
James Cole 2019-10-31 07:45:55 +01:00
parent c131e6ad9b
commit 5e61fa785e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 18 additions and 20 deletions

View File

@ -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));

View File

@ -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);
}

View File

@ -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