From: Joe Hunt Date: Mon, 17 Aug 2009 09:15:43 +0000 (+0000) Subject: [0000160] Customer payments in different currencies (bank account exchange error... X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=6fa8c9a843d36d2f5dedd26c7836c3161bbc9be5;p=textcart.git [0000160] Customer payments in different currencies (bank account exchange error). Fixed so diff bank_curr and cust/supp curr is readonly. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bf6a61d..2ed69db 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,13 @@ Legend: ! -> Note $ -> Affected files +17-Aug-2009 Joe Hunt +# [0000160] Customer payments in different currencies (bank account exchange error). Fixed so diff bank_curr and cust/supp curr is readonly. +$ /gl/includes/db/gl_db_bank_trans.inc + /purchasing/supplier_payment.php + /sales/customer_payments.php + /sales/includes/db/payments_db.inc + 14-Aug-2009 Janusz Dobrowolski # [0000161] Fixed reference edition on sales invoice/deliery/credit. $ /sales/customer_credit_invoice.php diff --git a/gl/includes/db/gl_db_bank_trans.inc b/gl/includes/db/gl_db_bank_trans.inc index de2ce48..c9f550c 100644 --- a/gl/includes/db/gl_db_bank_trans.inc +++ b/gl/includes/db/gl_db_bank_trans.inc @@ -16,7 +16,7 @@ // $date_ is display date (non-sql) function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, - $amount, $person_type_id, $person_id, $currency="", $err_msg="") + $amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0) { $sqlDate = date2sql($date_); @@ -24,7 +24,10 @@ function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, if ($currency != "") { $bank_account_currency = get_bank_account_currency($bank_act); - $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_); + if ($rate == 0) + $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_); + else + $to_bank_currency = 1 / $rate; $amount_bank = ($amount / $to_bank_currency); } else diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 0834f2a..82ad275 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -83,11 +83,8 @@ function display_controls() if (!is_date_in_fiscalyear($_POST['DatePaid'])) $_POST['DatePaid'] = end_fiscalyear(); } - //start_table($table_style2, 5, 7); - //echo ""; // outer table start_outer_table($table_style2, 5); - //echo ""; table_section(1); bank_accounts_list_row(_("From Bank Account:"), 'bank_account', null, true); @@ -98,28 +95,23 @@ function display_controls() date_row(_("Date Paid") . ":", 'DatePaid', '', null, 0, 0, 0, null, true); table_section(2); - //echo "
"; - //echo ""; // outer table - //echo ""; supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true); set_global_supplier($_POST['supplier_id']); + $comp_currency = get_company_currency(); $supplier_currency = get_supplier_currency($_POST['supplier_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($bank_currency != $supplier_currency) { - exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid'], true); + exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid'], ($bank_currency == $comp_currency)); } ref_row(_("Reference:"), 'ref', '', references::get_next(22)); text_row(_("Memo:"), 'memo_', null, 52,50); - //echo "
"; - - //echo ""; end_outer_table(1); // outer table submit_center('ProcessSuppPayment',_("Enter Payment"), true, '', true); diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 5c87183..8a39103 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -218,11 +218,12 @@ function display_item_form() bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); + $comp_currency = get_company_currency(); $cust_currency = get_customer_currency($_POST['customer_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($cust_currency != $bank_currency) { - exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], true); + exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency)); } text_row(_("Reference:"), 'ref', null, 20, 40); diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index 12e7cc0..d2615c5 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -67,7 +67,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou /*now enter the bank_trans entry */ add_bank_trans(12, $payment_no, $bank_account, $ref, $date_, $amount, payment_person_types::customer(), $customer_id, - get_customer_currency($customer_id)); + get_customer_currency($customer_id), "", $rate); add_comments(12, $payment_no, $date_, $memo_);