Topic: Purchase order updating issue
Hi,
I encountered a scenario and reported it in Mantis.
Refer the bug here
http://mantis.frontaccounting.com/view.php?id=183
1. Entered a PO for item A (Single Line) - Quantity - 100
2. Modified the PO and set item quantity to 0 (Single item line with order quantity 0)
3. Again updated the PO and set quantity for item to - 50
Then while receiving the delivery, a false message is encountered which is not going.
This order has been changed or invoiced since this delivery was started to be actioned. Processing halted. To enter a delivery against this purchase order, it must be re-selected and re-read again to update the changes made by the other user.
What went wrong -
Step 2 should not have been accepted in first place !) One should be forced to cancel order in such case !
I check the procedure function check_po_changed() from purchasing/po_receive_items.php
The reason of the error was due to abovesaid modifications
xx_purch_order_details table has 2 entries for same item 1 with quantity_ordered = 0 and other with quantity_ordered = 50
This resulted in mismatch in function check_po_changed() as line with quantity_ordered = 0 was not having match in session[PO]->lines
Thus resulting in error !
A temporary work around applied -
In function check_po_changed()
$sql = "SELECT item_code, quantity_ordered, quantity_received, qty_invoiced
FROM ".TB_PREF."purch_order_details
WHERE order_no=".db_escape($_SESSION['PO']->order_no)
." ORDER BY po_detail_item";
is changed to
// Chaitanya 18-Dec-09 Consider only quantity_ordered != 0
$sql = "SELECT item_code, quantity_ordered, quantity_received, qty_invoiced
FROM ".TB_PREF."purch_order_details
WHERE order_no=".db_escape($_SESSION['PO']->order_no)
." and quantity_ordered != 0 ORDER BY po_detail_item";
This solved the issue but I doubt the approach. We may even continue with this but better if we can disallow a user to add 0 quantity while updating.
We may need to recheck - function handle_update_item() and function check_data()
You are best judge to decide on the exact changes required.
Thanks