mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix #2975
This commit is contained in:
@@ -76,7 +76,7 @@ class PiggyBankFormRequest extends Request
|
|||||||
$rules = [
|
$rules = [
|
||||||
'name' => $nameRule,
|
'name' => $nameRule,
|
||||||
'account_id' => 'required|belongsToUser:accounts',
|
'account_id' => 'required|belongsToUser:accounts',
|
||||||
'targetamount' => 'required|numeric|more:0|max:1000000000',
|
'targetamount' => 'required|numeric|gte:0.01|max:1000000000',
|
||||||
'startdate' => 'date',
|
'startdate' => 'date',
|
||||||
'targetdate' => 'date|nullable',
|
'targetdate' => 'date|nullable',
|
||||||
'order' => 'integer|min:1',
|
'order' => 'integer|min:1',
|
||||||
|
@@ -77,12 +77,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
$this->piggyRepos->setUser($account->user);
|
$this->piggyRepos->setUser($account->user);
|
||||||
|
|
||||||
// get currency from account, or use default.
|
// get currency from account, or use default.
|
||||||
// TODO we can use getAccountCurrency() instead
|
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);
|
||||||
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
|
||||||
$currency = $this->currencyRepos->findNull($currencyId);
|
|
||||||
if (null === $currency) {
|
|
||||||
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
|
|
||||||
}
|
|
||||||
|
|
||||||
// note
|
// note
|
||||||
$notes = $this->piggyRepos->getNoteText($piggyBank);
|
$notes = $this->piggyRepos->getNoteText($piggyBank);
|
||||||
@@ -99,6 +94,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
// target and percentage:
|
// target and percentage:
|
||||||
$targetAmount = round($piggyBank->targetamount, $currency->decimal_places);
|
$targetAmount = round($piggyBank->targetamount, $currency->decimal_places);
|
||||||
|
$targetAmount = 1 === bccomp('0.01', (string)$targetAmount) ? '0.01' : $targetAmount;
|
||||||
$percentage = (int)(0 !== bccomp('0', $currentAmountStr) ? $currentAmount / $targetAmount * 100 : 0);
|
$percentage = (int)(0 !== bccomp('0', $currentAmountStr) ? $currentAmount / $targetAmount * 100 : 0);
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$piggyBank->id,
|
'id' => (int)$piggyBank->id,
|
||||||
|
@@ -57,7 +57,7 @@ return [
|
|||||||
'at_least_one_action' => 'Rule must have at least one action.',
|
'at_least_one_action' => 'Rule must have at least one action.',
|
||||||
'base64' => 'This is not valid base64 encoded data.',
|
'base64' => 'This is not valid base64 encoded data.',
|
||||||
'model_id_invalid' => 'The given ID seems invalid for this model.',
|
'model_id_invalid' => 'The given ID seems invalid for this model.',
|
||||||
'more' => ':attribute must be larger than zero.',
|
'more' => ':attribute must be larger than ":more".',
|
||||||
'less' => ':attribute must be less than 10,000,000',
|
'less' => ':attribute must be less than 10,000,000',
|
||||||
'active_url' => 'The :attribute is not a valid URL.',
|
'active_url' => 'The :attribute is not a valid URL.',
|
||||||
'after' => 'The :attribute must be a date after :date.',
|
'after' => 'The :attribute must be a date after :date.',
|
||||||
@@ -195,4 +195,9 @@ return [
|
|||||||
|
|
||||||
'generic_invalid_source' => 'You can\'t use this account as the source account.',
|
'generic_invalid_source' => 'You can\'t use this account as the source account.',
|
||||||
'generic_invalid_destination' => 'You can\'t use this account as the destination account.',
|
'generic_invalid_destination' => 'You can\'t use this account as the destination account.',
|
||||||
|
|
||||||
|
'gte.numeric' => 'The :attribute must be greater than or equal to :value.',
|
||||||
|
'gte.file' => 'The :attribute must be greater than or equal to :value kilobytes.',
|
||||||
|
'gte.string' => 'The :attribute must be greater than or equal to :value characters.',
|
||||||
|
'gte.array' => 'The :attribute must have :value items or more.',
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user