fix: exportStatus mis à jour à 'exported' après validation BAP (unitaire et en masse)

This commit is contained in:
Manus
2026-06-16 12:18:40 -04:00
parent 22b34fcf1e
commit 1a09c98ef5

View File

@@ -616,9 +616,11 @@ export const appRouter = router({
// ── Mise à jour de la facture ─────────────────────────────────────
const validatedAt = new Date();
const newExportStatus = (exportPath || pdfUrl) ? 'exported' : 'not_exported';
await updateInvoice(input.id, {
bapValidated: 1,
bapValidatedAt: validatedAt,
exportStatus: newExportStatus as any,
});
// ── Enregistrement dans l'historique BAP ─────────────────────────
@@ -816,7 +818,8 @@ export const appRouter = router({
console.warn(`[BAP Bulk] Erreur PDF facture ${invoice.id}:`, pdfError.message);
}
// Mise à jour de la facture
await updateInvoice(invoice.id, { bapValidated: 1, bapValidatedAt: validatedAt });
const bulkExportStatus = (exportPath || pdfUrl) ? 'exported' : 'not_exported';
await updateInvoice(invoice.id, { bapValidated: 1, bapValidatedAt: validatedAt, exportStatus: bulkExportStatus as any });
// Historique
await createBapHistoryEntry({
userId: ctx.user.id,