From b2026777331330dc9d55f6575084bb9a7f747622 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Wed, 17 Jun 2009 22:52:18 +0000 Subject: [PATCH] Better support for conversion_factor in Purchasing Pricing. Instruction on Sticky Inventory Forum. --- CHANGELOG.txt | 6 ++++++ inventory/purchasing_data.php | 8 +++++--- purchasing/includes/purchasing_db.inc | 17 +++++++++++++++++ purchasing/includes/ui/po_ui.inc | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8437603..6134a6e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,12 @@ Legend: ! -> Note $ -> Affected files +18-Jun-2009 Joe Hunt +! Better support for conversion_factor in Purchasing Pricing. Instruction on Sticky Inventory Forum. +$ /inventory/purchasing_data.php + /purchasing/includes/purchasing_db.inc + /purchasing/includes/ui/po_ui.inc + 17-Jun-2009 Janusz Dobrowolski # Fixed form reset after error, allowed png logo files. $ /admin/company_preferences.php diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 85e8ade..c545beb 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -151,10 +151,10 @@ else } else { - start_table("$table_style width=60%"); + start_table("$table_style width=65%"); $th = array(_("Supplier"), _("Price"), _("Currency"), - _("Supplier's Unit"), _("Supplier's Description"), "", ""); + _("Supplier's Unit"), _("Conversion Factor"), _("Supplier's Description"), "", ""); table_header($th); @@ -168,6 +168,7 @@ else amount_cell($myrow["price"]); label_cell($myrow["curr_code"]); label_cell($myrow["suppliers_uom"]); + qty_cell($myrow['conversion_factor'], false, user_exrate_dec()); label_cell($myrow["supplier_description"]); edit_button_cell("Edit".$myrow['supplier_id'], _("Edit")); delete_button_cell("Delete".$myrow['supplier_id'], _("Delete")); @@ -207,7 +208,7 @@ if ($Mode =='Edit') $_POST['conversion_factor'] = exrate_format($myrow["conversion_factor"]); } -echo "
"; +br(); hidden('selected_id', $selected_id); start_table($table_style2); @@ -219,6 +220,7 @@ if ($Mode == 'Edit') else { supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true); + $_POST['price'] = $_POST['suppliers_uom'] = $_POST['conversion_factor'] = $_POST['supplier_description'] = ""; } amount_row(_("Price:"), 'price', null,'', get_supplier_currency($selected_id)); text_row(_("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51); diff --git a/purchasing/includes/purchasing_db.inc b/purchasing/includes/purchasing_db.inc index 7236962..da03835 100644 --- a/purchasing/includes/purchasing_db.inc +++ b/purchasing/includes/purchasing_db.inc @@ -62,6 +62,23 @@ function get_purchase_price($supplier_id, $stock_id) } } +function get_purchase_conversion_factor($supplier_id, $stock_id) +{ + $sql = "SELECT conversion_factor FROM ".TB_PREF."purch_data + WHERE supplier_id = '" . $supplier_id . "' + AND stock_id = '". $stock_id . "'"; + $result = db_query($sql, "The supplier pricing details for " . $stock_id . " could not be retrieved"); + + if (db_num_rows($result) == 1) + { + $myrow = db_fetch($result); + return $myrow['conversion_factor']; + } + else + { + return 1; + } +} //---------------------------------------------------------------------------------------- function get_purchase_data($supplier_id, $stock_id) diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 2b3d639..a815c3a 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -76,6 +76,7 @@ function display_po_header(&$order) foreach ($order->line_items as $line_no=>$item) { $line = &$order->line_items[$line_no]; $line->price = get_purchase_price ($order->supplier_id, $_POST['stock_id']); + $line->quantity = get_purchase_conversion_factor ($order->supplier_id, $_POST['stock_id']); } $Ajax->activate('items_table'); } @@ -310,7 +311,7 @@ function po_item_controls(&$order, $stock_id=null) $_POST['units'] = $item_info["units"]; $dec = $item_info["decimals"]; - $_POST['qty'] = number_format2(1, $dec); + $_POST['qty'] = number_format2(get_purchase_conversion_factor ($order->supplier_id, $_POST['stock_id']), $dec); $_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id'])); $_POST['req_del_date'] = add_days(Today(), 10); } -- 2.30.2