Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0035428Openbravo ERP09. Financial managementpublic2017-03-03 13:052017-03-20 15:11
aferraz 
aferraz 
normalminoralways
closedfixed 
5
 
3.0PR17Q2 
vmromanos
Core
No
0035428: Do not calculate Net Price and Net Amount outside triggers when creating new Order/Invoice with Price Including Taxes
When creating new C_Order or C_Invoice records using Price Including Taxes from any PL/SQL or Java code, PriceStd, PriceList, PriceLimit, PriceActual, TaxBaseAmt and LineNetAmt should not be calculated for lines, as they will be calculated in C_OrderLine_Trg or C_InvoiceLine_Before_Trg triggers.

In case we need to calculate them, instead of using C_Get_Net_Price_From_Gross function to calculate net price from gross price, we need to use C_Get_Net_Amount_From_Gross function to calculate net amount from gross amount and then net price from net amount.
*
No tags attached.
related to defect 00210313.0MP13 closed mirurita Openbravo ERP Discounts are not applied properly for Price Including Taxes price lists 
related to defect 00321343.0PR16Q2 closed AtulOpenbravo Openbravo ERP Price Including taxes is not supported by the Purchasing Plan (Create Purchase Orders process) 
related to defect 00259323.0PR14Q3 closed AtulOpenbravo Openbravo ERP The Total Gross Amount of the Sales Order is wrong for non stockable BOM products udner some circumstancies 
related to defect 0021195 closed mirurita Openbravo ERP "create invoice from receipt" in goods receipt window when prices include taxes 
related to defect 0031788 closed AtulOpenbravo Openbravo ERP In a Purchase Order window the Price turns to 0 using a price list including taxes under some circumstancies 
related to defect 00235603.0MP24 closed pramakrishnan Openbravo ERP Insert Orphan Line when using Price List including taxes is not calculating Net Price properly 
related to design defect 0032265 closed aferraz Openbravo ERP [SER QA 1434] Taxes at document level are not properly calculated in some cases 
related to defect 0035453 closed marvintm Retail Modules Method FinancialUtils.calculateNetFromGross has been deprecated and is currently used in the "Add Pack" process 
related to defect 0035475 new Retail Retail Modules Do not calculate Net Price and Net Amount outside triggers when creating new Order/Invoice with Price Including Taxes 
related to feature request 0035773 new Triage Omni OMS Openbravo ERP Several improvements in FinancialUtils class 
Issue History
2017-03-03 13:05aferrazNew Issue
2017-03-03 13:05aferrazAssigned To => Triage Finance
2017-03-03 13:05aferrazModules => Core
2017-03-03 13:05aferrazTriggers an Emergency Pack => No
2017-03-03 13:06aferrazProposed Solution updated
2017-03-03 13:06aferrazRelationship addedrelated to 0032265
2017-03-03 13:08aferrazFile Added: 35428.diff
2017-03-06 18:33aferrazNote Added: 0094773
2017-03-06 18:34aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14730
2017-03-06 18:41aferrazRelationship addedrelated to 0021031
2017-03-06 18:45aferrazRelationship addedrelated to 0032134
2017-03-06 18:47aferrazRelationship addedrelated to 0025932
2017-03-06 18:51aferrazRelationship addedrelated to 0021195
2017-03-06 19:11aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14731
2017-03-06 19:25aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14732
2017-03-07 10:51aferrazRelationship addedrelated to 0031788
2017-03-07 11:01aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14733
2017-03-07 12:35aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14734
2017-03-07 12:40aferrazRelationship addedrelated to 0023560
2017-03-07 12:49aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14735
2017-03-07 16:27aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14740
2017-03-07 17:14aferrazNote Edited: 0094773bug_revision_view_page.php?bugnote_id=0094773#r14743
2017-03-08 13:34hgbotCheckin
2017-03-08 13:34hgbotNote Added: 0094832
2017-03-08 13:34hgbotStatusnew => resolved
2017-03-08 13:34hgbotResolutionopen => fixed
2017-03-08 13:34hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/2d002737ee99169df4fb03ea8f76aee2a2d7869b [^]
2017-03-08 13:35aferrazAssigned ToTriage Finance => aferraz
2017-03-08 13:35aferrazFile Deleted: 35428.diff
2017-03-08 13:36aferrazProposed Solution updated
2017-03-08 16:43aferrazRelationship addedrelated to 0035453
2017-03-09 18:25hgbotCheckin
2017-03-09 18:25hgbotNote Added: 0094886
2017-03-09 18:48hgbotCheckin
2017-03-09 18:48hgbotNote Added: 0094887
2017-03-09 18:59hgbotCheckin
2017-03-09 18:59hgbotNote Added: 0094888
2017-03-09 19:33hgbotCheckin
2017-03-09 19:33hgbotNote Added: 0094889
2017-03-10 08:53aferrazNote Added: 0094892
2017-03-10 09:10aferrazTypedesign defect => defect
2017-03-10 09:16aferrazRelationship addedrelated to 0035475
2017-03-15 20:21hudsonbotCheckin
2017-03-15 20:21hudsonbotNote Added: 0095279
2017-03-20 15:11vmromanosReview Assigned To => vmromanos
2017-03-20 15:11vmromanosNote Added: 0095426
2017-03-20 15:11vmromanosStatusresolved => closed
2017-03-20 15:11vmromanosFixed in Version => 3.0PR17Q2
2017-04-12 14:07vmromanosRelationship addedrelated to 0035773

