diff --git a/backend/src/routes/companies.ts b/backend/src/routes/companies.ts index 88337c4..b89664b 100644 --- a/backend/src/routes/companies.ts +++ b/backend/src/routes/companies.ts @@ -30,7 +30,7 @@ router.get('/', wrap(async (_req: AuthRequest, res: Response): Promise => router.post('/', validate(companySchema), wrap(async (req: AuthRequest, res: Response): Promise => { const { name, email, extra_emails } = req.body; const result = await db.query( - `INSERT INTO companies (name, email, extra_emails) VALUES ($1, $2, $3) RETURNING *`, + `INSERT INTO companies (name, email, extra_emails) VALUES ($1, $2, $3::text[]) RETURNING *`, [name, email, extra_emails] ); res.status(201).json(result.rows[0]); @@ -41,7 +41,7 @@ router.put('/:id', validate(companySchema), wrap(async (req: AuthRequest, res: R const { name, email, extra_emails } = req.body; const result = await db.query( `UPDATE companies - SET name=$1, email=$2, extra_emails=$3, updated_at=NOW() + SET name=$1, email=$2, extra_emails=$3::text[], updated_at=NOW() WHERE id=$4 AND is_active=TRUE RETURNING *`, [name, email, extra_emails, req.params.id] diff --git a/frontend/src/pages/MyInvoices.tsx b/frontend/src/pages/MyInvoices.tsx index b344f4c..bf490f4 100644 --- a/frontend/src/pages/MyInvoices.tsx +++ b/frontend/src/pages/MyInvoices.tsx @@ -436,6 +436,15 @@ export default function MyInvoices() { const total = listData?.total ?? 0; const totalPages = Math.ceil(total / PAGE_SIZE) || 1; + // Total cumulé par ligne (somme de toutes les lignes précédentes + la ligne courante) + const runningTotals = useMemo(() => { + let sum = 0; + return invoices.map(inv => { + sum += Number(inv.amount) || 0; + return sum; + }); + }, [invoices]); + // Compact page buttons (up to 5 around current) const pageButtons = useMemo(() => { if (totalPages <= 5) return Array.from({ length: totalPages }, (_, i) => i + 1); @@ -654,6 +663,9 @@ export default function MyInvoices() { + + Montant add + Statut @@ -663,7 +675,7 @@ export default function MyInvoices() { - {invoices.map((inv) => ( + {invoices.map((inv, idx) => ( {/* Date d'envoi */} @@ -691,6 +703,11 @@ export default function MyInvoices() { {fmtAmount(inv.amount)} + {/* Montant add (total cumulé) */} + + {fmtAmount(runningTotals[idx])} + + {/* Statut */}