mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix budget API call
This commit is contained in:
parent
98613b5ea6
commit
2b25631611
@ -76,8 +76,8 @@ class StoreRequest extends FormRequest
|
|||||||
'currency_code' => 'exists:transaction_currencies,code',
|
'currency_code' => 'exists:transaction_currencies,code',
|
||||||
// auto budget info
|
// auto budget info
|
||||||
'auto_budget_type' => 'in:reset,rollover,none',
|
'auto_budget_type' => 'in:reset,rollover,none',
|
||||||
'auto_budget_amount' => 'min:0|max:1000000000',
|
'auto_budget_amount' => 'numeric|min:0|max:1000000000|required_if:auto_budget_type,reset|required_if:auto_budget_type,rollover',
|
||||||
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly|required_if:auto_budget_type,reset|required_if:auto_budget_type,rollover',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
Log::error($e->getTraceAsString());
|
Log::error($e->getTraceAsString());
|
||||||
throw new FireflyException('400002: Could not store budget.', 0, $e);
|
throw new FireflyException('400002: Could not store budget.', 0, $e);
|
||||||
}
|
}
|
||||||
if (!array_key_exists('auto_budget_type', $data)) {
|
if (!array_key_exists('auto_budget_type', $data) || !array_key_exists('auto_budget_amount', $data) || !array_key_exists('auto_budget_period', $data)) {
|
||||||
return $newBudget;
|
return $newBudget;
|
||||||
}
|
}
|
||||||
$type = $data['auto_budget_type'];
|
$type = $data['auto_budget_type'];
|
||||||
|
@ -48,16 +48,21 @@ trait ValidatesAutoBudgetRequest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// basic float check:
|
// basic float check:
|
||||||
|
if (!is_numeric($amount)) {
|
||||||
|
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ('' === $amount) {
|
if ('' === $amount) {
|
||||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
||||||
}
|
}
|
||||||
if (null !== $amount && 1 !== bccomp((string)$amount, '0')) {
|
if (1 !== bccomp((string)$amount, '0')) {
|
||||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.auto_budget_amount_positive'));
|
$validator->errors()->add('auto_budget_amount', (string)trans('validation.auto_budget_amount_positive'));
|
||||||
}
|
}
|
||||||
if ('' === $period) {
|
if ('' === $period) {
|
||||||
$validator->errors()->add('auto_budget_period', (string)trans('validation.auto_budget_period_mandatory'));
|
$validator->errors()->add('auto_budget_period', (string)trans('validation.auto_budget_period_mandatory'));
|
||||||
}
|
}
|
||||||
if (null !== $amount && null !== $currencyId && null !== $currencyCode && '' === $currencyCode && 0 === $currencyId) {
|
if (null !== $currencyId && null !== $currencyCode && '' === $currencyCode && 0 === $currencyId) {
|
||||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.require_currency_info'));
|
$validator->errors()->add('auto_budget_amount', (string)trans('validation.require_currency_info'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user