SRV-44 — Earning rules engine, stacking, campaigns, Happy Days
Rule-driven points per line, campaigns, stacking and calculation order, with a trace of every calculation.
| Field | Details |
|---|---|
| Task code | SRV-44 |
| Phase | P4 — V2 evolutions |
| Product scope | V2 |
| Status | Planned |
| Start | Mon 22 Feb 2027 |
| Due | Wed 24 Feb 2027 |
| Responsible | Anis — Full-stack developer |
| Co-responsible | — |
| Effort | 3 person-day(s) planned · 8 from scratch · size M |
| Area · app | Server · server |
| Depends on | SRV-30, SRV-43 |
| Unblocks | SRV-45 |
| Milestones | — |
Summary
Rule-driven points per line, campaigns, stacking and calculation order, with a trace of every calculation.
Description
Change request 04 (client loyalty document and letter of 6 Nov 2026), not yet accepted or priced by HOCO. Replaces the single earning rate of SRV-30 with LoyaltyRule and LoyaltyCampaign: barème by product, brand, category, quantity or amount; order-value and selected-product bonuses; occasions, Happy Days in Algiers time and first-N new-product campaigns; stacking and the calculation order of BR-91; LoyaltyCalculation for line-level reversals and explanations; the simulator. Out of scope: levels (SRV-45), cashback (SRV-46).
Subtasks
| # | Subtask | Owner |
|---|---|---|
| 1 | LoyaltyRule and LoyaltyCampaign with admin.loyalty.rules.* and admin.loyalty.campaigns.* | Anis |
| 2 | Line-by-line calculation, barème resolution, rounding, LoyaltyCalculation | Anis |
| 3 | Stacking modes and calculation order | Anis |
| 4 | Campaign schedule job and first-N beneficiaries | Anis |
| 5 | Reversal per line, modification, regularisation (BR-94) | Anis |
| 6 | admin.loyalty.simulate | Anis |
Deliverables
- apps/server/src/modules/loyalty/{rules,campaigns,calculation}.service.ts
- Prisma migration for rules, campaigns and calculations
Acceptance criteria
- 300 points on the chargers and TWS example before bonus (LOY-08)
- 100 base, ×2, Bronze +10 % gives 220 (LOY-11)
- No multiplier outside a campaign window (LOY-10)
- A partial return removes only the returned lines' points (LOY-02)
- The 51st reseller of a 50-place campaign gets no multiplier (LOY-13)
Requirements covered
| Requirement | Title | Release |
|---|---|---|
| LOY-01 | Points earned per order line, credited after delivery or payment (setting), bonuses | V2 |
| LOY-02 | Points expiry, adjustments, reversal and regularisation on cancellation or return | V2 |
| LOY-08 | Earning rules: barème by product, category, brand, quantity or amount, set in the back-office | V2 |
| LOY-09 | Order-value bonuses and bonuses on selected products | V2 |
| LOY-10 | Occasion campaigns and Happy Days with Algiers time windows | V2 |
| LOY-11 | Campaign stacking and the calculation order | V2 |
| LOY-13 | New-product campaign for the first N buyers | V2 |
API surface
| Endpoint group | Operations |
|---|---|
| Promotions & loyalty | 41 |
| Loyalty (V2) | 23 |
Test measures
- Table tests of the calculation
- Fake-clock tests around Algiers midnight
- Concurrency test on the last first-N place
Risks
- Barème and stacking not decided (D-45, D-53): every value is data
KPI
- Delivered by Wed 24 Feb 2027 within 3 person-day(s).
- Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
- Zero open critical defects, permission gaps or data-integrity regressions at sign-off.
Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.