Anonymous | Login
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] 03. Procurement managementmajoralways2020-01-06 17:352020-03-20 17:54
ReporteragonzalezView Statuspublic 
Assigned ToAtulOpenbravo 
PriorityhighResolutionfixedFixed in Version3.0PR20Q2
StatusclosedFix in branchFixed in SCM revisiond70bc108e8d2
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product Version3.0PR18Q3.3SCM revision 
Review Assigned Todmiguelez
Web browserGoogle Chrome
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo

0042702: Rounding problem on posting matched invoices in certain cases when the result has an inifinite number of decimals

DescriptionThere is a problem while calculating the expenses of the transaction being posted. When the movement quantity of the goods receipt, the quantity invoiced of the invoice and the line net amount of the first line contains certain values, it could happen that the result of the calculation of the expenses generates a result with infinite results, causing a ArithmeticException as there is not a RoundingMode defined.

Please find attached a copy of the generated exception and follow the specified steps to reproduce, as this problems can be reproduced only certain conditions.

The code fragment that needs to be changed is on the DocMatchInv class and you will find a patch attached to the issue that seems to solve the problem.
Steps To Reproduce-----------------------
* The currency used for the invoice must have a price precision of 4


1. Create an invoice and add a line, with a product that contains "150452" as invoiced quantity and "1.059" as net unit price. (Process the invoice)

2. At this point, the line net amount for the created line should be "159,328.67"

3. Create a goods receipt, and copy the lines from the created invoice, and in the movement quantity, set the following quantity: "4156" (Process the goods receipt)

4. Go to the matched invoices window and find the recently created invoice associated with the recently created goods receipt.

5. Click on "Post". An error will be displayed: "Process failed during execution" and an exception log will be generated on the openbravo log. You will find the generated exception on the attached files.

NOTE: This case could be repeated with another quantities if the result of the following operation returns a result with infinite decimals: (line net amount * movement quantity) / quantity invoiced
Proposed SolutionAdd a rounding mode to the line in the DocMatchInv where the expenses are calculated. A patch was uploaded.
TagsNo tags attached.
Attached Filespatch file icon patch_rounding.patch [^] (675 bytes) 2020-01-06 17:35 [Show Content]
? file icon RoundingProblem.clear [^] (4,298 bytes) 2020-01-06 17:36

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
AtulOpenbravo (developer)
2020-01-24 05:58
edited on: 2020-01-24 05:59

Test Plan

- Login as System Admin
- Navigate to Currency window, select current EUR and set Price Precision as 4
- Log Out.

In Format.xml, set

<Number name="priceInform"
       decimal="." grouping="," formatOutput="#,##0.000" formatInternal="#0.000" />
   <Number name="priceRelation"
       decimal="." grouping="," formatOutput="#,##0.000" formatInternal="#0.000" />
   <Number name="priceEdition"
       decimal="." grouping="," formatOutput="#0.000" formatInternal="#0.000" />

<Number name="amountInform"
       decimal="." grouping="," formatOutput="#,##0.000" formatInternal="#0.000" />

- Run ant smartbuild

- Login as F&B International Group Admin
- Navigate to Purchase Invoice Window
- Create Purchase Invoice in F&B Espana Org, Bebidas Alegres, S.L. business partner.
- Create a Line for Product:Cerveza Ale 0,5L, Quantity = 150452, Price = 1.059
- Realize that Line Net amount is set 159328.67
- Complete Invoice.
- Navigate to Goods Receipt Window
- Create a Goods Receipt in F&B Espana Org, Bebidas Alegres, S.L. business partner.
- Using Create Lines from, select previously created purchase invoice in the Invoice Selector
- Realize that Line for Product Cerveza Ale 0,5L is loaded.
- Select the line, set Quantity to 4156, Storage Bin = RN-0-0-0
- Click on OK button.
- Complete the Goods Receipt.
- Schedule Costing Background process so that cost is calculated for related transactions.
- Navigate to Matched Invoice window and select the one which is linked with above Purchase Invoice Line and Goods Receipt Line.
- Post the record, Realize that posting is successful. (If there is error Account not found error then Navigate to product: Cerveza Ale 0,5L, Accounting Tab: set Invoice Price Variance account to some account to avoid error )
- Posting is as below:-


2120---Goods Received and not invoiced--6,386.94--Debit
5360---Product Expense------------------------6,386.94--Credit

hgbot (developer)
2020-01-31 08:30

Repository: erp/devel/pi
Changeset: d70bc108e8d238c04608becfab7b6854eec68b1a
Author: Atul Gaware <atul.gaware <at>>
Date: Fri Jan 24 10:32:04 2020 +0530
URL: [^]

Fixes BUG-42702:Rounding problem on posting matched invoices
in certain cases when the result has an inifinite number of

