Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0014920Openbravo ERP07. Sales managementpublic2010-10-19 16:112010-12-09 16:07
rafaroda 
adrianromero 
highmajoralways
closedfixed 
20Community Appliance
pi 
2.50MP24 
Core
No
0014920: Wrong Net Unit Price when Line Net Amount is edited
Net Unit Price is wrongly calculated when Line Net Amount is edited.
1) Create a Sales Invoice header.
2) Create a Sales Invoice line with product = Donuts and Select a Tax. Save the record.
3) Change invoiced quantity to 26. Save the record.
4) Click on Edit Line Net Amount. Save the record.
5) Change Line Net Amount to 27 and try to save the record.

ERROR displayed: Line Amount Is Not Correct
No tags attached.
related to defect 0015059 closed dalsasua Modules decimals error to edit Gross Unit Price 
Issue History
2010-10-19 16:11rafarodaNew Issue
2010-10-19 16:11rafarodaAssigned To => adrianromero
2010-10-19 16:13rafarodaIssue Monitored: rafaroda
2010-10-19 17:18networkbIssue Monitored: networkb
2010-10-20 09:01rafarodaNote Added: 0031996
2010-10-21 09:13jonalegriaesarteTarget Version => 2.50MP24
2010-11-10 10:55hgbotCheckin
2010-11-10 10:55hgbotNote Added: 0032528
2010-11-10 10:55hgbotStatusnew => resolved
2010-11-10 10:55hgbotResolutionopen => fixed
2010-11-10 10:55hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/54eb8122cee0e6d2928032b362ce28e54a9c9944 [^]
2010-11-10 11:27sivaramanNote Added: 0032535
2010-11-10 12:53psarobeNote Added: 0032538
2010-11-10 12:53psarobeStatusresolved => new
2010-11-10 12:53psarobeResolutionfixed => open
2010-11-10 13:02psarobeNote Deleted: 0032538
2010-11-10 13:02psarobeStatusnew => scheduled
2010-11-10 13:02psarobefix_in_branch => pi
2010-11-10 13:02psarobeStatusscheduled => resolved
2010-11-10 13:02psarobeResolutionopen => fixed
2010-11-10 13:14rafarodaRelationship addedrelated to 0015059
2010-11-10 20:06hudsonbotCheckin
2010-11-10 20:06hudsonbotNote Added: 0032544
2010-11-12 09:46sureshbabuNote Added: 0032576
2010-11-12 09:46sureshbabuStatusresolved => closed
2010-11-12 10:24adrianromeroNote Added: 0032578
2010-11-12 10:24adrianromeroStatusclosed => new
2010-11-12 10:24adrianromeroResolutionfixed => open
2010-11-12 10:25adrianromeroNote Added: 0032579
2010-11-15 05:34hgbotCheckin
2010-11-15 05:34hgbotNote Added: 0032606
2010-11-15 05:34hgbotStatusnew => resolved
2010-11-15 05:34hgbotResolutionopen => fixed
2010-11-15 05:34hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/54eb8122cee0e6d2928032b362ce28e54a9c9944 [^] => http://code.openbravo.com/erp/devel/pi/rev/3e0886948e278090d12f46e270373c3b4be0a772 [^]
2010-11-15 05:47sivaramanNote Added: 0032607
2010-11-15 15:40hudsonbotCheckin
2010-11-15 15:40hudsonbotNote Added: 0032615
2010-11-17 06:34sureshbabuNote Added: 0032652
2010-11-17 06:34sureshbabuStatusresolved => closed
2010-12-09 16:07anonymoussf_bug_id0 => 3133523

Notes
(0031996)
rafaroda   
2010-10-20 09:01   
Take care with this division https://code.openbravo.com/erp/devel/pi/file/tip/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java#l127 [^]

priceActual = LineNetAmt.divide(qtyInvoice, PricePrecision, BigDecimal.ROUND_HALF_UP);

There should be a check for the value of qtyInvoice to avoid a division by zero:

if (qtyInvoice.compareTo(BigDecimal.ZERO) == 0)
   priceActual = BigDecimal.ZERO;
else
   priceActual = LineNetAmt.divide(qtyInvoice, PricePrecision, BigDecimal.ROUND_HALF_UP);
