[0000078] Opened Exchange rate for editing (without storing) in sales/purchasing...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 26 Oct 2008 23:18:12 +0000 (23:18 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 26 Oct 2008 23:18:12 +0000 (23:18 +0000)
16 files changed:
gl/includes/db/gl_db_trans.inc
includes/banking.inc
includes/ui/ui_view.inc
purchasing/includes/db/supp_payment_db.inc
purchasing/includes/db/supp_trans_db.inc
purchasing/includes/purchasing_db.inc
purchasing/supplier_payment.php
reporting/rep101.php
reporting/rep106.php
reporting/rep201.php
reporting/rep203.php
reporting/rep209.php
sales/customer_payments.php
sales/includes/db/cust_trans_db.inc
sales/includes/db/payment_db.inc
sales/includes/sales_db.inc

index 79b03d80651e57b3a56385564c8f660d48a54735..969706789b52e308441c0b15a81db6e018c35537 100644 (file)
@@ -8,13 +8,18 @@
 // if $currency is not set, then defaults to no conversion
 
 function add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_,
-       $amount, $currency=null, $person_type_id=null, $person_id=null, $err_msg="")
+       $amount, $currency=null, $person_type_id=null, $person_id=null, $err_msg="", $rate=0)
 {
        global $use_audit_trail;
 
        $date = date2sql($date_);
        if ($currency != null)
-               $amount_in_home_currency = to_home_currency($amount, $currency, $date_);
+       {
+               if ($rate == 0)
+                       $amount_in_home_currency = to_home_currency($amount, $currency, $date_);
+               else
+                       $amount_in_home_currency = round($amount * $rate,  user_price_dec());
+       }               
        else
                $amount_in_home_currency = $amount;
        if ($dimension == null || $dimension < 0)
index 2c0fa94573c09cf2a0bcb3656741f73808f64d63..d26bbbbd7c4c5097ad8970b4914662c1690a4434 100644 (file)
@@ -147,6 +147,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
        if ($person_type == payment_person_types::customer())
        {
                $trans = get_customer_trans($trans_no, $type);
+               $pyt_trans = get_customer_trans($pyt_no, $pyt_type);
                $ar_ap_act = $trans['receivables_account'];
                $person_id = $trans['debtor_no'];
                $curr = $trans['curr_code'];
@@ -154,6 +155,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
        else
        {
                $trans = get_supp_trans($trans_no, $type);
+               $pyt_trans = get_supp_trans($pyt_no, $pyt_type);
                $supp_accs = get_supplier_accounts($trans['supplier_id']);
                $ar_ap_act = $supp_accs['payable_account'];
                $person_id = $trans['supplier_id'];
@@ -161,9 +163,8 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
        }
        if (is_company_currency($curr))
                return;
-       $exc_var_act = get_company_pref('exchange_diff_act');
-       $inv_amt = to_home_currency($amount, $curr, sql2date($trans['tran_date']));
-       $pay_amt = to_home_currency($amount, $curr, $pyt_date);
+       $inv_amt = round($amount * $trans['rate'], user_price_dec()); 
+       $pay_amt = round($amount * $pyt_trans['rate'], user_price_dec());
        if ($inv_amt != $pay_amt)
        {
                $diff = $inv_amt - $pay_amt;
@@ -171,6 +172,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
                        $diff = -$diff;
                if ($neg)
                        $diff = -$diff;
+               $exc_var_act = get_company_pref('exchange_diff_act');
                $memo = systypes::name($type)." ".$trans_no;
                add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
                add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
index 5925579be558ed33433bbbf9d50e31d91c864972..51ea641df4dc13940bd1dfd0e1b55d9942b8ca74 100644 (file)
@@ -275,7 +275,7 @@ function get_trans_view_str($type, $trans_no, $label="")
 // When there is no exrate for today, 
 // gets it form ECB and stores in local database.
 //
-function exchange_rate_display($from_currency, $to_currency, $date_)
+function exchange_rate_display($from_currency, $to_currency, $date_, $edit_rate=false)
 {
     global $Ajax;
 
@@ -296,15 +296,16 @@ function exchange_rate_display($from_currency, $to_currency, $date_)
                        }
                }
                if (!$rate)
-                       $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
-                       
-               if ($from_currency == $comp_currency)
-                       $rate = 1 / $rate;
+                       $rate = get_exchange_rate_from_home_currency($currency, $date_);
+               if ($from_currency != $comp_currency)
+                       $rate = 1 / ($rate / get_exchange_rate_from_home_currency($to_currency, $date_));
 
                $rate = number_format2($rate, user_exrate_dec());
-       label_row(_("Exchange Rate:"),"1 " . $from_currency 
-                       . " = <span id='_ex_rate'>" . $rate . "</span> " . $to_currency );
-                 $Ajax->addUpdate('_ex_rate','_ex_rate', $rate);
+               if ($edit_rate)
+                       text_row(_("Exchange Rate:"), '_ex_rate', $rate, 8, 8, null, "", " $from_currency = 1 $to_currency"); 
+               else
+               label_row(_("Exchange Rate:"),"<span id='_ex_rate'>$rate</span> $from_currency = 1 $to_currency" );
+               $Ajax->addUpdate('_ex_rate','_ex_rate', $rate);
        }
 }
 
