Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0045448Openbravo ERP03. Procurement managementpublic2020-11-16 10:242021-11-16 12:30
santi_lozano 
santi_lozano 
highmajoralways
closedout of date 
5
 
 
vmromanos
Core
No
0045448: Incorrect rounding while editing line net amount of a purchase order
Edit a the Line Net Amount of a Purchase Order, to be 20000, it is converted to 20010 (livebuilds)
It is done on c_orderline_trg() line:
new.LineNetAmt := ROUND(new.QtyOrdered*new.PriceActual, v_Prec);

As tested with customer, which they had 19999.99 for this same case

After 1st workaround still happening something similar, review notes section
-go to livebuilds, system admin role
-module window, set Core to be in development
-tables and columns, c_orderline table and for column LineNetAmt change its Read Only Logic to be nothing
-F&B International Group Admin, create a Purchase Order, with a product
-After it's created, modify the line net amount, to be 20000, it gets rounded incorrectly
No tags attached.
png 18910 - reproduced livebuilds.png (160,838) 2020-11-16 10:24
https://issues.openbravo.com/file_download.php?file_id=15091&type=bug
png

? livebuild_linenetamt.mp4 (1,022,335) 2020-12-04 13:25
https://issues.openbravo.com/file_download.php?file_id=15139&type=bug
Issue History
2020-11-16 10:24santi_lozanoNew Issue
2020-11-16 10:24santi_lozanoAssigned To => Triage Finance
2020-11-16 10:24santi_lozanoFile Added: 18910 - reproduced livebuilds.png
2020-11-16 10:24santi_lozanoModules => Core
2020-11-16 10:24santi_lozanoTriggers an Emergency Pack => No
2020-11-18 10:00santi_lozanoResolution time => 1607468400
2020-11-18 10:00santi_lozanoSeverityminor => major
2020-11-18 17:24dmiguelezNote Added: 0124493
2020-11-18 17:24dmiguelezStatusnew => closed
2020-11-18 17:24dmiguelezResolutionopen => unable to reproduce
2020-12-04 13:24santi_lozanoResolution time1607468400 => 1608850800
2020-12-04 13:24santi_lozanoStatusclosed => new
2020-12-04 13:24santi_lozanoDescription Updatedbug_revision_view_page.php?rev_id=21913#r21913
2020-12-04 13:25santi_lozanoFile Added: livebuild_linenetamt.mp4
2020-12-04 13:27santi_lozanoNote Added: 0124715
2020-12-09 09:20AtulOpenbravoStatusnew => scheduled
2020-12-09 09:20AtulOpenbravoAssigned ToTriage Finance => AtulOpenbravo
2020-12-09 16:06AtulOpenbravoNote Added: 0124730
2020-12-11 11:58hgbotNote Added: 0124791
2020-12-15 11:05vmromanosNote Added: 0124822
2020-12-15 11:05vmromanosAssigned ToAtulOpenbravo => santi_lozano
2020-12-15 11:05vmromanosStatusscheduled => feedback
2021-08-23 10:59dmitry_mezentsevReview Assigned To => vmromanos
2021-08-23 10:59dmitry_mezentsevNote Added: 0131261
2021-08-23 10:59dmitry_mezentsevStatusfeedback => closed
2021-08-23 10:59dmitry_mezentsevResolutionunable to reproduce => out of date
2021-11-16 12:30hgbotNote Added: 0133102

Notes
(0124493)
dmiguelez   
2020-11-18 17:24   
Log in as Openbravo

Change Role to System Admin

Go to Tables And Columns window
Select the record with DB Table Name: C_OrderLine
Move to Column Tab
Select the record with DB Column Name: LineNetAmt
Remove the expression from the Read Only Logic field and save

Change the Role to F&B International Group Admin

Go to Purchase Order Window
Create a new record with:
  * Organization: F&B España - Región Norte
  * Business Partner: Bebidas Alegres
Move to Lines Tab and create a new record wiht:
  * Product: Cerveza Ale 0,5L
  * Line Net Amount: 20000
Save the record and validate that the Line Net Amount remains 20000
Complete the Order, the value remains 20000
Modify the value (from a functional point of view this should not be allowed, but the definition change in the first step allows this), the value remains 20000
(0124715)
santi_lozano   
2020-12-04 13:27   
Customer reports that still happens something similar, reproduced on livebuilds (video attached):
1) apply the modifications commented on previous note
2) go to Purchase Order, create a new one for F&B US Org, add a line for Cherry Cola, set Ordered Quantity to be 1000, Line Net Amount to be 220, save it
3) modify Line Net Amount to be 221, save it, it gets saved as 220
(0124730)
AtulOpenbravo   
2020-12-09 16:06   
Test Plan
- Login as System admin
- Navigate to windows tabs field, select Purchase Order window, select Lines Tab record.
- In Field tab, search for field Edit Line Net Amount, set Displayed = Yes

- Logout and login as F&B International Group Admin
- Navigate to Purchase Order window
- Create Header for F&B US Inc organization and Be Soft Drinker, Inc. business partner.
- In Lines select product, Cherry Cola, set quantity 1000, realize that Line Net Amount is set as 550. (Read Only)
- In More Information section, set Edit Line Net Amount as Yes, realise that Line Net Amount is editable.
- Set Line Net Amount as 220.
- Try to re-set it to 221, Information is shown in Message Box as
"Info
It's not correct the amount provided: 221.00. Please consider using 220.00"
- Try to save the record error message is shown as
"Error
Saving failed. Line Amount Is Not Correct"

**Similar flow is tested successfully with Sales Order window.
The solution is implemented to maintain consistency as per Lines Tab "Edit Line Net Amount" field in Sales/Purchase Invoice window.
(0124791)
hgbot   
2020-12-11 11:58   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/258 [^]
(0124822)
vmromanos   
2020-12-15 11:05   
In feedback: ask the customer for the concrete use case.


IMHO we should implement something similar to what we have in Invoice window:

At the lines tab there is a flag called Edit Line Amount (which is hidden by default). If you enable it the Line Net Amount field becomes editable and you can set any amount there. Then there is a callout that tries to adjust the unit price accordingly. If the currency precision allows it, the callout automatically adjusts the unit price. If the currency precision avoids a good calculation, the callout informs the user about that. If the user tries to save the record with a wrong amount, the trigger avoids it.

Let see it with an example (currency precision = 2):
Qty= 1000
Unit price = 0.83
Line net amount (automatically calculated) = 830 (1000*0.83) OK
I set Edit Line Net Amount = Y
I edit the line net amount and set it to 910
The callout automatically changes the unit price to 0.91 (OK)
Now I change the Line Net amount to 911.
The callout informs me that this amount is not valid (as the unit price continues to be 0.91 due to the currency precision), and suggests to set it to 910.
If I try to save the 911 it fails to avoid an inconsistency.


The issue you're reporting is at the Order window. The behavior compared to the Invoice window is almost the same: it doesn't allow you to save wrong amounts. The obvious difference is that there is no callout info, and that the trigger silently rounds the line net amount instead of failing.


My proposal for this issue is to implement exactly the same behavior we showed in Invoice to the Orders, i.e. to have a callout that informs you in case of problems, and a trigger that avoids saving.

What we can't do is to increase the unit price precision to match the line net amount, as this would break the precision model.
(0131261)
dmitry_mezentsev   
2021-08-23 10:59   
No feedback for more than 6 months.
(0133102)
hgbot   
2021-11-16 12:30   
Merge request closed: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/258 [^]