To avoid java.lang.ArithmeticException: Non-terminating
decimal expansion; no exact representable decimal result
use RoundingMode HALF_UP when doing a BigDecimal Division

M src/org/openbravo/erpCommon/ad_forms/
hgbot (developer)
2020-01-31 08:30

Repository: erp/devel/pi
Changeset: c95107ddf37c29e4e3a2d8963bb7ec2450f7c534
Author: Atul Gaware <atul.gaware <at>>
Date: Fri Jan 24 11:50:32 2020 +0530
URL: [^]

Related To ISSUE-42702:Apply sonarlint suggestions

- Use built-in formatting to construct argument for log4jDocMatchInv.debug
- Use isEmpty() instead of MaterialMgmtMaterialTransactionList().size()
- Only the sign of the result should be examined when checking condition
lineAmount.compareTo(BigDecimal.ZERO) == 1
- Remove the literal "true" boolean value when using ternary operator
strIsSOTrx.equalsIgnoreCase("Y") ? true : false
- Use the opposite operator ("!=") instead in if condition
!(linenetamt.compareTo(BigDecimal.ZERO) == 0
- Remove useless assignment to local variable lineAmount, bdCost
- Add error log when getting std precision from invoice currency.
- "formatDate" returns a string, there's no need to call toString().
- Declare variable cr and diff on separate lines.
- Rename local variable Fact_Acct_Group_ID as factAcctGroupId,
LineNetAmt as lineNetAmt, PriceList as priceList,
AD_Client_ID as adClientId, AD_Org_ID as adOrgId,
p_inOutlines as pinOutlines, SeqNo as seqNum
names to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
- Immediately return ZERO expression instead of assigning it
to the temporary variable "retValue".
- Return an empty array DocLine[0] instead of null.

M src/org/openbravo/erpCommon/ad_forms/
dmiguelez (developer)
2020-01-31 08:31

Code Review + Testing Ok
hgbot (developer)
2020-01-31 09:29

Repository: erp/devel/pi
Changeset: 1f3682a60c1cb3d91648e2edafe78df4aec72551
Author: David Miguelez <david.miguelez <at>>
Date: Fri Jan 31 09:29:36 2020 +0100
URL: [^]

Related To ISSUE 42702. Removed unnecessary supress warnings since the
parameter name is no longer the same as the class variable name of the
parent class

M src/org/openbravo/erpCommon/ad_forms/
hudsonbot (developer)
2020-03-20 17:54

A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: [^]
Maturity status: Test

- Issue History
Date Modified Username Field Change
2020-01-06 17:35 agonzalez New Issue
2020-01-06 17:35 agonzalez Assigned To => Triage Finance
2020-01-06 17:35 agonzalez File Added: patch_rounding.patch
2020-01-06 17:35 agonzalez Web browser => Google Chrome
2020-01-06 17:35 agonzalez Modules => Core
2020-01-06 17:35 agonzalez Triggers an Emergency Pack => No
2020-01-06 17:36 agonzalez File Added: RoundingProblem.clear
2020-01-20 13:37 ngarcia Web browser Google Chrome => Google Chrome
2020-01-22 09:17 ngarcia Web browser Google Chrome => Google Chrome
2020-01-22 09:17 ngarcia Priority normal => high
2020-01-22 09:17 ngarcia Severity minor => major
2020-01-22 11:04 dmiguelez Assigned To Triage Finance => AtulOpenbravo
2020-01-23 08:08 AtulOpenbravo Status new => scheduled
2020-01-24 05:58 AtulOpenbravo Note Added: 0117209
2020-01-24 05:59 AtulOpenbravo Note Edited: 0117209 View Revisions
2020-01-24 05:59 AtulOpenbravo Note Edited: 0117209 View Revisions
2020-01-31 08:30 hgbot Checkin
2020-01-31 08:30 hgbot Note Added: 0117387
2020-01-31 08:30 hgbot Status scheduled => resolved
2020-01-31 08:30 hgbot Resolution open => fixed
2020-01-31 08:30 hgbot Fixed in SCM revision => [^]
2020-01-31 08:30 hgbot Checkin
2020-01-31 08:30 hgbot Note Added: 0117388
2020-01-31 08:31 dmiguelez Review Assigned To => dmiguelez
2020-01-31 08:31 dmiguelez Note Added: 0117389
2020-01-31 08:31 dmiguelez Status resolved => closed
2020-01-31 08:31 dmiguelez Fixed in Version => 3.0PR20Q2
2020-01-31 09:29 hgbot Checkin
2020-01-31 09:29 hgbot Note Added: 0117396
2020-03-20 17:54 hudsonbot Checkin
2020-03-20 17:54 hudsonbot Note Added: 0118736

Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker