fix: extra_emails cast text[] + colonne Montant add cumule
This commit is contained in:
@@ -30,7 +30,7 @@ router.get('/', wrap(async (_req: AuthRequest, res: Response): Promise<void> =>
|
||||
router.post('/', validate(companySchema), wrap(async (req: AuthRequest, res: Response): Promise<void> => {
|
||||
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]
|
||||
|
||||
@@ -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() {
|
||||
<SortHeader label="Catégorie" field="category_name" current={sortBy} dir={sortDir} onSort={handleSort} />
|
||||
<SortHeader label="Fournisseur" field="supplier" current={sortBy} dir={sortDir} onSort={handleSort} />
|
||||
<SortHeader label="Montant" field="amount" current={sortBy} dir={sortDir} onSort={handleSort} right />
|
||||
<th className="px-3 py-3 text-right text-xs font-semibold text-indigo-400 uppercase tracking-wide whitespace-nowrap">
|
||||
Montant add
|
||||
</th>
|
||||
<th className="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wide whitespace-nowrap">
|
||||
Statut
|
||||
</th>
|
||||
@@ -663,7 +675,7 @@ export default function MyInvoices() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-50">
|
||||
{invoices.map((inv) => (
|
||||
{invoices.map((inv, idx) => (
|
||||
<tr key={inv.id} className="hover:bg-gray-50/60 transition-colors">
|
||||
|
||||
{/* Date d'envoi */}
|
||||
@@ -691,6 +703,11 @@ export default function MyInvoices() {
|
||||
{fmtAmount(inv.amount)}
|
||||
</td>
|
||||
|
||||
{/* Montant add (total cumulé) */}
|
||||
<td className="px-3 py-3 text-right tabular-nums whitespace-nowrap text-indigo-500 text-xs font-medium">
|
||||
{fmtAmount(runningTotals[idx])}
|
||||
</td>
|
||||
|
||||
{/* Statut */}
|
||||
<td className="px-3 py-3 whitespace-nowrap">
|
||||
<StatusBadge
|
||||
|
||||
Reference in New Issue
Block a user