Topic: Different Service Item Description From Same Vendor?

I have a service item setup for office supplies which is set to allow editing the description. This seemed to work out initially, but am running into an issue:

  I previously purchased tape from supplier "A" which is used in the office so I used my OSUPPLY item on the purchase order and changed the description to "Tape". This worked.

  Now, I need to purchase printer ink from the same supplier, "A", so I use my OSUPPLY item and change the description to "Printer Ink". All seems well, until I print the purchase order and it has "Tape" as the description although the cost is correct for the ink. I then opened the ink PO to edit which now shows "Tape" as the description. I edit the line and rename it "Printer Ink" and confirm the changes. It looks right, so I Update Order. If I reopen or print, the description is back to "Tape".

  Looking into the database, purch_order_details table and the new PO description is "Printer Ink". If I go in to the OSUPPLY item's Purchasing Price tab and remove the price line for the Tape, the PO for the ink prints correctly. It would be nice to keep the price line for the tape so I know how much I paid the last time.

  Am I using the Service Item incorrectly or outside of it's capabilities? Maybe a bug?

  Thanks!

Re: Different Service Item Description From Same Vendor?

Keep a separate Item for Printer Ink and for Tape.
Editable description is for small variations in Item description for the specific Invoice.

@joe: should we entirely delete all changed descriptions from being remembered except for the specific Invoice/Order and where none, take the default for the item?

Re: Different Service Item Description From Same Vendor?

Thanks Apmuthu. But I have many different items from the same supplier. I was hoping to avoid a different FA Item for each product that fits under office supplies.

Re: Different Service Item Description From Same Vendor?

Or you could change the code to disable the PO description recall if the same item with a different description is used more than once on the PO:

