Projects:Best Deal Case
Functional Requirements
Currently Discounts and Promotions are applied to a ticket based on two factors:
- Discount Sequence determines the priority the discount is applied in
- Apply next allows or denies other discounts to be applied on this line if current is applied
Best Deal Case is an alternative mechanism to the described one. When working on "Best Deal Case" mode:
- Only one discount can be applied per line (discretionary discounts can also be applied together with standard ones)
- The best combination at ticket level (from client's point of view, this is the one that obtains the biggest discount) of discounts is applied.
It is not required to calculate best deal case while products are added to the ticket, this can be calculated instead when the ticket is about to be paid.
First iteration of this project will implement Best Deal Case in POS but not in backend.
Technical Specs
Algorithm
splitLines() promotionCandidates = getPromotionCandidates() do { if (!alreadyCalculated()) { removeAllDiscounts() for (line:lines) { line.addCurrentCandidate() } for (line:lines) { line.calculateDiscount() } if (currentDiscount > biggestDiscount) { biggestDiscount = currentDiscount } } couldMovePointer = movePointer() } while (!couldMovePointer) apply(biggestDiscount) function getPromotionCandidates() { for (line:lines) { candidates.push(getCandidatesForLine(line)) } return candidates } function splitLines() { // splits each line with more than 1 unit in several, having each of them 1 unit // it only applies to those lines that are candidates for at least one discount } function alreadyCalculated () { // checks if current combianation is already calculated // Example: // A disc1, A disc2 === A disc2, A disc1 }