Better support for conversion_factor in Purchasing Pricing. Instruction on Sticky...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 17 Jun 2009 22:52:18 +0000 (22:52 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 17 Jun 2009 22:52:18 +0000 (22:52 +0000)
CHANGELOG.txt
inventory/purchasing_data.php
purchasing/includes/purchasing_db.inc
purchasing/includes/ui/po_ui.inc

index 8437603cd98c1ab2ebc20980ac189f971ae110d8..6134a6ef5e450f61f822e911748dd385db6ae686 100644 (file)
@@ -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
index 85e8adedc254d2ffeb71bcadf6b303e12ef3314d..c545beb5f902fb7703233b0f71b2d01fbbcc5bf9 100644 (file)
@@ -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>";
+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);
index 7236962fba711561f0594bcd09fde126c7a20a7d..da038358b1faf5fb95d3cf13e42f1745a6112f88 100644 (file)
@@ -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)
index 2b3d639b5d81404ddf11cfde01ab1753d9366061..a815c3a925e643da9a7f3ad967154cfc51978df0 100644 (file)
@@ -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);
        }