[0000160] Customer payments in different currencies (bank account exchange error...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 17 Aug 2009 09:15:43 +0000 (09:15 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 17 Aug 2009 09:15:43 +0000 (09:15 +0000)
CHANGELOG.txt
gl/includes/db/gl_db_bank_trans.inc
purchasing/supplier_payment.php
sales/customer_payments.php
sales/includes/db/payment_db.inc

index bf6a61d102de576faae97a3b1f98f1db9e205c8b..2ed69db5fd3cd1c7391301d319dfbc6f23035ba6 100644 (file)
@@ -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
index de2ce4862920f121b5d256b89b5c79c63855f6d9..c9f550c82419aff60614b087b662a0f417447075 100644 (file)
@@ -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
index 0834f2a12c4f4d3b255b1262614bf707938fb27b..82ad2750a09926bc664eb0a3f0582e3b9ba8b14f 100644 (file)
@@ -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 "<tr><td valign=top>"; // outer table
        start_outer_table($table_style2, 5);
 
-       //echo "<table>";
        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 "</table>";
-       //echo "</td><td valign=top class='tableseparator'>"; // outer table
-       //echo "<table>";
 
     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 "</table>";
-
-       //echo "</td></tr>";
        end_outer_table(1); // outer table
 
        submit_center('ProcessSuppPayment',_("Enter Payment"), true, '', true);
index 5c871834e8e3540d7d172dfd305f9d6ce296e65d..8a391032279e0576228bf0b8cccad697438ab4e4 100644 (file)
@@ -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);
index 12e7cc0fab833df3b19219c4fc50284a0092df10..d2615c5dc368ff4fb63d42271edd24effcf87780 100644 (file)
@@ -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_);