This commit is contained in:
James Cole
2021-05-15 12:58:19 +02:00
parent a7f74522bd
commit 8a8aa7ca71
6 changed files with 45 additions and 5 deletions

View File

@@ -264,6 +264,9 @@ trait RecurringTransactionTrait
$categoryFactory->setUser($transaction->recurrence->user);
$category = $categoryFactory->findOrCreate($categoryId, null);
if (null === $category) {
// remove category:
$transaction->recurrenceTransactionMeta()->where('name', 'category_id')->delete();
$transaction->recurrenceTransactionMeta()->where('name', 'category_name')->delete();
return;
}

View File

@@ -286,9 +286,17 @@ class RecurrenceUpdateService
if (array_key_exists('budget_id', $current)) {
$this->setBudget($match, (int)$current['budget_id']);
}
// reset category if name is set but empty:
// can be removed when v1 is retired.
if (array_key_exists('category_name', $current) && '' === (string)$current['category_name']) {
$current['category_name'] = null;
$current['category_id'] = 0;
}
if (array_key_exists('category_id', $current)) {
$this->setCategory($match, (int)$current['category_id']);
}
if (array_key_exists('tags', $current)) {
$this->updateTags($match, $current['tags']);
}