/** * Reports Page Logic - Aadhaar Pro */ document.addEventListener('DOMContentLoaded', () => { if (typeof flatpickr !== 'undefined') { flatpickr(".date-picker", { dateFormat: "Y-m-d", allowInput: true }); } loadReports(); }); async function loadReports(filters = {}) { const listEl = document.getElementById('reports-list'); if (!listEl) return; try { let url = '/api/wallet/ledger'; if (filters.from || filters.to) { const params = new URLSearchParams(filters); url += `?${params.toString()}`; } const res = await fetch(url); const data = await res.json(); if (data && data.length > 0) { const items = data.map(item => { let displayId = item.id ? item.id.substring(0, 8) + '...' : 'N/A'; if (item.description && item.description.includes('Aadhaar Advance: ')) { const parts = item.description.split('Aadhaar Advance: '); if (parts.length > 1) displayId = parts[1]; } const statusClass = item.type === 'credit' ? 'status-approved' : 'status-rejected'; const statusIcon = item.type === 'credit' ? 'fa-arrow-down' : 'fa-arrow-up'; const statusText = item.type === 'credit' ? 'CREDIT' : 'DEBIT'; const amountPrefix = item.type === 'credit' ? '+' : '-'; const amountClass = item.type === 'credit' ? 'amount-plus' : 'amount-minus'; return `
No transactions for the selected period
Could not fetch report data