Skip to content

Commit

Permalink
Account for frequency being "never"
Browse files Browse the repository at this point in the history
  • Loading branch information
danielh-official committed Nov 14, 2024
1 parent 7e1b24a commit 8260be9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Exports/RepeatingTransactionExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ private function parseTransaction(array $transaction, ?array $parentTransaction
return null;
}

if ($frequency === null) {
return null;
}

$account = $this->accounts->filter(fn ($item) => $this->filterByNotDeleted($item))->firstWhere('id', data_get($transaction, 'account_id'));

if ($parentTransaction) {
Expand Down
44 changes: 44 additions & 0 deletions tests/Feature/Exports/RepeatingTransactionExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,47 @@
expect($result)->toBeInstanceOf(Collection::class)
->and($result->toArray())->toEqual([]);
});

it('ignores items without accepted frequency', function () {
$result = resolve(RepeatingTransactionExport::class, [
'scheduledTransactions' => collect([[
'id' => 1,
'account_id' => 1,
'payee_id' => 1,
'category_id' => 1,
'transfer_account_id' => null,
'deleted' => false,
'frequency' => 'never',
'date_first' => '2021-01-01',
'date_next' => '2021-01-01',
'amount' => -1000,
'memo' => 'Test',
'flag_color' => 'red',
]]),
'categories' => collect([
[
'id' => '1',
'name' => 'Test',
'category_group_name' => 'Test Group',
'deleted' => false,
],
]),
'payees' => collect([
[
'id' => '1',
'name' => 'Test',
'deleted' => false,
],
]),
'accounts' => collect([
[
'id' => '1',
'name' => 'Test',
'deleted' => false,
],
]),
])->collection();

expect($result)->toBeInstanceOf(Collection::class)
->and($result->toArray())->toEqual([]);
});

0 comments on commit 8260be9

Please sign in to comment.