From 2e4bcaec7cf50ee9bf4dee135d0cd8057af8dfa2 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sat, 31 Aug 2013 09:32:50 +0200 Subject: [PATCH 1/1] Customer Payment: fixed bug with exchange rates resulting in invalid postings ts AR and foreign Exchange Gain Accounts. --- sales/includes/db/payment_db.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index e7c5729a..873e8389 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -41,16 +41,19 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou } $bank = get_bank_account($bank_account); - if (!$rate) - $rate = get_exchange_rate_from_home_currency($bank['bank_curr_code'], $date_ ); if (!$bank_amount) // backward compatibility workaround { + if(!$rate) + $rate = get_exchange_rate_from_to(get_customer_currency($customer_id), + $bank['bank_curr_code'], $date_ ); + $bank_amount = $amount/$rate; } + // do not use $rate here: global rate stored in exrate table is always used $payment_no = write_customer_trans(ST_CUSTPAYMENT, $trans_no, $customer_id, $branch_id, - $date_, $ref, $amount, $discount, 0, 0, 0, 0, 0, 0, "", 0, $rate); + $date_, $ref, $amount, $discount); $bank_gl_account = get_bank_gl_account($bank_account); -- 2.30.2