Optimize Supabase TypeScript Wallet Statements

Job ID: 40357059

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

I’m running a Supabase-backed project written in .ts and .tsx. The core is a gender-segmented wallet system, and I’m looking for solid code optimization to make the following workflow airtight:

• Each account should show a correct, real-time balance in both the everyday statements (men and women) and the scheduled exports.
• At exactly the 16th of every month 00:00 and again at 00:00 on the last day, I need every woman’s balance captured, written to an Excel file (columns: Name, Account Number, IFSC, Balance, KYC Status), and then her wallet reset to zero so I can trigger payouts externally.
• Statement generation itself must remain accurate after the reset, reflecting the cleared balance for women while leaving men’s data untouched.

The existing logic mostly works, but the queries and calculations are starting to slow down as data grows. I want the TypeScript functions and any Supabase RPC or Edge Function you touch to be lean, deterministic, and well commented.

Deliverables
1. Refactored TypeScript / React (.ts, .tsx) files with optimized queries and reduced latency.
2. Automated job or Edge Function that runs at the scheduled times, outputs the Excel exactly as described, uploads it to a designated bucket, then zeroes the balances.
3. Proof-of-concept test data plus short README so I can reproduce runs locally and in production.

If you’re comfortable with Supabase triggers, Postgres functions, cron scheduling (Supabase Scheduler or external), and Excel generation in Node/TS, this should be straightforward. Let me know your approach and an estimated turnaround; I’ll share repo access right after.