(0032528)
hgbot   
2010-11-10 10:55   
Repository: erp/devel/pi
Changeset: 54eb8122cee0e6d2928032b362ce28e54a9c9944
Author: Sivaraman Rajagopal <sivaraman.rajagopal <at> openbravo.com>
Date: Wed Nov 10 15:23:10 2010 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/54eb8122cee0e6d2928032b362ce28e54a9c9944 [^]

Fixes issue 14920: Wrong Net Unit Price when Line Net Amount is edited

Line Net Amount is re-calculated, multiplying invoice quantity with actual price, in order to get below condition passed.

Line Net Amount == (price actual * invoice quantity)

i.e,

invoice quantity = 26
actual price = 1.04

If Net Amount is changed to 27 and invoice, it will be re-calculated as 27.04. Thus, we can get check passed in trigger and avoid error message

---
M src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java
---
(0032535)
sivaraman   
2010-11-10 11:27   
Pre-requisition:
Make sure output format of price edition is "#0.00" in Format.xml

Steps to test:

1. Log on to Openbravo with Admin role
2. Go to Sales Management || Transactions || Sales Invoice
3. Create Header
4. Create a line with product = Donuts and Save the record
5. Change invoiced quantity to 26 and Save the record
6. Click on Edit Line Net Amount and Save the record
7. Change Line Net Amount to 27 and verify if record is successfully saved with following values
   Net Unit Price = 1.04
   Line Net Amount = 27.04

Note:
Change Line Net Amount with many different values and verify if it can be saved with re-calculated values. Also modify the output format of price edition as "#0.000" in Format.xml and verify the same behavior in saving invoice lines.
(0032544)
hudsonbot   
2010-11-10 20:06   
A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/54eb8122cee0 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/9c2b09096a6d [^]
Tests: http://builds.openbravo.com/view/int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.18851.obx [^]
(0032576)
sureshbabu   
2010-11-12 09:46   
verified, now when i change the Line net amount to 27 it changes to 27.04
(0032578)
adrianromero   
2010-11-12 10:24   
In order to make the fix consistent with the behavior implemented in other areas related to the same situation. This issue has to be resolved again.
(0032579)
adrianromero   
2010-11-12 10:25   
The approach that has to be implemented is the same behavior implemented in the related issue 15059.

It will also be fixed the possible division by zero error described in the note: https://issues.openbravo.com/view.php?id=14920#c31996 [^]
(0032606)
hgbot   
2010-11-15 05:34   
Repository: erp/devel/pi
Changeset: 3e0886948e278090d12f46e270373c3b4be0a772
Author: Sivaraman Rajagopal <sivaraman.rajagopal <at> openbravo.com>
Date: Mon Nov 15 10:03:21 2010 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/3e0886948e278090d12f46e270373c3b4be0a772 [^]

Fixes issue 14920: Wrong Net Unit Price when Line Net Amount is edited

Line Net Amount is re-calculated, multiplying invoice quantity with actual price, in order to check below condition. Message will be thrown if it fail

Line Net Amount == (price actual * invoice quantity)

---
M src-db/database/sourcedata/AD_MESSAGE.xml
M src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java
---
(0032607)
sivaraman   
2010-11-15 05:47   
Pre-requisition:
Make sure output format of price edition is "#0.00" in Format.xml

Steps to test:

1. Log on to Openbravo with Admin role
2. Go to Sales Management || Transactions || Sales Invoice
3. Create Header
4. Create a line with product = Donuts and Save the record
5. Change invoiced quantity to 26 and Save the record
6. Click on Edit Line Net Amount and Save the record
7. Change Line Net Amount to 27 and verify if message is shown suggesting re-calculated amount i.e, 27.04
8. Now, change Line Net Amount to 27.04 (suggested amount) and verify if it can be successfully saved

Note:
Change Line Net Amount with many different values and verify if it can be saved with re-calculated values. Also modify the output format of price edition as "#0.000" in Format.xml and verify the same behavior in saving invoice lines.
(0032615)
hudsonbot   
2010-11-15 15:40   
A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/3e0886948e27 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/2dbba9a7d6a0 [^]
Tests: http://builds.openbravo.com/view/int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.18900.obx [^]
(0032652)
sureshbabu   
2010-11-17 06:34   
verified, still the information message needs to be fine tuned.