Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Tiny fixes in API
James Cole8c9bb3addb45
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 9fdc689b61..5a8c0fd9ed 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -94,7 +94,7 @@ abstract class Controller extends BaseController$obj = Carbon::parse($date);} catch (InvalidDateException | InvalidFormatException $e) {// don't care- Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));+ Log::warn(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', (string) $date, $e->getMessage()));}}$bag->set($field, $obj);diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.phpindex 39ad831593..6beaeaf3f9 100644--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php@@ -143,10 +143,12 @@ class StoreRequest extends FormRequest'active' => [new IsBoolean],'repeat_until' => 'nullable|date','nr_of_repetitions' => 'nullable|numeric|between:1,31',+'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly','repetitions.*.moment' => 'between:0,10','repetitions.*.skip' => 'nullable|numeric|between:0,31','repetitions.*.weekend' => 'numeric|min:1|max:4',+'transactions.*.description' => 'required|between:1,255','transactions.*.amount' => 'required|numeric|gt:0','transactions.*.foreign_amount' => 'nullable|numeric|gt:0',diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.phpindex 66bc12af35..0dd9509fec 100644--- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php@@ -155,33 +155,34 @@ class UpdateRequest extends FormRequest'first_date' => 'date','apply_rules' => [new IsBoolean],'active' => [new IsBoolean],- 'repeat_until' => 'date',- 'nr_of_repetitions' => 'numeric|between:1,31',+ 'repeat_until' => 'nullable|date',+ 'nr_of_repetitions' => 'nullable|numeric|between:1,31',+'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly','repetitions.*.moment' => 'between:0,10',- 'repetitions.*.skip' => 'numeric|between:0,31',- 'repetitions.*.weekend' => 'numeric|min:1|max:4',+ 'repetitions.*.skip' => 'nullable|numeric|between:0,31',+ 'repetitions.*.weekend' => 'nullable|numeric|min:1|max:4','transactions.*.description' => 'between:1,255','transactions.*.amount' => 'numeric|gt:0',- 'transactions.*.foreign_amount' => 'numeric|gt:0',- 'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',- 'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',- 'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',- 'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',+ 'transactions.*.foreign_amount' => 'nullable|numeric|gt:0',+ 'transactions.*.currency_id' => 'nullable|numeric|exists:transaction_currencies,id',+ 'transactions.*.currency_code' => 'nullable|min:3|max:3|exists:transaction_currencies,code',+ 'transactions.*.foreign_currency_id' => 'nullable|numeric|exists:transaction_currencies,id',+ 'transactions.*.foreign_currency_code' => 'nullable|min:3|max:3|exists:transaction_currencies,code','transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],'transactions.*.source_name' => 'between:1,255|nullable','transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],'transactions.*.destination_name' => 'between:1,255|nullable',// new and updated fields:- 'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],+ 'transactions.*.budget_id' => ['nullable','mustExist:budgets,id', new BelongsUser],'transactions.*.budget_name' => ['between:1,255', 'nullable', new BelongsUser],- 'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser],+ 'transactions.*.category_id' => ['nullable','mustExist:categories,id', new BelongsUser],'transactions.*.category_name' => 'between:1,255|nullable',- 'transactions.*.piggy_bank_id' => ['numeric', 'mustExist:piggy_banks,id', new BelongsUser],+ 'transactions.*.piggy_bank_id' => ['nullable','numeric', 'mustExist:piggy_banks,id', new BelongsUser],'transactions.*.piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser],- 'transactions.*.tags' => 'between:1,64000',+ 'transactions.*.tags' => 'nullable|between:1,64000',];}diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.phpindex 1841c256f1..9fa6af232f 100644--- a/app/Services/Internal/Update/RecurrenceUpdateService.php+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php@@ -303,7 +303,7 @@ class RecurrenceUpdateService$this->setCategory($match, (int)$current['category_id']);}- if (array_key_exists('tags', $current)) {+ if (array_key_exists('tags', $current) && is_array($current['tags'])) {$this->updateTags($match, $current['tags']);}if (array_key_exists('piggy_bank_id', $current)) {diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.phpindex 7340b9163a..fa5160fbc3 100644--- a/app/Validation/RecurrenceValidation.php+++ b/app/Validation/RecurrenceValidation.php@@ -93,7 +93,7 @@ trait RecurrenceValidation// validate source account.$sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;$sourceName = $transaction['source_name'] ?? null;- $validSource = $accountValidator->validateSource($sourceId, $sourceName, null);+ $validSource = $accountValidator->validateSource(['id' => $sourceId, 'name' => $sourceName]);// do something with result:if (false === $validSource) {