mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix #10687
This commit is contained in:
@@ -96,7 +96,10 @@ class StoreRequest extends FormRequest
|
|||||||
function (Validator $validator): void {
|
function (Validator $validator): void {
|
||||||
// validate start before end only if both are there.
|
// validate start before end only if both are there.
|
||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$currency = $this->getCurrencyFromData($data);
|
$currency = $this->getCurrencyFromData($validator, $data);
|
||||||
|
if(null === $currency) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$targetAmount = (string) ($data['target_amount'] ?? '0');
|
$targetAmount = (string) ($data['target_amount'] ?? '0');
|
||||||
$currentAmount = '0';
|
$currentAmount = '0';
|
||||||
if (array_key_exists('accounts', $data) && is_array($data['accounts'])) {
|
if (array_key_exists('accounts', $data) && is_array($data['accounts'])) {
|
||||||
@@ -130,7 +133,7 @@ class StoreRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCurrencyFromData(array $data): TransactionCurrency
|
private function getCurrencyFromData(Validator $validator, array $data): ?TransactionCurrency
|
||||||
{
|
{
|
||||||
if (array_key_exists('transaction_currency_code', $data) && '' !== (string) $data['transaction_currency_code']) {
|
if (array_key_exists('transaction_currency_code', $data) && '' !== (string) $data['transaction_currency_code']) {
|
||||||
$currency = TransactionCurrency::whereCode($data['transaction_currency_code'])->first();
|
$currency = TransactionCurrency::whereCode($data['transaction_currency_code'])->first();
|
||||||
@@ -144,7 +147,7 @@ class StoreRequest extends FormRequest
|
|||||||
return $currency;
|
return $currency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$validator->errors()->add('transaction_currency_id', trans('validation.require_currency_id_code'));
|
||||||
throw new FireflyException('Unexpected empty currency.');
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,6 +77,7 @@ return [
|
|||||||
'at_least_one_repetition' => 'Need at least one repetition.',
|
'at_least_one_repetition' => 'Need at least one repetition.',
|
||||||
'require_repeat_until' => 'Require either a number of repetitions, or an end date (repeat_until). Not both.',
|
'require_repeat_until' => 'Require either a number of repetitions, or an end date (repeat_until). Not both.',
|
||||||
'require_currency_info' => 'The content of this field is invalid without currency information.',
|
'require_currency_info' => 'The content of this field is invalid without currency information.',
|
||||||
|
'require_currency_id_code' => 'Please set either "transaction_currency_id" or "transaction_currency_code".',
|
||||||
'not_transfer_account' => 'This account is not an account that can be used for transfers.',
|
'not_transfer_account' => 'This account is not an account that can be used for transfers.',
|
||||||
'require_currency_amount' => 'The content of this field is invalid without foreign amount information.',
|
'require_currency_amount' => 'The content of this field is invalid without foreign amount information.',
|
||||||
'require_foreign_currency' => 'This field requires a number',
|
'require_foreign_currency' => 'This field requires a number',
|
||||||
|
Reference in New Issue
Block a user