Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0043750Openbravo ERP03. Procurement managementpublic2020-04-16 11:302020-04-16 12:22
santi_lozano 
Triage Omni OMS 
normalminoralways
newopen 
5
 
 
Core
No
0043750: Exchanged values on variables QtyDelivered and QtyInvoiced at function c_order_post1 but without more affections
The function c_order_post1 has a part in which it calculates the QtyDelivered and QtyInvoiced taking those values exchanged. This doesn't get further affection on code as it is only used to calculate the greatest value of both later.
But maybe on further implementations of code this variables could be wrongly used.
It is part of the code that calculates the difference between the ordered and received/delivered quantities and updates the m_storage_pending. Concretely the "if" part for purchase orders.
1) Check how those variables are gotten

                COALESCE((SELECT SUM(CASE WHEN M_MATCHPO.M_INOUTLINE_ID IS NULL THEN M_MATCHPO.QTY ELSE 0 END)
                FROM M_MATCHPO
                WHERE M_MATCHPO.C_ORDERLINE_ID=C_ORDERLINE.C_ORDERLINE_ID), 0) AS QtyDelivered,
        COALESCE((SELECT SUM(CASE WHEN M_MATCHPO.C_INVOICELINE_ID IS NULL THEN M_MATCHPO.QTY ELSE 0 END)
                FROM M_MATCHPO
                WHERE M_MATCHPO.C_ORDERLINE_ID=C_ORDERLINE.C_ORDERLINE_ID), 0) AS QtyInvoiced

2) Check how those variables are used to calculate the higher amount of both later
->A:
v_QtyOrdered := COALESCE(CASE WHEN (Cur_Inventory.QtyDelivered < 0) THEN LEAST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) ELSE CASE WHEN (Cur_Inventory.QtyDelivered = 0) THEN Cur_Inventory.QtyInvoiced ELSE GREATEST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) END END, 0);
->B:
ELSE (COALESCE(c_uom_convert((CASE WHEN (Cur_Inventory.QtyDelivered < 0) THEN LEAST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) ELSE GREATEST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) END)

3) One can also check it functionally, create a purchase order, with two lines (example one qty=10 and other qty=5), create a goods receipt for one line and a purchase invoice for the other, then run the query on database of step 1 for the c_orderline_id (see attached images for a similar example)
Instead of "is null" use "is not null" on the first two select
No tags attached.
png 15574 - 001 .png (132,764) 2020-04-16 11:37
https://issues.openbravo.com/file_download.php?file_id=14319&type=bug
png

png 15574 - 002 .png (108,950) 2020-04-16 11:37
https://issues.openbravo.com/file_download.php?file_id=14320&type=bug
png

png 15574 - 003 .png (67,547) 2020-04-16 11:37
https://issues.openbravo.com/file_download.php?file_id=14321&type=bug
png

png 15574 - 004 .png (86,240) 2020-04-16 11:37
https://issues.openbravo.com/file_download.php?file_id=14322&type=bug
png
Issue History
2020-04-16 11:30santi_lozanoNew Issue
2020-04-16 11:30santi_lozanoAssigned To => Triage Finance
2020-04-16 11:30santi_lozanoModules => Core
2020-04-16 11:30santi_lozanoTriggers an Emergency Pack => No
2020-04-16 11:35santi_lozanoSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20791#r20791
2020-04-16 11:37santi_lozanoFile Added: 15574 - 001 .png
2020-04-16 11:37santi_lozanoFile Added: 15574 - 002 .png
2020-04-16 11:37santi_lozanoFile Added: 15574 - 003 .png
2020-04-16 11:37santi_lozanoFile Added: 15574 - 004 .png
2020-04-16 11:39santi_lozanoSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20792#r20792
2020-04-16 12:22santi_lozanoSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20793#r20793

There are no notes attached to this issue.