index 38b1d440f4c4dcf1279df993aa06a73ce243ee4b..5e5b400d952746786509494d52649ab3546fbe4b 100644 (file)
@@ -1,41 +1,50 @@
 <?php
 
 function add_supp_payment($supplier_id, $date_, $payment_type, $bank_account,
-       $amount, $discount, $ref, $memo_)
+       $amount, $discount, $ref, $memo_, $rate=0)
 {
        begin_transaction();
 
        $supplier_currency = get_supplier_currency($supplier_id);
     $bank_account_currency = get_bank_account_currency($bank_account);
 
-       $supp_amount = exchange_from_to($amount, $bank_account_currency, $supplier_currency, $date_);
-       $supp_discount = exchange_from_to($discount, $bank_account_currency, $supplier_currency, $date_);
+       if ($rate == 0)
+       {
+               $supp_amount = exchange_from_to($amount, $bank_account_currency, $supplier_currency, $date_);
+               $supp_discount = exchange_from_to($discount, $bank_account_currency, $supplier_currency, $date_);
+       }
+       else
+       {
+               $supp_amount = $amount / $rate;
+               $supp_discount = $discount / $rate;
+       }
+       
 
        // it's a supplier payment
        $trans_type = 22;
 
        /* Create a supp_trans entry for the supplier payment */
        $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_,
-               $ref, "", -$supp_amount, 0, -$supp_discount);
+               $ref, "", -$supp_amount, 0, -$supp_discount, "", $rate);
 
        // Now debit creditors account with payment + discount
 
     $supplier_accounts = get_supplier_accounts($supplier_id);
 
        add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0,
-               $supp_amount + $supp_discount, $supplier_id);
+               $supp_amount + $supp_discount, $supplier_id, "", $rate);
 
        // Now credit discount received account with discounts
        if ($supp_discount != 0)
        {
                add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0,
-                       -$supp_discount, $supplier_id);
+                       -$supp_discount, $supplier_id, "", $rate);
        }
 
        if ($supp_amount != 0)
        {
                add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_account, 0, 0,
-                       -$supp_amount, $supplier_id);
+                       -$supp_amount, $supplier_id, "", $rate);
        }
 
    /*now enter the bank_trans entry */
index 0ddabcec3d27f4cb36cb8dc431ac437a17b4969a..975fe428001eb6fc4d024048434079be1b4742cd 100644 (file)
@@ -3,7 +3,7 @@
 //-------------------------------------------------------------------------------------------------------------
 
 function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $supp_reference,
-       $amount, $amount_tax, $discount, $err_msg="")
+       $amount, $amount_tax, $discount, $err_msg="", $rate=0)
 {
        $date = date2sql($date_);
        if ($due_date == "")
@@ -14,7 +14,9 @@ function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $sup
        $trans_no = get_next_trans_no($type);
 
        $curr = get_supplier_currency($supplier_id);
-       $rate = get_exchange_rate_from_home_currency($curr, $date_);
+       
+       if ($rate == 0)
+               $rate = get_exchange_rate_from_home_currency($curr, $date_);
 
 
        $sql = "INSERT INTO ".TB_PREF."supp_trans (trans_no, type, supplier_id, tran_date, due_date,
index 9ab331fe819bf33e0969f66eb4d0059013f1b0b0..a33c81b82fff13e404453b4e00888e608f651d2e 100644 (file)
@@ -23,14 +23,14 @@ include_once($path_to_root . "/purchasing/includes/db/suppliers_db.inc");
 // $amount is in SUPPLIERS'S currency
 
 function add_gl_trans_supplier($type, $type_no, $date_, $account, $dimension, $dimension2,  
-       $amount, $supplier_id, $err_msg="")
+       $amount, $supplier_id, $err_msg="", $rate=0)
 {
        if ($err_msg == "")
                $err_msg = "The supplier GL transaction could not be inserted"; 
                
        return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, "", 
                $amount, get_supplier_currency($supplier_id), 
-               payment_person_types::supplier(), $supplier_id, $err_msg);
+               payment_person_types::supplier(), $supplier_id, $err_msg, $rate);
 }
 
 //----------------------------------------------------------------------------------------