diff --git a/core/purchasing/includes/db/po_db.inc b/core/purchasing/includes/db/po_db.inc
index b13c100..cb00da7 100644
--- a/core/purchasing/includes/db/po_db.inc
+++ b/core/purchasing/includes/db/po_db.inc
@@ -208,7 +208,11 @@ function read_po_items($order_no, &$order, $open_items_only=false)
 {
        /*now populate the line po array with the purchase order details records */
 
-       $sql = "SELECT poline.*, units
+       $sql = "SELECT poline.*, units,
+            (SELECT COUNT(*) 
+                FROM ".TB_PREF."purch_order_details poline2
+                WHERE poline.item_code = poline2.item_code
+                    AND poline.description != poline2.description) AS dup
                FROM ".TB_PREF."purch_order_details poline
                        LEFT JOIN ".TB_PREF."stock_master item  ON poline.item_code=item.stock_id
                WHERE order_no =".db_escape($order_no);
@@ -224,12 +228,14 @@ function read_po_items($order_no, &$order, $open_items_only=false)
     {
                while ($myrow = db_fetch($result))
         {
-               $data = get_purchase_data($order->supplier_id, $myrow['item_code']);
-               if ($data !== false)
-               {
-                       if ($data['supplier_description'] != "")
-                               $myrow['description'] = $data['supplier_description'];
-               }               
+            if ($myrow['dup'] == 0) {
+                $data = get_purchase_data($order->supplier_id, $myrow['item_code']);
+                if ($data !== false)
+                {
+                    if ($data['supplier_description'] != "")
+                        $myrow['description'] = $data['supplier_description'];
+                }              
+            }
             if (is_null($myrow["units"]))
             {
                        $units = "";

Re: Different Service Item Description From Same Vendor?

It is possible to inadvertantly change the description (typo) and the absence of the recall would entail re-entry.

@joe: have a look at @braathwaate's code and see if it is ok to include in the light of accustomed data entry after ignoring whitespace differences.

Re: Different Service Item Description From Same Vendor?

I had the chance to try Braath's mod which allows me to open the PO and it always shows the description I typed in. But when I go to print the PO, it still pulls the description from the item's Purchasing Pricing tab; If there is a supplier by the same name here which has anything other than null in the description field, that is what prints on the PO. If I delete the description in this tab, my PO will print with the new description. As soon as I receive this PO, the description (if blank) is updated in the Purchasing Pricing tab.

  It would be nice to allow multiple supplier entries in the Item's Purchasing Pricing tab as long as the Supplier's Code or Description is unique. I suppose a typo would make for multiple, unwanted entries, too.

  I am tempted to not allow editable description, but then I can't enter the description of the item I actually want.

  Or delete the line in the Purchasing Pricing tab after receiving the PO.

7 (edited by Braath Waate 04/27/2020 11:15:10 am)

Re: Different Service Item Description From Same Vendor?

Thanks for testing this.

Unfortunately my suggested fix was not complete because a lack of code modularity: the print code does not call the underlying base code functions.  This is a bit disconcerting as you found out: viewing or editing a PO does not necessarily produce the same output as printing.   Not only is description is affected, but also units, price, and quantity which could easily lead to surprising results for the purchasing team when changing suppliers.

While I believe the correct fix is to change the print code to call the base function, the bandaid fix is to add the same logic that I suggested for the base code:

diff --git a/core/reporting/rep209.php b/core/reporting/rep209.php
index 2ed8cb8..8b9a15b 100644
--- a/core/reporting/rep209.php
+++ b/core/reporting/rep209.php
@@ -49,7 +49,11 @@ function get_po($order_no)
 
 function get_po_details($order_no)
 {
-       $sql = "SELECT poline.*, units
+       $sql = "SELECT poline.*, units,
+            (SELECT COUNT(*)
+                FROM ".TB_PREF."purch_order_details poline2
+                WHERE poline.item_code = poline2.item_code
+                    AND poline.description != poline2.description) AS dup
                FROM ".TB_PREF."purch_order_details poline
                        LEFT JOIN ".TB_PREF."stock_master item ON poline.item_code=item.stock_id
                WHERE order_no =".db_escape($order_no)." ";
@@ -118,19 +122,21 @@ function print_po()
                $items = $prices = array();
                while ($myrow2=db_fetch($result))
                {
-                       $data = get_purchase_data($myrow['supplier_id'], $myrow2['item_code']);
-                       if ($data !== false)
-                       {
-                               if ($data['supplier_description'] != "")
-                                       $myrow2['description'] = $data['supplier_description'];
-                               if ($data['suppliers_uom'] != "")
-                                       $myrow2['units'] = $data['suppliers_uom'];
-                               if ($data['conversion_factor'] != 1)
-                               {
-                                       $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec());
-                                       $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec());
-                               }
-                       }
+            if ($myrow2['dup'] == 0) {
+                $data = get_purchase_data($myrow['supplier_id'], $myrow2['item_code']);
+                if ($data !== false)
+                {
+                    if ($data['supplier_description'] != "")
+                        $myrow2['description'] = $data['supplier_description'];
+                    if ($data['suppliers_uom'] != "")
+                        $myrow2['units'] = $data['suppliers_uom'];
+                    if ($data['conversion_factor'] != 1)
+                    {
+                        $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec());
+                        $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec());
+                    }
+                }

While I understand your suggestion about allowing additional entries in the purchase data table, this would require a database change and substantive code changes which I really don't think really would be worth the coding and testing effort.

8 (edited by paul 04/26/2020 10:58:13 pm)

Re: Different Service Item Description From Same Vendor?

Thanks Braath. I will try this as soon as I get a chance.

  I understand about the lack of benefit to substantial re-coding.

Another way to work this, I wonder about, is having the option to not record the details found in the Purchasing Pricing tab in the first place. Maybe an option at the Item level? Right now, to solve my immediate need, was to just delete the matching Supplier found in the Purchasing Pricing tab and then print and receive my new item purchase order. I can go in now and delete the new entry in the Purchasing Pricing tab from this receive to prepare for the next time I purchase an office item from this same supplier.

  Would this manual procedure mess up any other FrontAccounting operation or reporting by deleting entries in the Purchasing Pricing tab??

Re: Different Service Item Description From Same Vendor?

I don't like the idea of an option to mask what really is an obscure bug.  Someone else unaware of the option will run into the same problem down the line and spend hours searching for the same solution.  It is better if they never run into the problem into the first place.

Yes, you can workaround the problem the way you did, but the workaround is non-intuitive and distracting.  If it were me, I would just code around it so it never happens again.

Re: Different Service Item Description From Same Vendor?

Braath, is your latest mod for rep209.php? If I read the mod right, it's pointing to cust_trans_db.inc, but that doesn't seem to work for me.

Re: Different Service Item Description From Same Vendor?

Yes, the diff was in error; the mod was for rep209.php. (Stands corrected now).