Do not validate currency if account has no currency configured

This commit is contained in:
Kuba Turek
2023-01-14 16:42:37 +01:00
parent 618e70748c
commit 9191ae5054

View File

@@ -67,8 +67,16 @@ trait ValidatesBulkTransactionQuery
return; return;
} }
// must have same currency: // must have same currency:
if ($repository->getAccountCurrency($source)->id !== $repository->getAccountCurrency($dest)->id) { // some account types (like expenses) do not have currency, so they have to be omitted
$sourceCurrency = $repository->getAccountCurrency($source);
$destCurrency = $repository->getAccountCurrency($dest);
if (
$sourceCurrency !== null
&& $destCurrency !== null
&& $sourceCurrency->id !== $destCurrency->id
) {
$validator->errors()->add('query', (string)trans('validation.invalid_query_currency')); $validator->errors()->add('query', (string)trans('validation.invalid_query_currency'));
} }
} }