index 28e16c6f3229aad6c1229f0f2cd93aba3ebf60ef..834e5de1b8e08a28a30cb43347c57621c5cccf59 100644 (file)
@@ -100,7 +100,7 @@ function display_controls()
        $bank_currency = get_bank_account_currency($_POST['bank_account']);
        if ($bank_currency != $supplier_currency) 
        {
-               exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']);
+               exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid'], true);
        }
 
        bank_trans_types_list_row(_("Payment Type:"), 'PaymentType', null);
@@ -140,6 +140,13 @@ function check_inputs()
                return false;
        }
 
+       if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 0.000001))
+       {
+               display_error(_("The exchange rate must be numeric and greater than zero."));
+               set_focus('_ex_rate');
+               return false;
+       }
+
        if ($_POST['discount'] == "") 
        {
                $_POST['discount'] = 0;
@@ -154,7 +161,7 @@ function check_inputs()
 
        if (input_num('amount') - input_num('discount') <= 0) 
        {
-               display_error(_("The total of the amount and the discount negative. Please enter positive values."));
+               display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values."));
                set_focus('amount');
                return false;
        }
@@ -192,9 +199,17 @@ function check_inputs()
 
 function handle_add_payment()
 {
+       $supp_currency = get_supplier_currency($_POST['supplier_id']);
+       $bank_currency = get_bank_account_currency($_POST['bank_account']);
+       $comp_currency = get_company_currency();
+       if ($comp_currency != $bank_currency && $bank_currency != $supp_currency)
+               $rate = 0;
+       else
+               $rate = input_num('_ex_rate');
+
        $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'],
                $_POST['PaymentType'], $_POST['bank_account'],
-               input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_']);
+               input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_'], $rate);
 
        //unset($_POST['supplier_id']);
        unset($_POST['bank_account']);
index c98253f2ce46e94887ec38f3b8c9acf80d83bc9f..a206239a7ba82ef0c388109d2b957371399eaebc 100644 (file)
@@ -118,7 +118,7 @@ function print_customer_balances()
                                $rep->TextCol(3, 4,     sql2date($trans['due_date']));
                        $item[0] = $item[1] = 0.0;
                        if ($convert)
-                               $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
+                               $rate = $trans['rate'];
                        else
                                $rate = 1.0;
                        if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2)
index 00e4046109de5d3633dfc102ddcc1c3a70ba96b7..ad26d7dd4ff177c9d1df5b6997448e1ae4d1da6c 100644 (file)
@@ -127,7 +127,7 @@ function print_salesman_list()
                        $subprov = 0;
                }
                $date = sql2date($myrow['tran_date']);
-               $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
+               $rate = $myrow['rate'];
                $amt = $myrow['InvoiceTotal'] * $rate;
                if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0)
                        $prov = $myrow['provision2'] * $amt / 100;
index 92e85c0461c9be2c144bf4eb2bbe818a3bf4d087..89169ce0567eb011cdebc0a9627e00f3b8b6fa91 100644 (file)
@@ -118,7 +118,8 @@ function print_supplier_balances()
                                $rep->TextCol(3, 4,     sql2date($trans['due_date']));
                        $item[0] = $item[1] = 0.0;
                        if ($convert)
-                               $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
+                               //$rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
+                               $rate = $trans['rate'];
                        else
                                $rate = 1.0;
                        if ($trans['TotalAmount'] > 0.0)
index 625e3ce15bf85576f5038930d5d10e1376d4beeb..d69bf519dcb8024f66ae1bf9d4b8017ab03d864c 100644 (file)
@@ -25,17 +25,19 @@ function getTransactions($supplier, $date)
 
        $sql = "SELECT ".TB_PREF."sys_types.type_name,
                        ".TB_PREF."supp_trans.supp_reference,
+                       ".TB_PREF."supp_trans.tran_date,
                        ".TB_PREF."supp_trans.due_date,
                        ".TB_PREF."supp_trans.trans_no,
                        ".TB_PREF."supp_trans.type,
-                       (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst - ".TB_PREF."supp_trans.alloc) AS Balance,
-                       (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst ) AS TranTotal
+                       ".TB_PREF."supp_trans.rate,
+                       (ABS(".TB_PREF."supp_trans.ov_amount) + ABS(".TB_PREF."supp_trans.ov_gst) - ".TB_PREF."supp_trans.alloc) AS Balance,
+                       (ABS(".TB_PREF."supp_trans.ov_amount) + ABS(".TB_PREF."supp_trans.ov_gst) ) AS TranTotal
                FROM ".TB_PREF."supp_trans,
                        ".TB_PREF."sys_types
                WHERE ".TB_PREF."sys_types.type_id = ".TB_PREF."supp_trans.type
                AND ".TB_PREF."supp_trans.supplier_id = '" . $supplier . "'
