Openbravo Issue Tracking System - Retail Modules
View Issue Details
0048737Retail ModulesWeb POSpublic2022-03-08 10:502022-06-14 17:47
aferraz 
aferraz 
normalmajorhave not tried
closedfixed 
5
 
RR22Q2 
No
0048737: Performance problem in Tax Engine having tax rules with many tax zones
The map of joinRuleAndZone function in OB.Taxes.filterRulesByTicket (tax-engine.js) consumes a lot of memory when having tax rules with many tax zones.
Add a product to a ticket in POS and check tax engine performance.
Filter tax rules by country and region using taxZones property instead of creating a new rule for each tax zone.
No tags attached.
related to defect 0045303 closed aferraz Retail Modules Performance of the tax engine can be improved 
related to defect 0048762 closed gorka_gil Retail Modules Many unneded tax rules are loaded in WebPOS making tax engine very slow 
related to defect 0047419 closed igor_trebol Openbravo Localizations Wrong tax calculation for sales to not exempt customers from a Store located in Guadeloupe to a customer located in Guadeloupe 
related to defect 0051712pi new Triage Omni OMS Retail Modules Tax application error in POS 
diff 20Q3.diff (14,246) 2022-06-14 17:47
https://issues.openbravo.com/file_download.php?file_id=17162&type=bug
Issue History
2022-03-08 10:50aferrazNew Issue
2022-03-08 10:50aferrazAssigned To => aferraz
2022-03-08 10:50aferrazTriggers an Emergency Pack => No
2022-03-08 11:37hgbotNote Added: 0135547
2022-03-08 13:25aferrazRelationship addedrelated to 0045303
2022-03-10 13:37aferrazRelationship addedrelated to 0048762
2022-03-11 11:04hgbotResolutionopen => fixed
2022-03-11 11:04hgbotStatusnew => closed
2022-03-11 11:04hgbotNote Added: 0135653
2022-03-11 11:04hgbotFixed in Version => RR22Q2
2022-03-11 11:04hgbotNote Added: 0135654
2022-03-11 11:17aferrazNote Added: 0135655
2022-05-19 15:30aferrazRelationship addedrelated to 0047419
2022-06-14 17:47aferrazFile Added: 20Q3.diff
2023-02-28 13:31aferrazRelationship addedrelated to 0051712

Notes
(0135547)
hgbot   
2022-03-08 11:37   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/739 [^]
(0135653)
hgbot   
2022-03-11 11:04   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/739 [^]
(0135654)
hgbot   
2022-03-11 11:04   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^]
Changeset: c54d8b29e49b4042369858f5a51245e1f2c05e84
Author: Álvaro Ferraz <alvaro.ferraz@openbravo.com>
Date: 11-03-2022 10:04:54
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/c54d8b29e49b4042369858f5a51245e1f2c05e84 [^]

Fixes ISSUE-48737: Remove joinRuleAndZone and groupRuleAndZone functions from tax engine

Tax definition in OB allows to define different tax zones for each tax rate. Tax zones work as tax rate extension. That means the rule should apply if it matches the country/region defined in the tax rate (header) or in any tax zone (subtab).

In order to compute tax zones, joinRuleAndZone function was doing a map to retrieve each tax zone as a new rule, including the information from the tax rate but overriding the country/region properties. After this map, rules were filtered by country/region properties and groupRuleAndZone grouped rules by tax rate again.

The map function was consuming a lot of memory when many tax rates and tax zones were defined making tax engine very slow. This map has been replaced by two flatMaps named checkandUpdateLocation. Both functions copy the rules after filtering by country/region instead of before as it was doing joinRuleAndZone, creating a copy only for the tax rates and tax zones that match lines country/region, which reduces the memory needed.

---
M web/org.openbravo.retail.posterminal/app/model/business-logic/taxes-engine/engine/tax-engine.js
---
(0135655)
aferraz   
2022-03-11 11:17   
MR for TAP: https://gitlab.com/obcustomers/AGAP/org.openbravo.retail.posterminal/-/merge_requests/26 [^]