From: Janusz Dobrowolski Date: Thu, 23 May 2013 13:18:34 +0000 (+0200) Subject: Direct GRN, GRN to PO, Direct Purchase Invoice: added exchange rate edition/storage... X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=ab1b31e53054b0e77deed2be48ea1436b0d63b9b;p=textcart.git Direct GRN, GRN to PO, Direct Purchase Invoice: added exchange rate edition/storage on new transaction date. --- diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 2bfa00d..6c684cf 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -98,6 +98,8 @@ function add_grn(&$po) begin_transaction(); hook_db_prewrite($po, ST_SUPPRECEIVE); + add_new_exchange_rate(get_supplier_currency($po->supplier_id), $date_, $po->ex_rate); + $grn = add_grn_batch($po->order_no, $po->supplier_id, $po->reference, $po->Location, $date_); $clearing_act = get_company_pref('grn_clearing_act'); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index 1d729ea..83e9f7f 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -124,6 +124,8 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $supplier = get_supplier($supp_trans->supplier_id); + add_new_exchange_rate($supplier['curr_code'], $supp_trans->tran_date, $supp_trans->ex_rate); + foreach ($taxes as $n => $taxitem) { $taxes[$n]['Value'] = round2($taxitem['Value'], user_price_dec()); diff --git a/purchasing/includes/po_class.inc b/purchasing/includes/po_class.inc index 142dd55..f9f75aa 100644 --- a/purchasing/includes/po_class.inc +++ b/purchasing/includes/po_class.inc @@ -33,7 +33,8 @@ class purch_order var $tax_group_array = null; // saves db queries var $tax_included; // type of prices var $terms; - + var $ex_rate; + var $reference; var $tax_overrides = array(); // array of taxes manually inserted during sales invoice entry (direct invoice) diff --git a/purchasing/includes/supp_trans_class.inc b/purchasing/includes/supp_trans_class.inc index a62688e..c85f8ae 100644 --- a/purchasing/includes/supp_trans_class.inc +++ b/purchasing/includes/supp_trans_class.inc @@ -22,6 +22,7 @@ class supp_trans var $supplier_id; var $supplier_name; var $terms; + var $ex_rate; var $tax_description; var $tax_group_id; diff --git a/purchasing/includes/ui/grn_ui.inc b/purchasing/includes/ui/grn_ui.inc index cfb2f26..d0db38f 100644 --- a/purchasing/includes/ui/grn_ui.inc +++ b/purchasing/includes/ui/grn_ui.inc @@ -11,59 +11,81 @@ ***********************************************************************/ //--------------------------------------------------------------------------------------------------- -function display_grn_summary(&$po, $editable=false) +function display_grn_summary(&$po) { global $Refs; start_table(TABLESTYLE2, "width=90%"); - + start_row(); label_cells(_("Supplier"), $po->supplier_name, "class='tableheader2'"); - + if (!is_company_currency($po->curr_code)) label_cells(_("Order Currency"), $po->curr_code, "class='tableheader2'"); - + label_cells(_("For Purchase Order"), get_trans_view_str(ST_PURCHORDER, $po->order_no), "class='tableheader2'"); - + label_cells(_("Ordered On"), $po->orig_order_date, "class='tableheader2'"); end_row(); - + start_row(); - if ($editable) - { + label_cells(_("Reference"), $po->reference, "class='tableheader2'"); + label_cells(_("Deliver Into Location"), get_location_name($po->Location), "class='tableheader2'"); + label_cells(_("Supplier's Reference"), $po->supp_ref, "class='tableheader2'"); + + end_row(); + + label_row(_("Delivery Address"), $po->delivery_address, "class='tableheader2'", "colspan=9"); + + if ($po->Comments != "") + label_row(_("Order Comments"), $po->Comments, "class='tableheader2'", "colspan=9"); + end_table(1); +} + +function edit_grn_summary(&$po) +{ + global $Refs; + + start_outer_table(TABLESTYLE2, "width=80%"); + + table_section(1); + label_row(_("Supplier"), $po->supplier_name); + + if (!is_company_currency($po->curr_code)) + label_row(_("Order Currency"), $po->curr_code); + + label_row(_("For Purchase Order"), get_trans_view_str(ST_PURCHORDER, $po->order_no)); + + label_row(_("Ordered On"), $po->orig_order_date); + + table_section(2); if (!isset($_POST['ref'])) $_POST['ref'] = $Refs->get_next(ST_SUPPRECEIVE); - ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'"); - + ref_row(_("Reference"), 'ref', '', null); + if (!isset($_POST['Location'])) $_POST['Location'] = $po->Location; - label_cell(_("Deliver Into Location"), "class='tableheader2'"); - locations_list_cells(null, "Location", $_POST['Location']); - + + locations_list_row(_("Deliver Into Location"), "Location", $_POST['Location']); + if (!isset($_POST['DefaultReceivedDate'])) $_POST['DefaultReceivedDate'] = new_doc_date(); - - date_cells(_("Date Items Received"), 'DefaultReceivedDate', '', true, 0, 0, 0, "class='tableheader2'"); + + date_row(_("Date Items Received"), 'DefaultReceivedDate', '', true, 0, 0, 0, '', true); + + table_section(3); // currently this is related order supp reference -// ref_cells(_("Supplier's Reference"), 'supp_ref', _("Supplier's Reference"), null, "class='tableheader2'"); - label_cells(_("Supplier's Reference"), $po->supp_ref, "class='tableheader2'"); - } - else - { - label_cells(_("Reference"), $po->reference, "class='tableheader2'"); - label_cells(_("Deliver Into Location"), get_location_name($po->Location), "class='tableheader2'"); - label_cells(_("Supplier's Reference"), $po->supp_ref, "class='tableheader2'"); - } - - end_row(); - - if (!$editable) - - label_row(_("Delivery Address"), $po->delivery_address, "class='tableheader2'", "colspan=9"); - - if ($po->Comments != "") - label_row(_("Order Comments"), $po->Comments, "class='tableheader2'", "colspan=9"); - end_table(1); +// ref_row(_("Supplier's Reference"), 'supp_ref', _("Supplier's Reference")); + label_row(_("Supplier's Reference"), $po->supp_ref); + + label_row(_("Delivery Address"), $po->delivery_address); + + if ($po->Comments != "") + label_row(_("Order Comments"), $po->Comments, "class='tableheader2'", "colspan=9"); + + if (!is_company_currency($po->curr_code)) + exchange_rate_display($po->curr_code, get_company_currency(), get_post('DefaultReceivedDate')); + end_outer_table(1); } ?> \ No newline at end of file diff --git a/purchasing/includes/ui/invoice_ui.inc b/purchasing/includes/ui/invoice_ui.inc index 1591f73..3421d1f 100644 --- a/purchasing/includes/ui/invoice_ui.inc +++ b/purchasing/includes/ui/invoice_ui.inc @@ -19,6 +19,7 @@ function copy_from_trans(&$supp_trans) $_POST['supp_reference'] = $supp_trans->supp_reference; $_POST['reference'] = $supp_trans->reference; $_POST['supplier_id'] = $supp_trans->supplier_id; + $_POST['_ex_rate'] = $supp_trans->ex_rate; if (isset($supp_trans->tax_overrides)) foreach($supp_trans->tax_overrides as $id => $value) $_POST['mantax'][$id] = price_format($value); @@ -33,6 +34,7 @@ function copy_to_trans(&$supp_trans) $supp_trans->due_date = $_POST['due_date']; $supp_trans->supp_reference = $_POST['supp_reference']; $supp_trans->reference = $_POST['reference']; + $supp_trans->ex_rate = input_num('_ex_rate', null); $supp_trans->ov_amount = $supp_trans->ov_discount = 0; /* for starters */ if (isset($_POST['mantax'])) { diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 4fa13ab..5f09dc1 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -26,6 +26,7 @@ function copy_from_cart() $_POST['Comments'] = $cart->Comments; $_POST['StkLocation'] = $cart->Location; $_POST['delivery_address'] = $cart->delivery_address; + $_POST['_ex_rate'] = $cart->ex_rate; foreach($cart->tax_overrides as $id => $value) $_POST['mantax'][$id] = price_format($value); } @@ -43,6 +44,8 @@ function copy_to_cart() $cart->Comments = $_POST['Comments']; $cart->Location = $_POST['StkLocation']; $cart->delivery_address = $_POST['delivery_address']; + $cart->ex_rate = input_num('_ex_rate', null); + if (isset($_POST['mantax'])) { foreach($_POST['mantax'] as $id => $tax) { $cart->tax_overrides[$id] = user_numeric($_POST['mantax'][$id]); } @@ -113,7 +116,7 @@ function display_po_header(&$order) $editable = ($order->order_no == 0); - start_outer_table(TABLESTYLE2, "width=80%"); + start_outer_table(TABLESTYLE2, 'width=80%'); table_section(1); if ($editable) @@ -148,6 +151,18 @@ function display_po_header(&$order) } set_global_supplier($_POST['supplier_id']); + date_row($order->trans_type==ST_PURCHORDER ? _("Order Date:") : + ($order->trans_type==ST_SUPPRECEIVE ? _("Delivery Date:") : _("Invoice Date:")), + 'OrderDate', '', true, 0, 0, 0, null, true); + + if (isset($_POST['_OrderDate_changed'])) { + $order->orig_order_date = $_POST['OrderDate']; + get_duedate_from_terms($order); + $_POST['due_date'] = $order->due_date; + $Ajax->activate('due_date'); + } + supplier_credit_row($order->supplier_id, $order->credit); + if (!is_company_currency($order->curr_code)) { label_row(_("Supplier Currency:"), $order->curr_code); @@ -155,8 +170,6 @@ function display_po_header(&$order) $_POST['OrderDate']); } - supplier_credit_row($order->supplier_id, $order->credit); - if ($editable) { @@ -170,26 +183,6 @@ function display_po_header(&$order) table_section(2); - // check this out????????? - //if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") - // $_POST['OrderDate'] = $order->orig_order_date; - //if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") - //{ - // $_POST['OrderDate'] = Today(); - // if (!is_date_in_fiscalyear($_POST['OrderDate'])) - // $_POST['OrderDate'] = end_fiscalyear(); - //} - date_row($order->trans_type==ST_PURCHORDER ? _("Order Date:") : - ($order->trans_type==ST_SUPPRECEIVE ? _("Delivery Date:") : _("Invoice Date:")), - 'OrderDate', '', true, 0, 0, 0, null, true); - - if (isset($_POST['_OrderDate_changed'])) { - $order->orig_order_date = $_POST['OrderDate']; - get_duedate_from_terms($order); - $_POST['due_date'] = $order->due_date; - $Ajax->activate('_ex_rate'); - $Ajax->activate('due_date'); - } if ($order->trans_type==ST_SUPPINVOICE) date_row(_("Due Date:"), 'due_date', '', false, 0, 0, 0, null, true); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index eb0f56a..ec03796 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -475,6 +475,7 @@ function handle_commit_order() $total += isset($taxitem['Override']) ? $taxitem['Override'] : $taxitem['Value']; } } + $inv->ex_rate = $cart->ex_rate; $inv_no = add_supp_invoice($inv); commit_transaction(); // save PO+GRN+PI diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index 3d09c3d..f80130e 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -266,6 +266,7 @@ function process_receive_po() $grn->orig_order_date = $_POST['DefaultReceivedDate']; $grn->reference = $_POST['ref']; $grn->Location = $_POST['Location']; + $grn->ex_rate = input_num('_ex_rate', null); $grn_no = add_grn($grn); @@ -325,7 +326,7 @@ if (isset($_POST['ProcessGoodsReceived'])) start_form(); -display_grn_summary($_SESSION['PO'], true); +edit_grn_summary($_SESSION['PO'], true); display_heading(_("Items to Receive")); display_po_receive_items();