Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045453Retail ModulesWeb POSpublic2020-10-27 06:352020-11-18 09:11
marvintm 
aferraz 
normalmajoralways
closedfixed 
5
 
RR20Q3.2RR20Q3.2 
marvintm
No
0045453: 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.
blocks defect 0045303 closed aferraz Performance of the tax engine can be improved 
Issue History
2020-11-16 16:36marvintmTypedefect => backport
2020-11-16 16:36marvintmTarget Version => RR20Q3.2
2020-11-18 09:07aferrazAssigned Tomarvintm => aferraz
2020-11-18 09:09hgbotResolutionopen => fixed
2020-11-18 09:09hgbotStatusscheduled => resolved
2020-11-18 09:09hgbotFixed in Version => RR20Q3.2
2020-11-18 09:09hgbotNote Added: 0124472
2020-11-18 09:11marvintmReview Assigned To => marvintm
2020-11-18 09:11marvintmStatusresolved => closed

Notes
(0124472)
hgbot   
2020-11-18 09:09   
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^]
Changeset: a9cd81947ca27a88f0f4ac392c2b74d5921774ea
Author: Álvaro Ferraz <alvaro.ferraz@openbravo.com>
Date: 2020-11-18T09:09:26+01:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/a9cd81947ca27a88f0f4ac392c2b74d5921774ea [^]

Fixes ISSUE-45453: 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
---