fix: require BAP before original PDF exports

This commit is contained in:
Manus
2026-10-09 08:44:02 +00:00
parent e402233120
commit 939dddd1d8
6 changed files with 157 additions and 6 deletions

26
shared/bapExportGuard.ts Normal file
View File

@@ -0,0 +1,26 @@
/**
* Une facture hors abonnement doit être validée BAP avant l'export de son PDF
* d'origine. Les abonnements ne suivent pas le circuit BAP.
*/
export function requiresBapBeforeOriginalPdfExport(input: {
isSubscription?: number | boolean | null;
bapValidated?: number | boolean | null;
}): boolean {
const isSubscription = input.isSubscription === 1 || input.isSubscription === true;
const isBapValidated = input.bapValidated === 1 || input.bapValidated === true;
return !isSubscription && !isBapValidated;
}
/**
* Signale un export historique réalisé avant la validation BAP. Ce cas est
* conservé pour l'audit, mais l'interface doit rendre la régularisation BAP
* possible et explicite.
*/
export function wasExportedBeforeBap(input: {
exportStatus?: string | null;
isSubscription?: number | boolean | null;
bapValidated?: number | boolean | null;
}): boolean {
return input.exportStatus === "exported" && requiresBapBeforeOriginalPdfExport(input);
}