From 8cad430816fdbf936583945e1868ae8d8d2b2c20 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 11 May 2025 07:35:20 +0200 Subject: [PATCH] Fix validation error in transaction processing. --- app/Validation/TransactionValidation.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index 5b5a01a525..c6e4d09496 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -233,16 +233,16 @@ trait TransactionValidation return; } - Log::debug(sprintf('Source account expects %s', $sourceCurrency->code)); - Log::debug(sprintf('Destination account expects %s', $destinationCurrency->code)); + Log::debug(sprintf('Source account expects #%d: %s', $sourceCurrency->id, $sourceCurrency->code)); + Log::debug(sprintf('Destination account expects #%d: %s', $destinationCurrency->id, $destinationCurrency->code)); Log::debug(sprintf('Amount is %s', $transaction['amount'])); if (TransactionTypeEnum::DEPOSIT->value === ucfirst($transactionType)) { Log::debug(sprintf('Processing as a "%s"', $transactionType)); // 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 destination + // the amount must be in the currency of the SOURCE + // the foreign amount must be in the currency of the DESTINATION // no foreign currency information is present: if (!$this->hasForeignCurrencyInfo($transaction)) { @@ -255,7 +255,7 @@ trait TransactionValidation $foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false; $foreignCurrencyId = (int) ($transaction['foreign_currency_id'] ?? 0); 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')); return;