fix: require BAP before original PDF exports
This commit is contained in:
26
shared/bapExportGuard.ts
Normal file
26
shared/bapExportGuard.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user