Sales Delivery, Direct Invoice and Sales Credit: added exchange rate edition/storage...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 23 May 2013 20:41:08 +0000 (22:41 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 10 Jun 2013 16:58:53 +0000 (18:58 +0200)
sales/includes/cart_class.inc
sales/includes/db/sales_credit_db.inc
sales/includes/db/sales_delivery_db.inc
sales/includes/db/sales_invoice_db.inc
sales/includes/ui/sales_order_ui.inc
sales/sales_order_entry.php

index 5a3d561db42bc5e74568f01f91375844ce3c8b49..64a237f320aa824db88f3377e653e6615cbc7132 100644 (file)
@@ -71,7 +71,8 @@ class cart
        var $payment;
        var $payment_terms; // cached payment terms
        var $credit;
-       
+       var $ex_rate;
+
        //-------------------------------------------------------------------------
        //
        //  $trans_no==0 => open new/direct document
index 2efb8d87a6c0d6cf44fb3c27c77ee0e4f9ae7240..e7b97e55d789648f2c763bbc48aa54f3eb292397 100644 (file)
@@ -41,6 +41,8 @@ function write_credit_note(&$credit_note, $write_off_acc)
        $company_data = get_company_prefs();
        $branch_data = get_branch_accounts($credit_note->Branch);
 
+       add_new_exchange_rate(get_customer_currency($credit_note->customer_id), $credit_date, $credit_note->ex_rate);
+
        $credit_note_total = $credit_note->get_items_total_dispatch();
        $freight_tax = $credit_note->get_shipping_tax();
 
index f92feca5b02622541dcddf3a48563d0f883ddaa3..90ef315e83b4b0330950f66c39ce0afc7847365f 100644 (file)
@@ -24,6 +24,9 @@ function write_sales_delivery(&$delivery,$bo_policy)
        hook_db_prewrite($delivery, ST_CUSTDELIVERY);
 
        $customer = get_customer($delivery->customer_id);
+
+       add_new_exchange_rate($customer['curr_code'], $delivery->document_date, $delivery->ex_rate);
+
        $delivery_items_total = $delivery->get_items_total_dispatch();
        $freight_tax = $delivery->get_shipping_tax();
 
index a1f6dd5cc62697364448f6b99d288d95d627a4d4..cd80b2cf939830a4d441f1cbb3711ddabf89d62d 100644 (file)
@@ -32,6 +32,8 @@ function write_sales_invoice(&$invoice)
 
        $customer = get_customer($invoice->customer_id);
 
+       add_new_exchange_rate($customer['curr_code'], $date_, $invoice->ex_rate);
+
        // offer price values without freight costs
        $items_total = $invoice->get_items_total_dispatch();
        $freight_tax = $invoice->get_shipping_tax();
index 0d2b3d33dbc7c1d011ea9d1525b8ea8e7d864a07..f58f677c1fea70d472b5c555e331f5b00bf230d3 100644 (file)
@@ -372,7 +372,6 @@ function display_order_header(&$order, $editable, $date_text)
                        $row = get_customer_to_order($_POST['customer_id']);
                        if ($row['dissallow_invoices'] == 1)
                                $customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.");
-               
                }
        }
 
@@ -380,7 +379,7 @@ function display_order_header(&$order, $editable, $date_text)
 
        table_section(2);
 
-       if (!is_company_currency($order->customer_currency))
+       if (!is_company_currency($order->customer_currency) && in_array($order->trans_type, array(ST_SALESINVOICE, ST_CUSTDELIVERY)))
        {
                label_row(_("Customer Currency:"), $order->customer_currency);
                exchange_rate_display($order->customer_currency, get_company_currency(),
index da9b9ce9a275b94a72ae8c3a1534eeaec92d6ae3..a9fb1bf1d03024ea96c128a391d24692662f2a6c 100644 (file)
@@ -284,6 +284,7 @@ function copy_to_cart()
                $cart->dimension_id = $_POST['dimension_id'];
                $cart->dimension2_id = $_POST['dimension2_id'];
        }
+       $cart->ex_rate = input_num('_ex_rate', null);
 }
 
 //-----------------------------------------------------------------------------
@@ -314,9 +315,9 @@ function copy_from_cart()
        if ($cart->trans_type!=ST_SALESORDER && $cart->trans_type!=ST_SALESQUOTE) { // 2008-11-12 Joe Hunt
                $_POST['dimension_id'] = $cart->dimension_id;
                $_POST['dimension2_id'] = $cart->dimension2_id;
-       }       
+       }
        $_POST['cart_id'] = $cart->cart_id;
-               
+       $_POST['_ex_rate'] = $cart->ex_rate;
 }
 //--------------------------------------------------------------------------------