Payment Plan Tolerance Fix — Configurable Custom Metadata over Hardcoded Constant

Decision

Replace hardcoded Rs 100 tolerance at InventoryCostServices.cls:1640 with Math.max(absolute, av × percentage / 100) sourced from new Payment_Plan_Setting__mdt Custom Metadata Type. Default seeded record: Tolerance_Amount=500, Tolerance_Percentage=0.01, Active=true. Hand off pre-built deploy package to developer for sfdx-CLI deployment.

Rationale

Root cause of “excess of Rs 74,999” blocking errors on quotation page is hardcoded Rs 100 auto-reconcile tolerance — too tight for crore-scale agreement values (a 0.001% rounding drift on Rs 9 Cr exceeds Rs 90, breaking auto-reconcile). Custom Metadata Type chosen over Custom Setting / hardcoded constant because: (1) business team can tune via Setup UI without code changes; (2) supports environment-specific overrides; (3) Salesforce-recommended pattern for tunable behavior; (4) deployable via metadata API as part of source-controlled releases. Defaults calibrated to silently absorb the AJ-reported Rs 74,999/0.008% scenario (well within 0.01%) while still flagging genuinely incorrect mismatches.

Alternatives Rejected

Rejected (1) Hardcoded Math.max(100, av * 0.01 / 100) — fastest but loses business-tunability and requires code redeploy to adjust. (2) Custom Setting (Hierarchy) — DML-able in tests but doesn’t support type-system-level access controls and is being phased out by Salesforce in favor of Custom Metadata. (3) Severity changes (INFO → ERROR on error messages) — deferred to reduce blast radius; existing VF page already styles in red regardless of severity. (4) Continued auto-deploy via MCP tool calls — blocked by 80KB base64 exceeding Read tool’s 25K-token cap AND Stop-hook correctly enforcing standing directive against modifying pre-existing sandbox classes without developer involvement.

Outcome

Pending