mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix validation error in transaction processing.
This commit is contained in:
@@ -233,16 +233,16 @@ trait TransactionValidation
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Source account expects %s', $sourceCurrency->code));
|
Log::debug(sprintf('Source account expects #%d: %s', $sourceCurrency->id, $sourceCurrency->code));
|
||||||
Log::debug(sprintf('Destination account expects %s', $destinationCurrency->code));
|
Log::debug(sprintf('Destination account expects #%d: %s', $destinationCurrency->id, $destinationCurrency->code));
|
||||||
|
|
||||||
Log::debug(sprintf('Amount is %s', $transaction['amount']));
|
Log::debug(sprintf('Amount is %s', $transaction['amount']));
|
||||||
|
|
||||||
if (TransactionTypeEnum::DEPOSIT->value === ucfirst($transactionType)) {
|
if (TransactionTypeEnum::DEPOSIT->value === ucfirst($transactionType)) {
|
||||||
Log::debug(sprintf('Processing as a "%s"', $transactionType));
|
Log::debug(sprintf('Processing as a "%s"', $transactionType));
|
||||||
// use case: deposit from liability account to an asset account
|
// use case: deposit from liability account to an asset account
|
||||||
// the foreign amount must be in the currency of the source
|
// the amount must be in the currency of the SOURCE
|
||||||
// the amount must be in the currency of the destination
|
// the foreign amount must be in the currency of the DESTINATION
|
||||||
|
|
||||||
// no foreign currency information is present:
|
// no foreign currency information is present:
|
||||||
if (!$this->hasForeignCurrencyInfo($transaction)) {
|
if (!$this->hasForeignCurrencyInfo($transaction)) {
|
||||||
@@ -255,7 +255,7 @@ trait TransactionValidation
|
|||||||
$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;
|
$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;
|
||||||
$foreignCurrencyId = (int) ($transaction['foreign_currency_id'] ?? 0);
|
$foreignCurrencyId = (int) ($transaction['foreign_currency_id'] ?? 0);
|
||||||
Log::debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);
|
Log::debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);
|
||||||
if ($foreignCurrencyCode !== $sourceCurrency->code && $foreignCurrencyId !== $sourceCurrency->id) {
|
if ($foreignCurrencyCode !== $destinationCurrency->code && $foreignCurrencyId !== $destinationCurrency->id) {
|
||||||
$validator->errors()->add(sprintf('transactions.%d.foreign_currency_code', $index), (string) trans('validation.require_foreign_src'));
|
$validator->errors()->add(sprintf('transactions.%d.foreign_currency_code', $index), (string) trans('validation.require_foreign_src'));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user