From 64d4d934eeecbc56ce59b60ec12183878f69b6f6 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 23 Jul 2010 13:12:22 +0000 Subject: [PATCH] Added support for tax included prices in transactions. --- purchasing/includes/db/grn_db.inc | 13 +++++- purchasing/includes/db/invoice_db.inc | 57 ++++++++++++------------ purchasing/includes/db/po_db.inc | 17 ++++--- purchasing/includes/db/supp_trans_db.inc | 30 ++++++++++++- purchasing/includes/po_class.inc | 52 ++++++++++++++++++--- purchasing/includes/supp_trans_class.inc | 40 ++++++++++++----- purchasing/includes/ui/invoice_ui.inc | 5 ++- purchasing/includes/ui/po_ui.inc | 39 +++++++++++----- purchasing/po_entry_items.php | 2 +- purchasing/po_receive_items.php | 18 ++++++-- 10 files changed, 201 insertions(+), 72 deletions(-) diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index e0284cec..a73efa6f 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -10,13 +10,22 @@ See the License here . ***********************************************************************/ //------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008 - function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false) { + // probably this function should be optimized + // passing transaction cart as argument. This would + // save a couple of db calls like get_supplier() + + $supp = get_supplier($supplier); if ($supplier != null) - $currency = get_supplier_currency($supplier); + $currency = $supp['curr_code']; else $currency = null; + + if ($supp['tax_included']) + $price = get_tax_free_price_for_item($stock_id, $price, $supp['tax_group_id'], + $supp['tax_included']); + $dec = user_price_dec(); price_decimal_format($price, $dec); $price = round2($price, $dec); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index de5e8f0a..26ff38a4 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -15,20 +15,20 @@ include_once($path_to_root . "/purchasing/includes/db/invoice_items_db.inc"); function read_supplier_details_to_trans(&$supp_trans, $supplier_id) { - $sql = "SELECT ".TB_PREF."suppliers.supp_name, ".TB_PREF."payment_terms.terms, " - .TB_PREF."payment_terms.days_before_due, - ".TB_PREF."payment_terms.day_in_following_month, - ".TB_PREF."suppliers.tax_group_id, ".TB_PREF."tax_groups.name As tax_group_name - From ".TB_PREF."suppliers, ".TB_PREF."payment_terms, ".TB_PREF."tax_groups - WHERE ".TB_PREF."suppliers.tax_group_id = ".TB_PREF."tax_groups.id - AND ".TB_PREF."suppliers.payment_terms=".TB_PREF."payment_terms.terms_indicator - AND ".TB_PREF."suppliers.supplier_id = ".db_escape($supplier_id); + $sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due, + terms.day_in_following_month, supp.tax_included, + supp.tax_group_id, tax_group.name AS tax_group_name + FROM ".TB_PREF."suppliers supp, ".TB_PREF."payment_terms terms, ".TB_PREF."tax_groups tax_group + WHERE supp.tax_group_id = tax_group.id + AND supp.payment_terms=terms.terms_indicator + AND supp.supplier_id = ".db_escape($supplier_id); $result = db_query($sql, "The supplier record selected: " . $supplier_id . " cannot be retrieved"); $myrow = db_fetch($result); $supp_trans->supplier_id = $supplier_id; + $supp_trans->tax_included = $myrow['tax_included']; $supp_trans->supplier_name = $myrow['supp_name']; $supp_trans->terms_description = $myrow['terms']; @@ -124,13 +124,21 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $tax_total = 0; $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id); - foreach ($taxes as $taxitem) + foreach ($taxes as $n => $taxitem) { - $taxitem['Value'] = round2($taxitem['Value'], user_price_dec()); - $tax_total += $taxitem['Value']; + $taxes[$n]['Value'] = round2($taxitem['Value'], user_price_dec()); + $tax_total += $taxes[$n]['Value']; } - $invoice_items_total = $supp_trans->get_total_charged($supp_trans->tax_group_id); + $invoice_items_total = $supp_trans->get_items_total(); +// $invoice_items_total = $supp_trans->get_total_taxfree($supp_trans->tax_group_id); + + if($supp_trans->tax_included==0) { + $item_added_tax = $tax_total; + } else { + $item_added_tax = 0; + + } $trans_type = $supp_trans->trans_type; @@ -140,6 +148,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $invoice_items_total = -$invoice_items_total; $tax_total = -$tax_total; $supp_trans->ov_discount = -$supp_trans->ov_discount; // this isn't used at all... + $item_added_tax = -$item_added_tax; } $date_ = $supp_trans->tran_date; @@ -148,27 +157,16 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b /*First insert the invoice into the supp_trans table*/ $invoice_id = add_supp_trans($trans_type, $supp_trans->supplier_id, $date_, $supp_trans->due_date, $supp_trans->reference, $supp_trans->supp_reference, - $invoice_items_total, $tax_total, $supp_trans->ov_discount); + $invoice_items_total, $item_added_tax, $supp_trans->ov_discount); $total = 0; /* Now the control account */ $supplier_accounts = get_supplier_accounts($supp_trans->supplier_id); $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0, - -($invoice_items_total + $tax_total + $supp_trans->ov_discount), + -($invoice_items_total + $item_added_tax + $supp_trans->ov_discount), $supp_trans->supplier_id, "The general ledger transaction for the control total could not be added"); - /*Loop through the GL Entries and create a debit posting for each of the accounts entered */ - - /*the postings here are a little tricky, the logic goes like this: - if its a general ledger amount it goes straight to the account specified - - if its a GRN amount invoiced then : - - The cost as originally credited to GRN suspense on arrival of items is debited to GRN suspense. Any difference - between the std cost and the currency cost charged as converted at the ex rate of of the invoice is written off - to the purchase price variance account applicable to the item being invoiced. - */ foreach ($supp_trans->gl_codes as $entered_gl_code) { @@ -192,7 +190,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $trans_type, $invoice_id, $entered_gl_code->amount, $ex_rate, $date_, $supp_trans->supp_reference); } - foreach ($supp_trans->grn_items as $entered_grn) + foreach ($supp_trans->grn_items as $line_no => $entered_grn) { if ($trans_type == ST_SUPPCREDIT) @@ -204,6 +202,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $line_tax = $entered_grn->full_charge_price($supp_trans->tax_group_id) - $line_taxfree; $stock_gl_code = get_stock_gl_code($entered_grn->item_code); $iv_act = (is_inventory_item($entered_grn->item_code) ? $stock_gl_code["inventory_account"] : $stock_gl_code["cogs_account"]); + $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["purchase_account"], $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id); @@ -283,7 +282,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b // ---------------------------------------------------------------------- add_supp_invoice_item($trans_type, $invoice_id, $entered_grn->item_code, - $entered_grn->item_description, 0, $line_taxfree, $line_tax, + $entered_grn->item_description, 0, $entered_grn->chg_price, $line_tax, $entered_grn->this_quantity_inv, $entered_grn->id, $entered_grn->po_detail_item, ""); } /* end of GRN postings */ /* Now the TAX account */ @@ -298,9 +297,8 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $taxitem['Net'] = -$taxitem['Net']; $taxitem['Value'] = -$taxitem['Value']; } - // here we suppose that tax is never included in price (we are company customer). add_trans_tax_details($trans_type, $invoice_id, - $taxitem['tax_type_id'], $taxitem['rate'], 0, $taxitem['Value'], + $taxitem['tax_type_id'], $taxitem['rate'], $supp_trans->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $date_, $supp_trans->supp_reference); if ($trans_type == ST_SUPPCREDIT) @@ -395,6 +393,7 @@ function read_supp_invoice($trans_no, $trans_type, &$supp_trans) $supp_trans->ov_amount = $trans_row["ov_amount"]; $supp_trans->ov_discount = $trans_row["ov_discount"]; $supp_trans->ov_gst = $trans_row["ov_gst"]; + $supp_trans->tax_included = $trans_row["tax_included"]; $id = $trans_row["trans_no"]; diff --git a/purchasing/includes/db/po_db.inc b/purchasing/includes/db/po_db.inc index 889e1a07..859deaa7 100644 --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@ -29,7 +29,8 @@ 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, total) VALUES("; + $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, + requisition_no, into_stock_location, delivery_address, total, tax_included) VALUES("; $sql .= db_escape($po_obj->supplier_id) . "," . db_escape($po_obj->Comments) . ",'" . date2sql($po_obj->orig_order_date) . "', " . @@ -37,7 +38,8 @@ function add_po(&$po_obj) db_escape($po_obj->supp_ref) . ", " . db_escape($po_obj->Location) . ", " . db_escape($po_obj->delivery_address) . ", " . - db_escape($po_obj->get_trans_total()) . ")"; + db_escape($po_obj->get_trans_total()). ", " . + db_escape($po_obj->tax_included) . ")"; db_query($sql, "The purchase order header record could not be inserted"); @@ -79,7 +81,8 @@ function update_po(&$po_obj) into_stock_location=" . db_escape($po_obj->Location). ", ord_date='" . date2sql($po_obj->orig_order_date) . "', delivery_address=" . db_escape($po_obj->delivery_address).", - total=". db_escape($po_obj->get_trans_total()); + total=". db_escape($po_obj->get_trans_total()).", + tax_included=". db_escape($po_obj->tax_included); $sql .= " WHERE order_no = " . $po_obj->order_no; db_query($sql, "The purchase order could not be updated"); @@ -130,10 +133,10 @@ function read_po_header($order_no, &$order) $myrow = db_fetch($result); $order->order_no = $order_no; - $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->set_supplier($myrow["supplier_id"], $myrow["supp_name"], $myrow["curr_code"], + $myrow['tax_group_id'], $myrow["tax_included"]); + $order->credit = get_current_supp_credit($order->supplier_id); $order->orig_order_date = sql2date($myrow["ord_date"]); diff --git a/purchasing/includes/db/supp_trans_db.inc b/purchasing/includes/db/supp_trans_db.inc index a2265bb9..d5112d53 100644 --- a/purchasing/includes/db/supp_trans_db.inc +++ b/purchasing/includes/db/supp_trans_db.inc @@ -216,8 +216,36 @@ function get_sql_for_supplier_inquiry() AND trans.tran_date >= '$date_after' AND trans.tran_date <= '$date_to' AND trans.ov_amount != 0"; // exclude voided transactions - if ($_POST['supplier_id'] != ALL_TEXT) + + $sql2 = "SELECT ".ST_SUPPRECEIVE." as type, + trans.id as trans_no, + trans.reference, + supplier.supp_name, + '' as supp_reference, + delivery_date as tran_date, + '' as due_date, + supplier.curr_code, + '' AS TotalAmount, + '' AS Allocated, + 0 as OverDue, + 1 as Settled + FROM ".TB_PREF."grn_batch as trans, ".TB_PREF."suppliers as supplier + WHERE supplier.supplier_id = trans.supplier_id + AND trans.delivery_date >= '$date_after' + AND trans.delivery_date <= '$date_to'"; + + if ($_POST['supplier_id'] != ALL_TEXT) { $sql .= " AND trans.supplier_id = ".db_escape($_POST['supplier_id']); + $sql2 .= " AND trans.supplier_id = ".db_escape($_POST['supplier_id']); + } + if (($_POST['filterType'] == '6')) + { + $sql = $sql2; + } + elseif (!isset($_POST['filterType']) || $_POST['filterType'] == ALL_TEXT || $_POST['filterType'] == '6') { + $sql = "SELECT * FROM (($sql) UNION ($sql2)) as tr"; + } + if (isset($_POST['filterType']) && $_POST['filterType'] != ALL_TEXT) { if (($_POST['filterType'] == '1')) diff --git a/purchasing/includes/po_class.inc b/purchasing/includes/po_class.inc index 1fee8be7..fa896193 100644 --- a/purchasing/includes/po_class.inc +++ b/purchasing/includes/po_class.inc @@ -29,6 +29,8 @@ class purch_order var $lines_on_order = 0; var $credit; var $tax_group_id; + var $tax_group_array = null; // saves db queries + var $tax_included; // type of prices var $reference; @@ -38,7 +40,17 @@ class purch_order $this->line_items = array(); $this->lines_on_order = $this->order_no = $this->supplier_id = 0; } - + + function set_supplier($supplier_id, $supplier_name, $curr_code, $tax_group_id, $tax_included) + { + $this->supplier_id = $supplier_id; + $this->supplier_name = $supplier_name; + $this->curr_code = $curr_code; + $this->tax_group_id = $tax_group_id; + $this->tax_included = $tax_included; + $this->tax_group_array = get_tax_group_items_as_array($tax_group_id); + } + function add_to_order($line_no, $stock_id, $qty, $item_descr, $price, $uom, $req_del_date, $qty_inv, $qty_recd) { if ($qty != 0 && isset($qty)) @@ -110,6 +122,30 @@ class purch_order } return 0; } + + function get_taxes($shipping_cost=null) + { + $items = array(); + $prices = array(); + if($shipping_cost==null) + $shipping_cost = 0;//$this->freight_cost; + + foreach ($this->line_items as $ln_itm) { + $items[] = $ln_itm->stock_id; + $prices[] = round($ln_itm->quantity * $ln_itm->price, user_price_dec()); + } + $taxes = get_tax_for_items($items, $prices, $shipping_cost, + $this->tax_group_id, $this->tax_included, $this->tax_group_array); + + // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken + if ($this->curr_code == 'CHF') { + $val = $taxes['1']['Value']; + $val1 = (floatval((intval(round(($val*20),0)))/20)); + $taxes['1']['Value'] = $val1; + } + return $taxes; + } + /* Returns order value including all taxes */ @@ -125,11 +161,13 @@ class purch_order $total += $value; } - $taxes = get_tax_for_items($items, $prices, 0, $this->tax_group_id); - - foreach($taxes as $tax) - $total += round($tax['Value'], $dec); + if (!$this->tax_included ) { + $taxes = get_tax_for_items($items, $prices, 0, $this->tax_group_id, + $this->tax_included, $this->tax_group_array); + foreach($taxes as $tax) + $total += round($tax['Value'], $dec); + } return $total; } @@ -146,6 +184,8 @@ class po_line_details var $price; var $units; var $req_del_date; + var $tax_type; + var $tax_type_name; var $quantity; // current/entry quantity of PO line var $qty_inv; // quantity already invoiced against this line @@ -175,6 +215,8 @@ class po_line_details $this->req_del_date = $req_del_date; $this->price = $prc; // $this->units = $uom; + $this->tax_type = $item_row["tax_type_id"]; + $this->tax_type_name = $item_row["tax_type_name"]; $this->units = $item_row["units"]; $this->qty_received = $qty_recd; $this->qty_inv = $qty_inv; diff --git a/purchasing/includes/supp_trans_class.inc b/purchasing/includes/supp_trans_class.inc index 0870f074..293b59a7 100644 --- a/purchasing/includes/supp_trans_class.inc +++ b/purchasing/includes/supp_trans_class.inc @@ -26,6 +26,7 @@ class supp_trans var $tax_description; var $tax_group_id; + var $tax_included; var $trans_type; // invoice or credit @@ -54,7 +55,7 @@ class supp_trans { $this->grn_items[$grn_item_id] = new grn_item($grn_item_id, $po_detail_item, $item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv, - $order_price, $chg_price, $std_cost_unit, $gl_code); + $order_price, $chg_price, $std_cost_unit, $gl_code, $this->tax_included); return 1; } @@ -105,14 +106,15 @@ class supp_trans foreach ($this->grn_items as $ln_itm) { $items[] = $ln_itm->item_code; - $prices[] =round( ($ln_itm->this_quantity_inv * $ln_itm->taxfree_charge_price($tax_group_id, $tax_group)), +// $prices[] =round( ($ln_itm->this_quantity_inv * $ln_itm->taxfree_charge_price($tax_group_id, $tax_group)), + $prices[] =round( ($ln_itm->this_quantity_inv * $ln_itm->chg_price), user_price_dec()); } if ($tax_group_id == null) - $tax_group_id = $this->tax_group_id; - - $taxes = get_tax_for_items($items, $prices, $shipping_cost, $tax_group_id); + $tax_group_id = $this->tax_group_id; + $taxes = get_tax_for_items($items, $prices, $shipping_cost, $tax_group_id, + $this->tax_included); ///////////////// Joe Hunt 2009.08.18 @@ -130,8 +132,10 @@ class supp_trans //////////////// return $taxes; } - - function get_total_charged($tax_group_id=null) + // + // Returns total invoice amount without taxes. + // + function get_total_taxfree($tax_group_id=null) { $total = 0; @@ -153,6 +157,20 @@ class supp_trans return $total; } + function get_items_total() + { + $total = 0; + + foreach ($this->grn_items as $ln_itm) + $total += round($ln_itm->this_quantity_inv * $ln_itm->chg_price, user_price_dec()); + + return $total; + + foreach ($this->gl_codes as $gl_line) + { + $total += $gl_line->amount; + } + } } /* end of class defintion */ class grn_item @@ -172,10 +190,11 @@ all the info to do the necessary entries without looking up ie additional querie var $chg_price; var $std_cost_unit; var $gl_code; + var $tax_included; function grn_item ($id, $po_detail_item, $item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price, - $std_cost_unit, $gl_code) + $std_cost_unit, $gl_code, $tax_included) { $this->id = $id; @@ -189,12 +208,13 @@ all the info to do the necessary entries without looking up ie additional querie $this->chg_price = $chg_price; $this->std_cost_unit = $std_cost_unit; $this->gl_code = $gl_code; + $this->tax_included = $tax_included; } function full_charge_price($tax_group_id, $tax_group=null) { return get_full_price_for_item($this->item_code, - $this->chg_price, $tax_group_id, 0, $tax_group); + $this->chg_price, $tax_group_id, $this->tax_included, $tax_group); } function taxfree_charge_price($tax_group_id, $tax_group=null) @@ -202,7 +222,7 @@ all the info to do the necessary entries without looking up ie additional querie // if ($tax_group_id==null) // return $this->chg_price; return get_tax_free_price_for_item($this->item_code, $this->chg_price, - $tax_group_id, 0, $tax_group); + $tax_group_id, $this->tax_included, $tax_group); } } diff --git a/purchasing/includes/ui/invoice_ui.inc b/purchasing/includes/ui/invoice_ui.inc index 0694cdae..3a6edd5f 100644 --- a/purchasing/includes/ui/invoice_ui.inc +++ b/purchasing/includes/ui/invoice_ui.inc @@ -144,7 +144,7 @@ function invoice_totals(&$supp_trans) label_row(_("Sub-total:"), price_format( $supp_trans->ov_amount), "colspan=$colspan align=right", "align=right"); $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id); - $tax_total = display_edit_tax_items($taxes, $colspan, 0); // tax_included==0 (we are the company) + $tax_total = display_edit_tax_items($taxes, $colspan, $supp_trans->tax_included); $display_total = price_format($supp_trans->ov_amount + $tax_total); @@ -459,7 +459,8 @@ function display_grn_items(&$supp_trans, $mode=0) { $th = array(_("Delivery"), _("Sequence #"), _("P.O."), _("Item"), _("Description"), _("Received On"), _("Quantity Received"), _("Quantity Invoiced"), - _("Qty Yet To Invoice"), _("Order Price"), _("Total"), ""); + _("Qty Yet To Invoice"), $supp_trans->tax_included ? _("Price after Tax") : _("Price before Tax"), + _("Total"), ""); if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) // Added 2008-10-18 by Joe Hunt. Only admins can remove GRNs $th[] = ""; if ($supp_trans->trans_type == ST_SUPPCREDIT) diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 6f50643f..f379573d 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -42,7 +42,7 @@ function copy_to_cart() function get_supplier_details_to_order(&$order, $supplier_id) { - $sql = "SELECT curr_code, supp_name, tax_group_id, + $sql = "SELECT curr_code, supp_name, tax_group_id, supp.tax_included, 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 @@ -55,10 +55,12 @@ function get_supplier_details_to_order(&$order, $supplier_id) $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; + $_POST['supplier_id'] = $supplier_id; + $_POST['supplier_name'] = $myrow["supp_name"]; + $_POST['curr_code'] = $myrow["curr_code"]; + + $order->set_supplier($supplier_id, $myrow["supp_name"], $myrow["curr_code"], + $myrow["tax_group_id"], $myrow["tax_included"]); } //--------------------------------------------------------------------------------------------------- @@ -207,7 +209,7 @@ function display_po_items(&$order, $editable=true) $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Received"), _("Unit"), - _("Required Delivery Date"), _("Price"), _("Line Total"), ""); + _("Required Delivery Date"), $order->tax_included ? _("Price after Tax") : _("Price before Tax"), _("Line Total"), ""); if ($order->trans_type != ST_PURCHORDER) array_remove($th, 5); @@ -252,10 +254,25 @@ function display_po_items(&$order, $editable=true) if ($id==-1 && $editable) po_item_controls($order, $k); - $display_total = price_format($total); - label_row(_("Total Excluding Shipping/Tax"), $display_total, "colspan=" - .(count($order->line_items) ? 7:6)." align=right", - "nowrap align=right", 2); + $colspan = count($th)-2; + if (count($order->line_items)) + $colspan--; + + $display_sub_total = price_format($total); + + label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right", 2); + + $taxes = $order->get_taxes(input_num('freight_cost')); + + $tax_total = display_edit_tax_items($taxes, $colspan, $order->tax_included, 2); + + $display_total = price_format(($total + input_num('freight_cost') + $tax_total)); + + start_row(); + label_cells(_("Amount Total"), $display_total, "colspan=$colspan align='right'","align='right'"); + $order->order_no ? submit_cells('update', _("Update"), "colspan=2 align='center'", _("Refresh"), true) + : label_cell('', "colspan=2"); + end_row(); end_table(1); div_end(); @@ -397,7 +414,7 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1) } else { - submit_cells('EnterLine', _("Add Item"), "colspan=2", + submit_cells('EnterLine', _("Add Item"), "colspan=2 align='center'", _('Add new item to document'), true); } diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index ed6308c9..278c5199 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -355,7 +355,6 @@ function can_commit() set_focus('delivery_address'); return false; } - if (get_post('StkLocation') == '') { display_error(_("There is no location specified to move any items into.")); @@ -420,6 +419,7 @@ function handle_commit_order() $inv->tran_date = $cart->orig_order_date; $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; + $inv->tax_included = $cart->tax_included; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; // $inv->ov_discount 'this isn't used at all' diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index b536ba82..c7e7cb13 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -103,9 +103,20 @@ function display_po_receive_items() } } - $display_total = number_format2($total,user_price_dec()); - label_row(_("Total value of items received"), $display_total, "colspan=8 align=right", - "nowrap align=right"); + $colspan = count($th)-1; + + $display_sub_total = price_format($total/* + input_num('freight_cost')*/); + + label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right"); + $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost')); + + $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['PO']->tax_included); + + $display_total = price_format(($total + input_num('freight_cost') + $tax_total)); + + start_row(); + label_cells(_("Amount Total"), $display_total, "colspan=$colspan align='right'","align='right'"); + end_row(); end_table(); div_end(); } @@ -314,7 +325,6 @@ submit_center_last('ProcessGoodsReceived', _("Process Receive Items"), _("Clear end_form(); //-------------------------------------------------------------------------------------------------- - end_page(); ?> -- 2.30.2