Fix Exchange Sales Returns

Scans every sales return whose sold device involved a trade-in. For each, shows the real cash portion vs. the trade-in (Exchange) portion of the original sale, and what was actually refunded. Rebalance Ledger is only offered when the trade-in device is no longer available to recover and more was refunded than the real cash collected. It adds one new money_transaction against account 5 (Exchange) — it never edits or deletes any existing row, and never moves real cash. Each rebalance is logged to stock_logs (action = 'EXCHANGE_RETURN_RECONCILED') so a record can never be rebalanced twice.
Preview mode is active. The Rebalance Ledger button is disabled until you switch mode to Live.
Needs rebalancing

2

Already reconciled

0

Trade-in still in stock (manual decision, no action here)

0

Status Return # Sold Device Customer Return Date Trade-in Device Trade-in Status Cash Portion Trade-in Portion Refunded Gap Action
Needs rebalancing #2 S25 ultra
352901547583347
Anuj jain 2026-07-20 X300 pro
862492086166978
Unavailable (resold/gone) ₹6,500 ₹72,500 ₹79,000 ₹72,500
Needs rebalancing #6 Phone 3
357502440483786
Vijay tamrakar 2026-07-27 A55
352053260421030
Unavailable (resold/gone) ₹10,000 ₹15,000 ₹25,000 ₹15,000