diff --git a/src/app/admin/accounting/page.tsx b/src/app/admin/accounting/page.tsx index 784860e..690ecb5 100644 --- a/src/app/admin/accounting/page.tsx +++ b/src/app/admin/accounting/page.tsx @@ -6,7 +6,8 @@ import { DollarSign, Calendar, FileText, ArrowDownLeft, ArrowUpRight, Building, ChevronLeft, ChevronRight, Wallet, Receipt, BookOpen, PieChart, List, Banknote, Smartphone, Users, Home, Wrench, Printer, FileSpreadsheet, - Filter, ShoppingCart, Tag, Move, Calculator, Save, CreditCard, Bike + Filter, ShoppingCart, Tag, Move, Calculator, Save, CreditCard, Bike, + Clock, Check, CheckCircle } from 'lucide-react'; export type AccountType = 'asset' | 'liability' | 'equity' | 'income' | 'expense'; @@ -71,6 +72,20 @@ export interface AccountingTransaction { createdBy: string; } +export interface WithdrawRequest { + id: string; + investorId: string; + investorName: string; + phone: string; + amount: number; + requestDate: string; + status: 'pending' | 'approved' | 'completed' | 'rejected'; + bankName: string; + accountNo: string; + processedDate?: string; + paymentMethod?: string; +} + const defaultAccounts: ChartOfAccount[] = [ { id: 'ASSET-001', code: '1000', name: 'Assets', type: 'asset', isActive: true, balance: 0 }, { id: 'ASSET-101', code: '1100', name: 'Cash in Hand', type: 'asset', parentId: 'ASSET-001', isActive: true, balance: 85000 }, @@ -223,7 +238,7 @@ function generateAutoJournalEntries(type: TransactionType, amount: number, descr } export default function AccountingPage() { - const [activeTab, setActiveTab] = useState<'dashboard' | 'transactions' | 'journal' | 'ledger' | 'accounts'>('dashboard'); + const [activeTab, setActiveTab] = useState<'dashboard' | 'transactions' | 'journal' | 'ledger' | 'accounts' | 'withdraw'>('dashboard'); const [transactions, setTransactions] = useState(mockTransactions); const [accounts] = useState(defaultAccounts); const [journalEntries, setJournalEntries] = useState(mockJournalEntries); @@ -234,6 +249,14 @@ export default function AccountingPage() { const [showModal, setShowModal] = useState(false); const [editingTransaction, setEditingTransaction] = useState(null); const [viewingTransaction, setViewingTransaction] = useState(null); + const [showWithdrawModal, setShowWithdrawModal] = useState(false); + const [payNowModal, setPayNowModal] = useState(null); + const [paymentForm, setPaymentForm] = useState({ method: 'bank', reference: '', notes: '', date: new Date().toISOString().split('T')[0] }); + const [withdrawRequests, setWithdrawRequests] = useState([ + { id: 'WDR-001', investorId: 'INV-001', investorName: 'Mohammad Islam', phone: '01987654321', amount: 15000, requestDate: '2024-03-20', status: 'pending', bankName: 'City Bank', accountNo: '1234567890' }, + { id: 'WDR-002', investorId: 'INV-002', investorName: 'Rahima Begum', phone: '01876543210', amount: 25000, requestDate: '2024-03-18', status: 'approved', bankName: 'DBBL', accountNo: '9876543210', processedDate: '2024-03-19', paymentMethod: 'bank' }, + { id: 'WDR-003', investorId: 'INV-003', investorName: 'Ahmed Hassan', phone: '01765432109', amount: 8000, requestDate: '2024-03-15', status: 'completed', bankName: 'bKash', accountNo: '01765432109', processedDate: '2024-03-16', paymentMethod: 'mobile' }, + ]); const [currentPage, setCurrentPage] = useState(1); const itemsPerPage = 10; @@ -417,7 +440,8 @@ export default function AccountingPage() { { id: 'transactions', label: 'Transactions', icon: Receipt }, { id: 'journal', label: 'Journal', icon: BookOpen }, { id: 'ledger', label: 'Ledger', icon: List }, - { id: 'accounts', label: 'Chart of Accounts', icon: Calculator }, + { id: 'accounts', label: 'Accounts', icon: Calculator }, + { id: 'withdraw', label: 'Withdraw', icon: ArrowDownLeft }, ]; return ( @@ -453,6 +477,11 @@ export default function AccountingPage() { > {tab.label} + {tab.id === 'withdraw' && withdrawRequests.filter(w => w.status === 'pending').length > 0 && ( + + {withdrawRequests.filter(w => w.status === 'pending').length} + + )} ); })} @@ -546,6 +575,289 @@ export default function AccountingPage() { {activeTab === 'journal' && } {activeTab === 'ledger' && } {activeTab === 'accounts' && } + + {activeTab === 'withdraw' && ( +
+
+
+

Withdraw Management

+

Process investor withdrawal requests

+
+ +
+ +
+
+
+
+ +
+
+

{withdrawRequests.filter(w => w.status === 'pending').length}

+

Pending

+
+
+
+
+
+
+ +
+
+

{withdrawRequests.filter(w => w.status === 'approved').length}

+

Approved

+
+
+
+
+
+
+ +
+
+

{withdrawRequests.filter(w => w.status === 'completed').length}

+

Completed

+
+
+
+
+
+
+ +
+
+

৳{withdrawRequests.reduce((sum, w) => sum + w.amount, 0).toLocaleString()}

+

Total Amount

+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + {withdrawRequests.map((req) => ( + + + + + + + + + + + ))} + +
IDInvestorPhoneAmountBank/MethodRequest DateStatusActions
{req.id} +
+

{req.investorName}

+

{req.investorId}

+
+
{req.phone}৳{req.amount.toLocaleString()} +

{req.bankName}

+

{req.accountNo}

+
{req.requestDate} + + {req.status === 'pending' && } + {req.status === 'approved' && } + {req.status === 'completed' && } + {req.status} + + +
+ {req.status === 'pending' && ( + <> + + + + )} + {req.status === 'approved' && ( + + )} + {req.status === 'completed' && ( +
+ Paid + +
+ )} + {req.status === 'rejected' && ( + Rejected + )} +
+
+
+
+ + {showWithdrawModal && ( +
+
+
+

New Withdraw Request

+ +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ )} +
+ )} + + {payNowModal && ( +
+
+
+

Process Payment

+ +
+
+
+

Paying to

+

{payNowModal.investorName}

+

{payNowModal.bankName} - {payNowModal.accountNo}

+
+
+

Amount

+

৳{payNowModal.amount.toLocaleString()}

+
+
+ + setPaymentForm(p => ({ ...p, date: e.target.value }))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" /> +
+
+ + +
+
+ + setPaymentForm(p => ({ ...p, reference: e.target.value }))} placeholder="e.g. TRX-123456" className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" /> +
+
+ +