1 (edited by aleifuuwork 09/06/2019 09:46:38 am)

Topic: Inventory Adjustment bug / error when trying to adjust 0 end balance

Hi everyone,


My current version is 2.4.3 Build 09.12.2017
Haven't had time to do upgrade to latest version yet

I notice this issue as I am doing some data migration onto our current FA system. It's mostly just about giving same item different category name just to better our reporting organization



How would you go move one item to different category btw ?

For example, we have item 'bread' that previously on category 'raw material', now it becomes 'finished good' because we just want to sell it as it is

The bread having ending balance 12 unit in this case

I find it can be done in 2 steps with IA operation :

Step 1
-------
Do Negative Inventory Adjustment of that item /w old category to 0
So you go -12 unit

Step 2
-------
Set the item and set to new category
Do Positive Inventory Adjustment of the same item set to new category to whatever the original balance was, which in this case +12 unit

Can anyone suggest simpler method ? I am open to that too



Now, the bug / error that I notice is that when the ending balance is something like of this value or decimal format : 27,328.2900

In this case, I can't do negative inventory adjustment of -27,328.2900 because FA will complain that there will be not enough stock

The most I can do is 27,328.2899

Anyone could perhaps point what code I should be looking or why is that ? how would you treat the remaining 0.0001 ?

innovation-driven technology

Re: Inventory Adjustment bug / error when trying to adjust 0 end balance

I don't know how anyone else does it, but I found that decimal precise stock quantities cause problems in FA because it is impossible to get them zeroed out.

So I had to make the following change to my fork.  My fork assumes stock is zero when it falls below the precision specified in Setup.

--- a/core/includes/db/inventory_db.inc
+++ b/core/includes/db/inventory_db.inc
@@ -79,7 +79,8 @@ function check_negative_stock($stock_id, $delta_qty, $location=null, $date=null)
        if ($min_qos && ($min_qos['qty'] < $qos['qty']))
                $qos = $min_qos;
 
-       return  -$delta_qty > $qos['qty'] ? $qos : null;
+        $row = get_item_edit_info($stock_id);
+       return  round($delta_qty + $qos['qty'], $row['decimals']) < 0 ? $qos : null;
 }