From: Janusz Dobrowolski Date: Mon, 21 Jun 2010 17:19:07 +0000 (+0000) Subject: Current credit display implemented. X-Git-Tag: v2.4.2~19^2~835 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=40ee20a833a502a0914202b56473fb330d5774cf;p=fa-stable.git Current credit display implemented. --- diff --git a/includes/sysnames.inc b/includes/sysnames.inc index a60c6c94..bf48ad9c 100644 --- a/includes/sysnames.inc +++ b/includes/sysnames.inc @@ -147,5 +147,14 @@ $sys_crm_cats = array ( 'shipper' => _("Shipper"), 'company' => _("Company internal") ); +//---------------------------------------------------------------------------------- + +$pterm_types = array( + PTT_PRE => _("Prepayment"), + PTT_CASH => _("Cash"), + PTT_DAYS => _("After No. of Days"), + PTT_FOLLOWING => _("Day In Following Month") +); + ?> \ No newline at end of file diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 9717a95c..272d515b 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -899,4 +899,29 @@ function inactive_control_column(&$th) { $Ajax->activate('_page_body'); } } + +function customer_credit_row($customer, $credit, $parms='') +{ + global $path_to_root; + + label_row( _("Current Credit:"), + "" + . price_format($credit) + ."", $parms); +} + +function supplier_credit_row($supplier, $credit, $parms='') +{ + global $path_to_root; + + label_row( _("Current Credit:"), + "" + . price_format($credit) + ."", $parms); +} + ?> \ No newline at end of file diff --git a/purchasing/includes/db/po_db.inc b/purchasing/includes/db/po_db.inc index d401f5e6..41ed94f0 100644 --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@ -29,14 +29,15 @@ function add_po(&$po_obj) begin_transaction(); /*Insert to purchase order header record */ - $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, requisition_no, into_stock_location, delivery_address) VALUES("; + $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, requisition_no, into_stock_location, delivery_address, total) VALUES("; $sql .= db_escape($po_obj->supplier_id) . "," . db_escape($po_obj->Comments) . ",'" . date2sql($po_obj->orig_order_date) . "', " . db_escape($po_obj->reference) . ", " . db_escape($po_obj->supp_ref) . ", " . db_escape($po_obj->Location) . ", " . - db_escape($po_obj->delivery_address) . ")"; + db_escape($po_obj->delivery_address) . ", " . + db_escape($po_obj->get_trans_total()) . ")"; db_query($sql, "The purchase order header record could not be inserted"); @@ -77,7 +78,8 @@ function update_po(&$po_obj) requisition_no= ". db_escape( $po_obj->supp_ref). ", into_stock_location=" . db_escape($po_obj->Location). ", ord_date='" . date2sql($po_obj->orig_order_date) . "', - delivery_address=" . db_escape($po_obj->delivery_address); + delivery_address=" . db_escape($po_obj->delivery_address).", + total=". db_escape($po_obj->get_trans_total()); $sql .= " WHERE order_no = " . $po_obj->order_no; db_query($sql, "The purchase order could not be updated"); @@ -113,7 +115,7 @@ function update_po(&$po_obj) function read_po_header($order_no, &$order) { - $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, + $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.tax_group_id, ".TB_PREF."suppliers.curr_code, ".TB_PREF."locations.location_name FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations WHERE ".TB_PREF."purch_orders.supplier_id = ".TB_PREF."suppliers.supplier_id @@ -121,7 +123,7 @@ function read_po_header($order_no, &$order) AND ".TB_PREF."purch_orders.order_no = ".db_escape($order_no); $result = db_query($sql, "The order cannot be retrieved"); - +_vd($sql); if (db_num_rows($result) == 1) { @@ -131,6 +133,8 @@ function read_po_header($order_no, &$order) $order->supplier_id = $myrow["supplier_id"]; $order->supplier_name = $myrow["supp_name"]; $order->curr_code = $myrow["curr_code"]; + $order->tax_group_id = $myrow['tax_group_id']; + $order->credit = get_current_supp_credit($order->supplier_id); $order->orig_order_date = sql2date($myrow["ord_date"]); $order->Comments = $myrow["comments"]; diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index 972d552a..b0fae283 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -85,68 +85,37 @@ function get_supplier_details($supplier_id, $to=null) $past2 = 2 * $past1; // removed - supp_trans.alloc from all summations - $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; - $due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; - $sql = "SELECT ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.curr_code, ".TB_PREF."payment_terms.terms, + $value = "(trans.ov_amount + trans.ov_gst + trans.ov_discount)"; + $due = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_SUPPCREDIT.",trans.due_date,trans.tran_date)"; + $sql = "SELECT supp.supp_name, supp.curr_code, ".TB_PREF."payment_terms.terms, - Sum($value) AS Balance, + Sum(IFNULL($value,0)) AS Balance, Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0)) AS Due, Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past1,$value,0)) AS Overdue1, - Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2 + Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2, + supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1) + * (ov_amount + ov_gst + ov_discount),0)) as cur_credit, + supp.tax_group_id - FROM ".TB_PREF."suppliers, - ".TB_PREF."payment_terms, - ".TB_PREF."supp_trans + FROM ".TB_PREF."suppliers supp + LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id AND trans.tran_date <= '$todate', + ".TB_PREF."payment_terms WHERE - ".TB_PREF."suppliers.payment_terms = ".TB_PREF."payment_terms.terms_indicator - AND ".TB_PREF."suppliers.supplier_id = $supplier_id - AND ".TB_PREF."supp_trans.tran_date <= '$todate' - AND ".TB_PREF."suppliers.supplier_id = ".TB_PREF."supp_trans.supplier_id + supp.payment_terms = ".TB_PREF."payment_terms.terms_indicator + AND supp.supplier_id = $supplier_id GROUP BY - ".TB_PREF."suppliers.supp_name, + supp.supp_name, ".TB_PREF."payment_terms.terms, ".TB_PREF."payment_terms.days_before_due, ".TB_PREF."payment_terms.day_in_following_month"; $result = db_query($sql,"The customer details could not be retrieved"); - - if (db_num_rows($result) == 0) - { - - /*Because there is no balance - so just retrieve the header information about the customer - the choice is do one query to get the balance and transactions for those customers who have a balance and two queries for those who don't have a balance OR always do two queries - I opted for the former */ - - $nil_balance = true; - - $sql = "SELECT ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.supplier_id, ".TB_PREF."payment_terms.terms - FROM ".TB_PREF."suppliers, - ".TB_PREF."payment_terms - WHERE - ".TB_PREF."suppliers.payment_terms = ".TB_PREF."payment_terms.terms_indicator - AND ".TB_PREF."suppliers.supplier_id = ".db_escape($supplier_id); - - $result = db_query($sql,"The customer details could not be retrieved"); - - } - else - { - $nil_balance = false; - } - $supp = db_fetch($result); - if ($nil_balance == true) - { - $supp["Balance"] = 0; - $supp["Due"] = 0; - $supp["Overdue1"] = 0; - $supp["Overdue2"] = 0; - } - return $supp; - } function get_supplier($supplier_id) @@ -188,4 +157,11 @@ function get_supplier_contacts($supplier_id, $action=null) return $results; } +function get_current_supp_credit($supplier_id) +{ + $suppdet = get_supplier_details($supplier_id); + return $suppdet['cur_credit']; + +} + ?> \ No newline at end of file diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 1e6f4f79..6f50643f 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -42,12 +42,20 @@ function copy_to_cart() function get_supplier_details_to_order(&$order, $supplier_id) { - $sql = "SELECT curr_code,supp_name FROM ".TB_PREF."suppliers - WHERE supplier_id = '$supplier_id'"; + $sql = "SELECT curr_code, supp_name, tax_group_id, + supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1) + * (ov_amount + ov_gst + ov_discount),0)) as cur_credit + FROM ".TB_PREF."suppliers supp + LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id + WHERE supp.supplier_id = '$supplier_id' + GROUP BY + supp.supp_name"; + $result = db_query($sql, "The supplier details could not be retreived"); $myrow = db_fetch($result); - + $order->credit = $myrow["cur_credit"]; + $order->tax_group_id = $myrow["tax_group_id"]; $order->curr_code = $_POST['curr_code'] = $myrow["curr_code"]; $order->supplier_name = $_POST['supplier_name'] = $myrow["supp_name"]; $order->supplier_id = $_POST['supplier_id'] = $supplier_id; @@ -125,6 +133,10 @@ function display_po_header(&$order) $_POST['OrderDate']); } + supplier_credit_row($order->supplier_id, $order->credit); + + table_section(2); + if ($editable) { ref_row(_("Reference:"), 'ref'); @@ -135,8 +147,6 @@ function display_po_header(&$order) label_row(_("Reference:"), $order->reference); } - table_section(2); - // check this out????????? //if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") // $_POST['OrderDate'] = $order->orig_order_date; diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 756add4d..ed6308c9 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -14,6 +14,7 @@ $page_security = 'SA_PURCHASEORDER'; include_once($path_to_root . "/purchasing/includes/po_class.inc"); include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); +include_once($path_to_root . "/purchasing/includes/db/suppliers_db.inc"); include_once($path_to_root . "/reporting/includes/reporting.inc"); set_page_security( @$_SESSION['PO']->trans_type, diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 2284f18a..814ff8dc 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -377,6 +377,7 @@ start_table(TABLESTYLE, "width=90%"); if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['DispatchDate']); } +customer_credit_row($_SESSION['Items']->customer_id, $_SESSION['Items']->credit, "class='tableheader2'"); start_row(); date_cells(_("Invoice Dead-line"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'"); end_row(); diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 5cf5f7bd..f5a12058 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -74,6 +74,8 @@ class cart var $dimension2_id; var $payment; var $payment_terms; // cached payment terms + var $credit; + //------------------------------------------------------------------------- // // $trans_no==0 => open new/direct document @@ -238,6 +240,7 @@ class cart $this->due_date = add_days($this->document_date, $SysPrefs->default_delivery_required_by()); } + $this->credit = get_current_cust_credit($this->customer_id); $this->pos = user_pos(); $pos = get_sales_point($this->pos); if (!$pos['cash_sale'] && !$pos['credit_sale']) @@ -305,6 +308,7 @@ class cart $this->payment_terms = get_payment_terms($payment); $this->cash = $this->payment_terms['cash_sale']; $this->cash_discount = $cdiscount; + $this->credit = get_current_cust_credit($customer_id); } function set_branch($branch_id, $tax_group_id, $tax_group_name, $phone='', $email='') @@ -466,7 +470,7 @@ class cart // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken if ($this->customer_currency == 'CHF') { $val = $taxes['1']['Value']; - $val1 = (floatval((intval(round(($val*20),0)))/20)); + $val1 = (floatval((intval(round(($val*20),0)))/20)); $taxes['1']['Value'] = $val1; } return $taxes; @@ -500,7 +504,22 @@ class cart else return round($this->freight_cost*$tax_rate/100, user_price_dec()); } + /* + Returns transaction value including all taxes + */ + function get_trans_total() { + + $total = $this->get_items_total() + $this->freight_cost; + $dec = user_price_dec(); + if (!$this->tax_included ) { + $total += $this->get_shipping_tax(); + $taxes = $this->get_taxes(); + foreach($taxes as $tax) + $total += round($tax['Value'], $dec); + } + return $total; + } } /* end of class defintion */ class line_details diff --git a/sales/includes/db/customers_db.inc b/sales/includes/db/customers_db.inc index 5f674881..a9a6301b 100644 --- a/sales/includes/db/customers_db.inc +++ b/sales/includes/db/customers_db.inc @@ -72,33 +72,29 @@ function get_customer_details($customer_id, $to=null) $past2 = 2 * $past1; // removed - debtor_trans.alloc from all summations - $value = "IF(".TB_PREF."debtor_trans.type=11 OR ".TB_PREF."debtor_trans.type=12 OR ".TB_PREF."debtor_trans.type=2, - -1, 1) *". - "(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + " - .TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_freight_tax + " - .TB_PREF."debtor_trans.ov_discount)"; - $due = "IF (".TB_PREF."debtor_trans.type=10,".TB_PREF."debtor_trans.due_date,".TB_PREF."debtor_trans.tran_date)"; + $value = "IFNULL(IF(trans.type=11 OR trans.type=12 OR trans.type=2, -1, 1) + * (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount),0)"; + + $due = "IF (trans.type=10, trans.due_date, trans.tran_date)"; $sql = "SELECT ".TB_PREF."debtors_master.name, ".TB_PREF."debtors_master.curr_code, ".TB_PREF."payment_terms.terms, ".TB_PREF."debtors_master.credit_limit, ".TB_PREF."credit_status.dissallow_invoices, ".TB_PREF."credit_status.reason_description, - Sum(".$value.") AS Balance, - + Sum(IFNULL($value,0)) AS Balance, Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0)) AS Due, Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past1,$value,0)) AS Overdue1, Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2 - FROM ".TB_PREF."debtors_master, + FROM ".TB_PREF."debtors_master + LEFT JOIN ".TB_PREF."debtor_trans trans ON + trans.tran_date <= '$todate' AND ".TB_PREF."debtors_master.debtor_no = trans.debtor_no AND trans.type <> 13 +, ".TB_PREF."payment_terms, - ".TB_PREF."credit_status, - ".TB_PREF."debtor_trans + ".TB_PREF."credit_status WHERE ".TB_PREF."debtors_master.payment_terms = ".TB_PREF."payment_terms.terms_indicator - AND ".TB_PREF."debtors_master.credit_status = ".TB_PREF."credit_status.id + AND ".TB_PREF."debtors_master.credit_status = ".TB_PREF."credit_status.id AND ".TB_PREF."debtors_master.debtor_no = ".db_escape($customer_id)." - AND ".TB_PREF."debtor_trans.tran_date <= '$todate' - AND ".TB_PREF."debtor_trans.type <> 13 - AND ".TB_PREF."debtors_master.debtor_no = ".TB_PREF."debtor_trans.debtor_no GROUP BY ".TB_PREF."debtors_master.name, @@ -110,46 +106,13 @@ function get_customer_details($customer_id, $to=null) ".TB_PREF."credit_status.reason_description"; $result = db_query($sql,"The customer details could not be retrieved"); - if (db_num_rows($result) == 0) - { - - /*Because there is no balance - so just retrieve the header information about the customer - the choice is do one query to get the balance and transactions for those customers who have a balance and two queries for those who don't have a balance OR always do two queries - I opted for the former */ - - $nil_balance = true; - - $sql = "SELECT ".TB_PREF."debtors_master.name, ".TB_PREF."debtors_master.curr_code, ".TB_PREF."debtors_master.debtor_no, ".TB_PREF."payment_terms.terms, - ".TB_PREF."debtors_master.credit_limit, ".TB_PREF."credit_status.dissallow_invoices, ".TB_PREF."credit_status.reason_description - FROM ".TB_PREF."debtors_master, - ".TB_PREF."payment_terms, - ".TB_PREF."credit_status - - WHERE - ".TB_PREF."debtors_master.payment_terms = ".TB_PREF."payment_terms.terms_indicator - AND ".TB_PREF."debtors_master.credit_status = ".TB_PREF."credit_status.id - AND ".TB_PREF."debtors_master.debtor_no = ".db_escape($customer_id); - - $result = db_query($sql,"The customer details could not be retrieved"); - - } - else - { - $nil_balance = false; - } - $customer_record = db_fetch($result); - if ($nil_balance == true) - { - $customer_record["Balance"] = 0; - $customer_record["Due"] = 0; - $customer_record["Overdue1"] = 0; - $customer_record["Overdue2"] = 0; - } - return $customer_record; } + function get_customer($customer_id) { $sql = "SELECT * FROM ".TB_PREF."debtors_master WHERE debtor_no=".db_escape($customer_id); @@ -193,5 +156,12 @@ function get_customer_contacts($customer_id, $action=null) return $results; } +function get_current_cust_credit($customer_id) +{ + $custdet = get_customer_details($customer_id); + + return $custdet['credit_limit']-$custdet['Balance']; + +} ?> \ No newline at end of file diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index 27b4fe9a..4ccc0fe8 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -19,9 +19,10 @@ function add_sales_order(&$order) $order_no = get_next_trans_no($order->trans_type); $del_date = date2sql($order->due_date); $order_type = 0; // this is default on new order + $total = $order->get_trans_total(); $sql = "INSERT INTO ".TB_PREF."sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date, order_type, ship_via, deliver_to, delivery_address, contact_phone, - freight_cost, from_stk_loc, delivery_date, payment_terms) + freight_cost, from_stk_loc, delivery_date, payment_terms, total) VALUES (" .db_escape($order_no) . "," .db_escape($order_type) . "," . db_escape($order->customer_id) . ", " .db_escape($order->trans_type) . "," .db_escape($order->Branch) . ", ". db_escape($order->cust_ref) .",". @@ -36,7 +37,8 @@ function add_sales_order(&$order) db_escape($order->freight_cost) .", " . db_escape($order->Location) .", " . db_escape($del_date) . "," . - db_escape($order->payment) . ")"; + db_escape($order->payment) . "," . + db_escape($total). ")"; db_query($sql, "order Cannot be Added"); @@ -155,6 +157,7 @@ function update_sales_order($order) $ord_date = date2sql($order->document_date); $order_no = key($order->trans_no); $version= current($order->trans_no); + $total = $order->get_trans_total(); begin_transaction(); @@ -174,7 +177,8 @@ function update_sales_order($order) from_stk_loc = " .db_escape($order->Location) .", delivery_date = " .db_escape($del_date). ", version = ".($version+1).", - payment_terms = " .db_escape($order->payment). " + payment_terms = " .db_escape($order->payment). ", + total = ". db_escape($total) ." WHERE order_no=" . $order_no ." AND trans_type=".$order->trans_type." AND version=".$version; db_query($sql, "order Cannot be Updated, this can be concurrent edition conflict"); @@ -431,26 +435,29 @@ function get_invoice_duedate($terms, $invdate) function get_customer_to_order($customer_id) { // Now check to ensure this account is not on hold */ - $sql = "SELECT ".TB_PREF."debtors_master.name, " - .TB_PREF."debtors_master.address, " - .TB_PREF."credit_status.dissallow_invoices, " - .TB_PREF."debtors_master.sales_type AS salestype, " - .TB_PREF."debtors_master.dimension_id, " - .TB_PREF."debtors_master.dimension2_id, " - .TB_PREF."sales_types.sales_type, " - .TB_PREF."sales_types.tax_included, " - .TB_PREF."sales_types.factor, " - .TB_PREF."debtors_master.curr_code, " - .TB_PREF."debtors_master.discount," - .TB_PREF."debtors_master.payment_terms," - .TB_PREF."debtors_master.pymt_discount - FROM ".TB_PREF."debtors_master, " + $sql = "SELECT cust.name, + cust.address, " + .TB_PREF."credit_status.dissallow_invoices, + cust.sales_type AS salestype, + cust.dimension_id, + cust.dimension2_id, + stype.sales_type, + stype.tax_included, + stype.factor, + cust.curr_code, + cust.discount, + cust.payment_terms, + cust.pymt_discount, + cust.credit_limit - Sum(IFNULL(IF(trans.type=11 OR trans.type=12 OR trans.type=2, + -1, 1) * (ov_amount + ov_gst + ov_freight + ov_freight_tax + ov_discount),0)) as cur_credit + FROM ".TB_PREF."debtors_master cust + LEFT JOIN ".TB_PREF."debtor_trans trans ON trans.type!=".ST_CUSTDELIVERY." AND trans.debtor_no = cust.debtor_no," .TB_PREF."credit_status, " - .TB_PREF."sales_types - WHERE ".TB_PREF."debtors_master.sales_type=" - .TB_PREF."sales_types.id - AND ".TB_PREF."debtors_master.credit_status=".TB_PREF."credit_status.id - AND ".TB_PREF."debtors_master.debtor_no = ".db_escape($customer_id); + .TB_PREF."sales_types stype + WHERE cust.sales_type=stype.id + AND cust.credit_status=".TB_PREF."credit_status.id + AND cust.debtor_no = ".db_escape($customer_id) + ." GROUP by cust.debtor_no"; $result =db_query($sql,"Customer Record Retreive"); return db_fetch($result); diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 57be1195..3fef8720 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -90,6 +90,8 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included'], $myrow['factor']); + $order->credit = $myrow['cur_credit']; + if ($order->trans_type != ST_SALESORDER && $order->trans_type != ST_SALESQUOTE) { $order->dimension_id = $myrow['dimension_id']; @@ -135,7 +137,7 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) function display_order_summary($title, &$order, $editable_items=false) { - global $path_to_root, $SysPrefs; + global $SysPrefs; display_heading($title); @@ -363,14 +365,19 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group ref_row(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, ''); + table_section(2); + if (!is_company_currency($order->customer_currency)) { - table_section(2); - label_row(_("Customer Currency:"), $order->customer_currency); exchange_rate_display($order->customer_currency, get_company_currency(), ($editable ? $_POST['OrderDate'] : $order->document_date)); } + + customer_credit_row($_POST['customer_id'], $order->credit); + + label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%"); + table_section(3); if (($order->trans_type != ST_CUSTDELIVERY) && ($order->pos != -1)) { // editable payment type @@ -406,8 +413,6 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group $change_prices = 1; } - label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%"); - table_section(4); if ($editable)