Flexible Financial Settlement Engine for Enterprise CRM
Lead Developer & Technical BA (acting) — mid-project discovery, schema redesign, and a batch-based payout model aligned with real commission accounting.
Architecture notes: finance shopping cart model, consolidated payment vouchers, and enterprise CRM commission flow (NDA).
- 01Cron Job Start→ Fetch Completed Cases
- 02Fetch Completed Cases→ Loop per Agent
- 03Calculation EngineLoop per Agent→ Is WHT Enabled for Agent?
- 04Calculation Engine◆ Is WHT Enabled for Agent?→ Tax = 0 [No]→ YTD + current meets policy threshold? [Yes]
- 05Calculation Engine◆ YTD + current meets policy threshold?→ Tax = 0 [No]→ Withholding = commission * policy rate [Yes]
- 06Calculation EngineTax = 0→ Insert Commission Record Status: NEW
- 07Calculation EngineWithholding = commission * policy rate→ Insert Commission Record Status: NEW
- 08Insert Commission Record Status: NEW→ Agent: Views My Commission
- 09Finance Shopping CartAgent: Views My Commission→ Agent Submits
- 10Finance Shopping CartAgent Submits→ Admin Approves
- 11Finance Shopping CartAdmin Approves→ Finance Pool
- 12Finance Shopping CartFinance Pool→ Finance Selects Items
- 13Finance Shopping Cart◆ Finance Selects Items→ LOCK Records, Set Batch_ID [Yes]
- 14Finance Shopping CartLOCK Records, Set Batch_ID→ Draft Batch
- 15Finance Shopping CartDraft Batch→ Generate PV
- 16Finance Shopping CartGenerate PV
Rigid deal ↔ payout assumptions
Joined an ongoing enterprise CRM build mid-flight. Discovery surfaced a critical architectural mismatch: the system assumed a fixed one-to-one link between deals and payouts. In practice, the client needed partial line items (base, bonus, incentives) across hierarchical partners and timelines — consolidated into single payment vouchers per agent.
Finance "shopping cart" batching
Designed a model where finance selects specific commission rows from multiple deals, locks them into a draft batch, and generates one consolidated payment voucher (PV) per agent. Led alignment across UI/UX and engineering on schema, locking rules, and commission lifecycle states.
02Impact
Impact
Reduced the risk of a disruptive post-launch financial refactor by matching how payouts are actually prepared in accounting — granular inputs, explicit locks, and clear voucher outputs — before go-live.
03Technical architecture
Technical architecture
Four views of the same design: data shape, end-to-end flow, cross-system sequence, and commission record states including the finance selection "lock".
Other views
Tap a table to see what it links to.
- AGENT closes SALE_CASE 1 → many
- AGENT earns COMMISSION_RECORD 1 → many
- SALE_CASE generates COMMISSION_RECORD 1 → many
- PAYMENT_BATCH contains COMMISSION_RECORD 1 → many
- PAYMENT_VOUCHER covers COMMISSION_RECORD 1 → many
- 01Steps 1–3: automatic calculation→ Calculation engine → Database · fetch new closed cases
- 02Calculation engine → Databasefetch new closed cases
- 03For each agent in the case · check year-to-date earning→ Year-to-date plus current · reaches the policy threshold?
- 04◆ Year-to-date plus current · reaches the policy threshold?→ Set withholding flag true · calculate withholding at the configured rate [yes]→ Set withholding flag false · tax = 0 [no]
- 05Set withholding flag true · calculate withholding at the configured rate→ Insert record · status NEW, withholding amount
- 06Set withholding flag false · tax = 0→ Insert record · status NEW, withholding amount
- 07Insert record · status NEW, withholding amount→ Step 4: visibility and submission
- 08Step 4: visibility and submission→ Database → Agent portal · agent views My Commission
- 09Database → Agent portalagent views My Commission
- 10Agent portal → Databasesubmit record, status PENDING_APPROVAL
- 11Step 6: shopping cart selection→ Database → Finance portal · query the approved commissions pool
- 12Database → Finance portalquery the approved commissions pool
- 13Finance selection session · select item A base and item B bonus→ Lock items · status IN_DRAFT_BATCH
- 14Lock items · status IN_DRAFT_BATCH→ Save as draft payment batch
- 15Save as draft payment batch→ Step 7: finalizing payment
- 16Step 7: finalizing payment→ Finance portal → Database · confirm batch and generate payment voucher
- 17Finance portal → Databaseconfirm batch and generate payment voucher
- 18Assign voucher number and date→ Update items to PAID
- 19Update items to PAID→ Update case status · partially or fully paid
- 20Update case status · partially or fully paid→ Update agent My Payment view
- 21Update agent My Payment view
- 01NEW→ PENDING_APPROVAL [Agent Submits]
- 02IN_DRAFT_BATCH→ APPROVED [Removed from Cart]→ PROCESSING_PV [Confirm Batch]
- 03PENDING_APPROVAL→ APPROVED [Admin Approves]→ REJECTED [Admin Rejects]
- 04PROCESSING_PV→ PAID [PV Generated]
- 05APPROVED→ IN_DRAFT_BATCH [Added to Finance Cart]
- 06REJECTED→ NEW [Reset for Edit]
- 07PAID→ end