-               AND ".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst - ".TB_PREF."supp_trans.alloc != 0
-               AND ".TB_PREF."supp_trans.due_date <='" . $date . "'
+               AND ABS(".TB_PREF."supp_trans.ov_amount) + ABS(".TB_PREF."supp_trans.ov_gst) - ".TB_PREF."supp_trans.alloc != 0
+               AND ".TB_PREF."supp_trans.tran_date <='" . $date . "'
                ORDER BY ".TB_PREF."supp_trans.type,
                        ".TB_PREF."supp_trans.trans_no";
 
@@ -106,12 +108,7 @@ function print_payment_report()
                $rep->fontSize += 2;
                $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']);
                if ($convert)
-               {
-                       $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
                        $rep->TextCol(6, 7,     $myrow['curr_code']);
-               }
-               else
-                       $rate = 1.0;
                $rep->fontSize -= 2;
                $rep->NewLine(1, 2);
                $res = getTransactions($myrow['supplier_id'], $to);
@@ -121,11 +118,23 @@ function print_payment_report()
                $total[0] = $total[1] = 0.0;
                while ($trans=db_fetch($res))
                {
+                       if ($convert)
+                               $rate = $trans['rate'];
+                       else
+                               $rate = 1.0;
                        $rep->NewLine(1, 2);
                        $rep->TextCol(0, 1,     $trans['type_name']);
                        $rep->TextCol(1, 2,     $trans['supp_reference']);
-                       $rep->TextCol(2, 3,     sql2date($trans['due_date']));
-                       $item[0] = Abs($trans['TranTotal']) * $rate;
+                       if ($trans['type'] == 20)
+                               $rep->TextCol(2, 3,     sql2date($trans['due_date']));
+                       else    
+                               $rep->TextCol(2, 3,     sql2date($trans['tran_date']));
+                       if ($trans['type'] != 20)
+                       {
+                               $trans['TranTotal'] = -$trans['TranTotal'];
+                               $trans['Balance'] = -$trans['Balance'];
+                       }
+                       $item[0] = $trans['TranTotal'] * $rate;
                        $rep->TextCol(6, 7,     number_format2($item[0], $dec));
                        $item[1] = $trans['Balance'] * $rate;
                        $rep->TextCol(7, 8,     number_format2($item[1], $dec));
index 6ae258303147d1c9e62b557c352930eaa966237d..c6e0240f2289033aa1be1a934e4c01e6eb6adaef 100644 (file)
@@ -111,7 +111,7 @@ function print_po()
                        $DisplayNet = number_format2($Net,$dec);
                        //$rep->TextCol(0, 1,   $myrow2['item_code'], -2);
                        $rep->TextCol(0, 2,     $myrow2['description'], -2);
-                       $rep->TextCol(2, 3,     $myrow2['delivery_date'], -2);
+                       $rep->TextCol(2, 3,     sql2date($myrow2['delivery_date']), -2);
                        $rep->TextCol(3, 4,     $DisplayQty, -2);
                        $rep->TextCol(4, 5,     $myrow2['units'], -2);
                        $rep->TextCol(5, 6,     $DisplayPrice, -2);
index 1ab43ce52a0cc320eb617400f00d3f789f441f95..debd1f3a1f2b93662d09854381a44529cdc28d94 100644 (file)
@@ -86,6 +86,18 @@ function can_process()
                return false;
        }
 
+       if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 0.000001))
+       {
+               display_error(_("The exchange rate must be numeric and greater than zero."));
+               set_focus('_ex_rate');
+               return false;
+       }
+
+       if ($_POST['discount'] == "") 
+       {
+               $_POST['discount'] = 0;
+       }
+
        if (!check_num('discount')) {
                display_error(_("The entered discount is not a valid number."));
                set_focus('discount');
@@ -120,9 +132,18 @@ if (isset($_POST['_DateBanked_changed'])) {
 //----------------------------------------------------------------------------------------------
 
 if (isset($_POST['AddPaymentItem'])) {
+       
+       $cust_currency = get_customer_currency($_POST['customer_id']);
+       $bank_currency = get_bank_account_currency($_POST['bank_account']);
+       $comp_currency = get_company_currency();
+       if ($comp_currency != $bank_currency && $bank_currency != $cust_currency)
+               $rate = 0;
+       else
+               $rate = input_num('_ex_rate');
+
        $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'],
                $_POST['bank_account'], $_POST['DateBanked'], $_POST['ReceiptType'], $_POST['ref'],
-               input_num('amount'), input_num('discount'), $_POST['memo_']);
+               input_num('amount'), input_num('discount'), $_POST['memo_'], $rate);
 
        meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no");
 }
