Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045305Retail ModulesWeb POSpublic2020-10-27 06:352020-11-18 09:11
marvintm 
aferraz 
normalmajoralways
closedfixed 
5
 
RR20Q4RR20Q4 
marvintm
No
0045305: 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-10-27 09:36marvintmTypedefect => backport
2020-10-27 09:36marvintmTarget Version => RR20Q4
2020-11-18 09:06aferrazAssigned ToRetail => aferraz
2020-11-18 09:08hgbotResolutionopen => fixed
2020-11-18 09:08hgbotStatusscheduled => resolved
2020-11-18 09:08hgbotFixed in Version => RR20Q4
2020-11-18 09:08hgbotNote Added: 0124471
2020-11-18 09:11marvintmReview Assigned To => marvintm
2020-11-18 09:11marvintmStatusresolved => closed

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

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