Notes
(0094773)
aferraz   
2017-03-06 18:33   
(edited on: 2017-03-07 17:14)
Test plan 1:

- Login as F&B Admin:
- Set Tarifa de ventas price list as Price Includes Tax
- Create a Sales Order for Alimentos y Supermercados, S.A
- Add a line with Agua sin Gas 1L product, quantity: 1, gross price: 1.53, tax: IVA 18%.
- Book the order.
- Check following data:
  Total Gross Amount: 1.38 (1.53 - 0.15)
  Total Net Amount: 1.17 (1.30 - 0.17)
  Line 1 Gross Amount: 1.53
  Line 1 Net Amount: 1.30 (1.53 / 1.18)
  Line 2 Gross Amount: -0.15 (1.53 * 0.10)
  Line 2 Net Amount: -0.13 (1.30 * 0.10)

Test plan 2:

- Login as F&B Admin:
- Set Tarifa de ventas price list as Price Includes Tax
- Create a Sales Invoice for Alimentos y Supermercados, S.A
- Add a line with Agua sin Gas 1L product, quantity: 1, gross price: 1.53, tax: IVA 18%.
- Book the invoice.
- Check following data:
  Total Gross Amount: 1.38 (1.53 - 0.15)
  Total Net Amount: 1.17 (1.30 - 0.17)
  Line 1 Gross Amount: 1.53
  Line 1 Net Amount: 1.30 (1.53 / 1.18)
  Line 2 Gross Amount: -0.15 (1.53 * 0.10)
  Line 2 Net Amount: -0.13 (1.30 * 0.10)

Test plan 3:

- Login as F&B Admin:
- Set Tarifa de ventas price list as Price Includes Tax
- Create a product with Stocked = No and Bill of Materials = Yes.
- Add a record in Price tab for Tarifa de ventas price list and price = 0.
- Add a record in Bill of Materials tab for Agua sin Gas product.
- Click on Verify BOM button.
- Create a Sales Order for Alimentos y Supermercados, S.A
- Add a line with created product, quantity = 1 and tax = IVA 21%.
- Click on Explode button
- Check following data:
  Total Gross Amount: 1.53
  Total Net Amount: 1.26

Test plan 4:

- Login as F&B Admin:
- Set Tarifa Bebidas Alegres price list as Price Includes Tax
- Create a Purchase Order for Bebidas Alegres, S.L.
- Add a line with Cerveza Ale product, quantity: 3, gross price: 9.99, tax: IVA 21%.
- Book the order.
- Create a Goods Receipt for Bebidas Alegres, S.L.
- Click on Create Lines From and select created order
- Click on Complete
- Click on Generate Invoice from Receipt
- Check following data in created invoice:
  Total Gross Amount: 29.97
  Total Net Amount: 24.77

Test plan 5:

- Login as F&B Admin:
- Set Tarifa Bebidas Alegres price list as Price Includes Tax
- Create a record in Discounts and Promotions window for Price Adjustment type, from 01-01-2017 to 31-12-2017, Included Products = Only those defined, Fixed Unit Price = 73 and Min Quantity = 10
- Add a record in Products tab for Agua sin Gas.
- Create a Purchase Order for Bebidas Alegres, S.L.
- Click on Create Lines and select Agua sin Gas with Standard Price = 19 and Quantity = 20.
- Book the order.
- Check following data in created order:
  Total Gross Amount: 1460.00
  Total Net Amount: 1206.61
  Line Gross Price: 73.00
  Line Net Price: 60.33

Test plan 6:

- Login as F&B Admin:
- Set Tarifa Bebidas Alegres price list as Price Includes Tax
- Create a record in Discounts and Promotions window for Price Adjustment type, from 01-01-2017 to 31-12-2017, Included Products = Only those defined, Fixed Unit Price = 73 and Min Quantity = 10
- Add a record in Products tab for Agua sin Gas.
- Create a Purchase Order for Bebidas Alegres, S.L.
- Click on Create Lines and select Agua sin Gas with Standard Price = 19 and Quantity = 20.
- Book the order.
- Check following data in created order:
  Total Gross Amount: 1460.00
  Total Net Amount: 1206.61
  Line Gross Price: 73.00
  Line Net Price: 60.33

Test plan 7:

- Login as F&B Admin:
- Set Tarifa de ventas price list as Price Includes Tax
- Create RM Allow Orphan Line preference with "Y" value.
- Logout and login again.
- Create Return From Customer for Alimentos y Supermercados.
- Click on Insert Orphan Line and select product Agua sin Gas, Returned = 5, Price = 330 and Tax = IVA 21%.
- Check following data in created line:
  Line Gross Amount: 1650.00
  Line Net Amount: 1363.64 (1650.00 / 1.21)
  Line Gross Price: 330.00 (1650.00 / 5)
  Line Net Price: 272.73 (1363.64 / 5)

