Topic: Partial Delivery - insufficient quantity - Bug?

I have a customer order for 10 items, and I have 2 in stock.  When I try to deliver the 2 and Place Delivery, I get an error that there isn't enough quantity in stock.

Tracing through the code, I found in customer_delivery.inc it checks $_SESSION['items']->check_qoh which ultimately calls check_negative_stock (cart_class.inc). 

For the quantity for check_negative_stock (line 568) it uses $line_item->quantity.  I suggest it should be using $line_item->qty_dispatched.  This way it is checking for the amount I am trying to deliver, rather than the amount that is not yet delivered.

Have I understood the variables correctly?  Also, are there any side effects from making this change that I may not be aware of?

Re: Partial Delivery - insufficient quantity - Bug?

@joe: while fixing this check on any alert thresholds to inform the user that the remaining is out of stock.

Hope you had enabled the config variable to allow negative stock.

Re: Partial Delivery - insufficient quantity - Bug?

Hi apmuthu,

I am pretty sure that allow negative stock is off.  However, I show 2 as in stock in FA, and I was trying to deliver 2 so the final stock count would not have been negative. 

If I understood the logic in the functions correctly, it was assuming I was delivering all 10 that the customer had ordered when I was trying to deliver the 2 on hand, and leave 8 on back order until the next shipment from my supplier comes in.  I do remember that I had the "leave on backorder" dropdown selected during the delivery process.

I did not do a dependencies check to see what other functions use the check_negative_stock hence one reason for asking about side effects to making that change long term.

Re: Partial Delivery - insufficient quantity - Bug?

@Iraserks

If you haven't marked 'Allow Negative Stock', you will get the allowed items as default and a warning that there is insuffient stock for the delivery. That means that you could not deliver all of it and you are allowed to deliver the default items (those in stock)..
I had no problems saving this delivery with available stock.

/Joe

Re: Partial Delivery - insufficient quantity - Bug?

fraserks wrote:

For the quantity for check_negative_stock (line 568) it uses $line_item->quantity.  I suggest it should be using $line_item->qty_dispatched.  This way it is checking for the amount I am trying to deliver, rather than the amount that is not yet delivered.

I'm not sure what you mean. In cart::check_qoh() $line_item->qty_dispatched is used, and it is about line 588. Which FA version you have installed?

Janusz

Re: Partial Delivery - insufficient quantity - Bug?

Everything works as expected. See attachment with files in transaction sequence.

Post's attachments

Part Delivery from Stock and Inv.zip 100.9 kb, 3 downloads since 2017-10-27 

You don't have the permssions to download the attachments of this post.