diff --git a/src/app/admin/investors/[id]/page.tsx b/src/app/admin/investors/[id]/page.tsx index 1a56c42..c8010c4 100644 --- a/src/app/admin/investors/[id]/page.tsx +++ b/src/app/admin/investors/[id]/page.tsx @@ -53,6 +53,20 @@ export default function InvestorDetailPage() { const [showEditModal, setShowEditModal] = useState(false); const [showAssignBikeModal, setShowAssignBikeModal] = useState(false); const [selectedBikeId, setSelectedBikeId] = useState(''); + const [showCreateInvestmentModal, setShowCreateInvestmentModal] = useState(false); + const [newInvestment, setNewInvestment] = useState({ + planName: '', + planType: 'gold' as 'silver' | 'gold' | 'platinum' | 'diamond', + selectedBikeIds: [] as string[], + totalInvestment: 0, + monthlyReturn: 0, + expectedRoi: 15, + startDate: new Date().toISOString().split('T')[0], + endDate: '', + paymentMethod: 'bank' as 'bank' | 'mobile' | 'cash' | 'cheque', + transactionReference: '', + notes: '' + }); if (!investor) { return ( @@ -76,6 +90,49 @@ export default function InvestorDetailPage() { setSelectedBikeId(''); }; + const handleCreateInvestment = () => { + const invId = `ip${Date.now()}`; + const transactionId = `INV/${new Date().getFullYear()}/${String(Math.floor(Math.random() * 1000)).padStart(3, '0')}`; + + console.log('Creating Investment:', { + id: invId, + investorId: investor.id, + ...newInvestment, + actualEarnings: 0, + status: 'active' as const, + transactionId: transactionId, + createdAt: new Date().toISOString() + }); + + console.log('Accounting Entry:', { + entryId: `AC-${Date.now()}`, + type: 'investment_created', + investorId: investor.id, + investmentId: invId, + amount: newInvestment.totalInvestment, + debitAccount: 'Investment Asset - Investor', + creditAccount: newInvestment.paymentMethod === 'bank' ? 'Bank Account' : 'Cash Account', + transactionRef: transactionId, + createdAt: new Date().toISOString() + }); + + alert(`Investment created successfully!\n\nInvestment ID: ${invId}\nTransaction Ref: ${transactionId}\nAmount: ৳${newInvestment.totalInvestment.toLocaleString()}\n\nAccounting entries have been logged.`); + setShowCreateInvestmentModal(false); + setNewInvestment({ + planName: '', + planType: 'gold', + selectedBikeIds: [], + totalInvestment: 0, + monthlyReturn: 0, + expectedRoi: 15, + startDate: new Date().toISOString().split('T')[0], + endDate: '', + paymentMethod: 'bank', + transactionReference: '', + notes: '' + }); + }; + return (
• Debit: Investment Asset - Investor ({newInvestment.totalInvestment ? `৳${newInvestment.totalInvestment.toLocaleString()}` : '৳0'})
+• Credit: {newInvestment.paymentMethod === 'bank' ? 'Bank Account' : newInvestment.paymentMethod === 'mobile' ? 'Mobile Wallet' : newInvestment.paymentMethod === 'cash' ? 'Cash Account' : 'Cheque Receivable'} ({newInvestment.totalInvestment ? `৳${newInvestment.totalInvestment.toLocaleString()}` : '৳0'})
+• Transaction ID will be auto-generated
+