Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0035773Openbravo ERP09. Financial managementpublic2017-04-12 14:062017-04-12 14:07
vmromanos 
Triage Omni OMS 
normaltrivialhave not tried
newopen 
5
 
 
Core
No
0035773: Several improvements in FinancialUtils class
The Taxes Calculation at document level project (0032265) slightly changed the way taxes are calculated to avoid rounding precision issues.
Right now the line net amount is calculated from the line gross amount instead of getting the line net price from the line gross amount and then line net amount from line net price.

The FinancialUtils.calculateNetFromGross() method was deprecated and a new calculateNetAmtFromGross() was created as part of the project.

These two methods are not equivalent, because the first one returns a Price, and the second one returns an Amount, so that usually means that, if you want to get the Price after the refactor, you need to manually divide the Amount by the Quantity (Price = Amount/Quantity).

This could create a misunderstanding when refactoring affected code.
NA
These are the proposed changes:

1. The Javadoc for FinancialUtils.calculateNetAmtFromGross() method must say "Calculates the net amount using the C_GET_NET_AMOUNT_FROM_GROSS stored procedure" (amount, not unit price).

2. A new method called calculateNetUnitPriceFromGross() must be developed that will be in charge of returning the net unit price. It will receive the same parameters as calculateNetAmtFromGross() and the quantity and price precission.
It will call the calculateNetAmtFromGross() and divide the amount by the quantity rounding to the price precision (control divide by 0 scenario).

3. The deprecated info at calculateNetFromGross() method will point to the new method calculateNetUnitPriceFromGross()

4. We will replace the calls to calculateNetAmtFromGross() by the new method calculateNetUnitPriceFromGross() in the places where we are interested in getting the price only.

Example of a candidate to change:
        BigDecimal netAmount = FinancialUtils.calculateNetAmtFromGross(strTaxId, grossAmount,
            StdPrecision, taxBaseAmt);
        priceActual = BigDecimal.ZERO;
        if (qtyInvoice.compareTo(BigDecimal.ZERO) != 0) {
          priceActual = netAmount.divide(qtyInvoice, PricePrecision, RoundingMode.HALF_UP);
        }
No tags attached.
related to defect 0035428 closed aferraz Do not calculate Net Price and Net Amount outside triggers when creating new Order/Invoice with Price Including Taxes 
related to design defect 0032265 closed aferraz [SER QA 1434] Taxes at document level are not properly calculated in some cases 
Issue History
2017-04-12 14:06vmromanosNew Issue
2017-04-12 14:06vmromanosAssigned To => Triage Finance
2017-04-12 14:06vmromanosModules => Core
2017-04-12 14:06vmromanosTriggers an Emergency Pack => No
2017-04-12 14:07vmromanosRelationship addedrelated to 0035428
2017-04-12 14:07vmromanosRelationship addedrelated to 0032265

There are no notes attached to this issue.