Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045303Retail ModulesWeb POSpublic2020-10-27 06:352020-11-18 09:06
marvintm 
aferraz 
normalmajoralways
closedfixed 
5
 
RR21Q1 
No
0045303: Performance of the tax engine can be improved
Currently, the ticket calculation performance degrades quite significantly with the number of lines. Almost all the degradation comes from the tax engine, and particularly the call to the OB.Taxes.filterRulesByTicketLine function, which computes which tax rules could be applied to a line.

If this was optimised, the performance of the engine, and the ticket calculation speed in general, would improve by a very large amount.
Create a big ticket using "GPS" products (to ensure that all lines have a discount).
Realise that after 200 lines, calculating a ticket takes around 1.5 seconds.
Do some profiling. Realise that almost all the time is spent in the OB.Taxes.filterRulesByTicketLine function.
The initial optimisation we are going to try consists in trying to avoid calculating the rules if the line already has them, and the line itself didn't change.
No tags attached.
depends on backport 0045305RR20Q4 closed aferraz Performance of the tax engine can be improved 
depends on backport 0045453RR20Q3.2 closed aferraz Performance of the tax engine can be improved 
related to defect 0048737 closed aferraz Performance problem in Tax Engine having tax rules with many tax zones 
Issue History
2020-10-27 06:35marvintmNew Issue
2020-10-27 06:35marvintmAssigned To => Retail
2020-10-27 06:35marvintmTriggers an Emergency Pack => No
2020-10-27 09:36marvintmStatusnew => scheduled
2020-10-27 09:36marvintmAssigned ToRetail => marvintm
2020-10-28 08:23hgbotNote Added: 0123966
2020-10-30 13:11hgbotNote Added: 0124065
2020-11-09 07:59hgbotNote Added: 0124232
2020-11-09 08:00hgbotNote Added: 0124233
2020-11-09 08:02hgbotNote Added: 0124234
2020-11-09 08:02hgbotNote Added: 0124235
2020-11-16 16:36marvintmStatusscheduled => acknowledged
2020-11-16 16:36marvintmStatusacknowledged => scheduled
2020-11-16 19:29hgbotNote Added: 0124432
2020-11-18 08:30hgbotResolutionopen => fixed
2020-11-18 08:30hgbotStatusscheduled => closed
2020-11-18 08:30hgbotNote Added: 0124463
2020-11-18 08:30hgbotFixed in Version => RR21Q1
2020-11-18 08:30hgbotNote Added: 0124464
2020-11-18 08:56hgbotNote Added: 0124466
2020-11-18 08:56hgbotNote Added: 0124467
2020-11-18 09:06aferrazAssigned Tomarvintm => aferraz
2022-03-08 13:25aferrazRelationship addedrelated to 0048737

Notes
(0123966)
hgbot   
2020-10-28 08:23   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/137 [^]
(0124065)
hgbot   
2020-10-30 13:11   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/146 [^]
(0124232)
hgbot   
2020-11-09 07:59   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/137 [^]
(0124233)
hgbot   
2020-11-09 08:00   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/157 [^]
(0124234)
hgbot   
2020-11-09 08:02   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/157 [^]
(0124235)
hgbot   
2020-11-09 08:02   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/158 [^]
(0124432)
hgbot   
2020-11-16 19:29   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/185 [^]
(0124463)
hgbot   
2020-11-18 08:30   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/185 [^]
(0124464)
hgbot   
2020-11-18 08:30   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^]
Changeset: be8805f67182617d31cec75865245c446713827b
Author: Álvaro Ferraz <alvaro.ferraz@openbravo.com>
Date: 2020-11-17T14:27:02+01:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/be8805f67182617d31cec75865245c446713827b [^]

Fixes ISSUE-45303: Performance of the tax engine can be improved

Move maps, filters and sorts not using line information from filterRulesByTicketLine to filterRulesByTicket:
- joinRuleAndZone
- sortByRegionFrom
- sortByCountryFrom
- sortByLineno
- sortByCascade
- sortByTaxBase

Move some filters to filterRulesByTicket to reduce the rules sent to filterRulesByTicketLine:
- checkTaxCategory,
- checkCountry
- checkRegion

Reorder some filters to apply first the ones more restrictive.

---
M web/org.openbravo.retail.posterminal/app/model/business-logic/taxes-engine/engine/tax-engine.js
---
(0124466)
hgbot   
2020-11-18 08:56   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/146 [^]
(0124467)
hgbot   
2020-11-18 08:56   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/158 [^]