feat: purge import history by retention

This commit is contained in:
Manus
2026-10-09 10:22:46 +00:00
parent 6d72547509
commit 16759b4ad5
6 changed files with 176 additions and 20 deletions

View File

@@ -0,0 +1,21 @@
export const IMPORT_LOG_RETENTION_OPTIONS = [3, 6, 12] as const;
export type ImportLogRetentionMonths = (typeof IMPORT_LOG_RETENTION_OPTIONS)[number];
export function isImportLogRetentionMonths(value: number): value is ImportLogRetentionMonths {
return IMPORT_LOG_RETENTION_OPTIONS.includes(value as ImportLogRetentionMonths);
}
/**
* Retourne la borne calendaire exclusive de la purge : les journaux strictement
* antérieurs à cette date peuvent être supprimés. Les factures et PDF ne sont
* jamais concernés par cette politique de rétention.
*/
export function getImportLogRetentionCutoff(
months: ImportLogRetentionMonths,
referenceDate = new Date(),
): Date {
const cutoff = new Date(referenceDate);
cutoff.setMonth(cutoff.getMonth() - months);
return cutoff;
}