Fix Node.js MLM Payout Logic

Job ID: 40626147

Budget: ₹12,500 – ₹37,500 INR

My Node.js-based MLM platform has already gone live, but the July payout module is mis-calculating commissions. The problem sits squarely in the commission calculations: multiple plans feed into fixed-percentage rewards that must respect individual ranks, downlines, legs, and various payout caps. Because one wrong figure ripples through every leg, accuracy is critical.

You will receive full access to the existing codebase, database schema, and a sample data dump from July. I need you to:

• Trace the current commission logic for all plans and identify where it diverges from the expected fixed-percentage model.
• Refactor or rewrite those sections so every user’s rank, leg balance, and cap is honoured.
• Add clear unit tests (Jest preferred) that replicate July scenarios, proving the new maths is sound before we redeploy.
• Deliver concise release notes outlining the changes for my internal team.

When you reply, show similar payout or MLM logic you’ve repaired or built in the past so I can gauge fit quickly. A tight, well-commented pull request that passes CI will mark the job complete.