Test plan 8:

- Login as F&B Admin:
- Set Tarifa de ventas price list as Price Includes Tax.
- Create Sales Quotation for Alimentos y Supermercados.
- Add a line with Agua sin Gas 1L product, quantity: 9, gross price: 9.99, tax: IVA 21%.
- Book the order.
- Click on Create Order.
- Check following data in created Sales Order:
  Total Gross Amount: 80.92 ((9*9.99) - (9*9.99*0.10))
  Total Net Amount: 66.88 (80.92 / 1.21)

Test plan 9:

- Login as F&B Admin:
- Set Tarifa Bebidas Alegres price list as Price Includes Tax
- Create a record in Discounts and Promotions window for Price Adjustment type, from 01-01-2017 to 31-12-2017, Included Products = Only those defined, Discount = 50.00%
- Add a record in Products tab for Agua sin Gas.
- Create a Purchase Order for Bebidas Alegres, S.L.
- Add a line for Agua sin Gas product and quantity = 99.
- Book the order.
- Check following data in created order:
  Total Gross Amount: 87.12 (1.76 * 0.5 * 99)
  Total Net Amount: 72.00 (87.12 / 1.21)

(0094832)
hgbot   
2017-03-08 13:34   
Repository: erp/devel/pi
Changeset: 2d002737ee99169df4fb03ea8f76aee2a2d7869b
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Wed Mar 08 10:08:26 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/2d002737ee99169df4fb03ea8f76aee2a2d7869b [^]

Fixes issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function

We avoid Net Price and Net Amount calculation outside triggers when creating new Order/Invoice lines with Price Including Taxes.
Also, we change use of C_GET_NET_PRICE_FROM_GROSS function with C_GET_NET_AMOUNT_FROM_GROSS in Order and Invoice callouts. Now, we get line net amount from line gross amount instead of getting line net price from line gross amount and then line net amount from line net price. Thus, we avoid precision loss.

---
M src-db/database/model/functions/C_INVOICE_POST.xml
M src-db/database/model/functions/C_ORDER_POST1.xml
M src-db/database/model/functions/MRP_PURCHASEORDER.xml
M src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml
M src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml
M src-db/database/model/functions/M_PROMOTION_ADJUSTMENT.xml
M src-db/database/model/functions/M_REQUISITION_CREATEPO.xml
M src/org/openbravo/common/actionhandler/OrderCreatePOLines.java
M src/org/openbravo/common/actionhandler/SRMOPickEditLines.java
M src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java
M src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java
M src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder.java
M src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
M src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java
M src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java
M src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java
M src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java
M src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql
M src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java
M src/org/openbravo/financial/FinancialUtils.java
---
(0094886)
hgbot   
2017-03-09 18:25   
Repository: erp/pmods/org.openbravo.materialmgmt.freightmgmt
Changeset: 305068c683c8a7207aba955802708d107199de93
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu Mar 09 18:22:21 2017 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.materialmgmt.freightmgmt/rev/305068c683c8a7207aba955802708d107199de93 [^]

Related to issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function

---
M src/org/openbravo/materialmgmt/freightmgmt/AvailableFreightsDS.java
M src/org/openbravo/materialmgmt/freightmgmt/SelectFreightHandler.java
---
(0094887)
hgbot   
2017-03-09 18:48   
Repository: erp/pmods/org.openbravo.module.resources
Changeset: 0a92293a8d0159108ea4a48dce3a1080b95b28ba
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu Mar 09 18:48:27 2017 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.module.resources/rev/0a92293a8d0159108ea4a48dce3a1080b95b28ba [^]

Related to issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function

---
M src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml
M src/org/openbravo/module/resources/calendar/ReservationUtilities.java
---
(0094888)
hgbot   
2017-03-09 18:59   
Repository: erp/pmods/org.openbravo.contract.services
Changeset: 3b94e730043475a1d312da8d1eb5a32a0eda30db
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu Mar 09 18:58:36 2017 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.contract.services/rev/3b94e730043475a1d312da8d1eb5a32a0eda30db [^]

Related to issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function

---
M src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml
M src/org/openbravo/contract/services/process/billing/StandardContractInvoiceProcess.java
---
(0094889)
hgbot   
2017-03-09 19:33   
Repository: erp/pmods/org.openbravo.contract.services
Changeset: e5d641089f92a363cecb2d37d6334a69d5d91293
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu Mar 09 19:33:11 2017 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.contract.services/rev/e5d641089f92a363cecb2d37d6334a69d5d91293 [^]

Related to issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function

---
M src/org/openbravo/contract/services/process/billing/StandardContractInvoiceProcess.java
---
(0094892)
aferraz   
2017-03-10 08:53   
Pending to update dependency of org.openbravo.materialmgmt.freightmgmt and org.openbravo.contract.services (spm2 branch) modules to core 17Q2.
(0095279)
hudsonbot   
2017-03-15 20:21   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/54e102bef53e [^]
Maturity status: Test
(0095426)
vmromanos   
2017-03-20 15:11   
Code review OK