@@ -198,7 +219,7 @@ function display_item_form()
                $bank_currency = get_bank_account_currency($_POST['bank_account']);
 
                if ($cust_currency != $bank_currency) {
-                       exchange_rate_display($cust_currency, $bank_currency, $_POST['DateBanked']);
+                       exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], true);
                }
 
                bank_trans_types_list_row(_("Type:"), 'ReceiptType', null);
index b91a279558873c141331c55c30c21a5222c9ae57..afa814d4779f6e3ec08bfbbc3817c9b090df86ff 100644 (file)
@@ -79,11 +79,12 @@ function get_customer_trans_version($type, $trans_no) {
 function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
        $date_, $reference, $Total, $discount=0, $Tax=0, $Freight=0, $FreightTax=0,
        $sales_type=0, $order_no=0, $trans_link=0, $ship_via=0, $due_date="",
-       $AllocAmt=0)
+       $AllocAmt=0, $rate=0)
 {
 
        $curr = get_customer_currency($debtor_no);
-       $rate = get_exchange_rate_from_home_currency($curr, $date_);
+       if ($rate == 0)
+               $rate = get_exchange_rate_from_home_currency($curr, $date_);
 
        $SQLDate = date2sql($date_);
        if ($due_date == "")
index 74054b06965669e886c5e6389b6fa44a6286a4cd..14d358b8ff18624f05521a7d4c3c5f679611316a 100644 (file)
@@ -3,14 +3,14 @@
   Write/update customer payment.
 */
 function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account,
-       $date_, $receipt_type, $ref, $amount, $discount, $memo_)
+       $date_, $receipt_type, $ref, $amount, $discount, $memo_, $rate=0)
 {
        begin_transaction();
 
        $company_record = get_company_prefs();
 
-       $payment_no = write_customer_trans(12, $trans_no,
-           $customer_id, $branch_id, $date_, $ref, $amount, $discount);
+       $payment_no = write_customer_trans(12, $trans_no, $customer_id, $branch_id, 
+               $date_, $ref, $amount, $discount, 0, 0, 0, 0, 0, 0, 0, "", 0, $rate);
 
        if ($trans_no != 0) {
          delete_comments(12, $trans_no);
@@ -22,7 +22,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
        /* Bank account entry first */
        add_gl_trans_customer(12, $payment_no, $date_,
                $bank_account, 0, 0, $amount,  $customer_id,
-               "Cannot insert a GL transaction for the bank account debit");
+               "Cannot insert a GL transaction for the bank account debit", $rate);
 
        if ($branch_id != reserved_words::get_any_numeric()) {
 
@@ -40,14 +40,14 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
                /* Now Credit Debtors account with receipts + discounts */
                add_gl_trans_customer(12, $payment_no, $date_,
                        $debtors_account, 0, 0, -($discount + $amount), $customer_id,
-                       "Cannot insert a GL transaction for the debtors account credit");
+                       "Cannot insert a GL transaction for the debtors account credit", $rate);
        }
 
        if ($discount != 0)     {
                /* Now Debit discount account with discounts allowed*/
                add_gl_trans_customer(12, $payment_no, $date_,
                        $discount_account, 0, 0, $discount, $customer_id,
-                       "Cannot insert a GL transaction for the payment discount debit");
+                       "Cannot insert a GL transaction for the payment discount debit", $rate);
        }
 
        /*now enter the bank_trans entry */
index 5c4fffdb763b9d907731d531521448f609101c1e..1c6f67f648dd4f4321ce20281628e55821cf6d2f 100644 (file)
@@ -35,14 +35,14 @@ function add_stock_move_customer($type, $stock_id, $trans_id, $location, $date_,
 // $amount is in CUSTOMER'S currency
 
 function add_gl_trans_customer($type, $type_no, $date_, $account, $dimension, $dimension2,
-       $amount, $customer_id, $err_msg="")
+       $amount, $customer_id, $err_msg="", $rate)
 {
        if ($err_msg == "")
                $err_msg = "The customer GL transaction could not be inserted";
 
        return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, "", $amount,
                get_customer_currency($customer_id),
-               payment_person_types::customer(), $customer_id, $err_msg);
+               payment_person_types::customer(), $customer_id, $err_msg, $rate);
 }
 
 //----------------------------------------------------------------------------------------