Some checks failed
Validation applicative / TypeScript, tests et build (push) Failing after 1m54s
29 lines
1.5 KiB
TypeScript
29 lines
1.5 KiB
TypeScript
import fs from "node:fs";
|
|
import { extractPayrollBulletins } from "../server/payrollParser";
|
|
import { extractPayrollPdfText } from "../server/payrollPdfText";
|
|
|
|
const filePath = process.argv[2];
|
|
if (!filePath) throw new Error("Chemin PDF requis");
|
|
|
|
const text = await extractPayrollPdfText(fs.readFileSync(filePath));
|
|
const extraction = extractPayrollBulletins(text);
|
|
const lines = text.split(/\r?\n/);
|
|
const redactStructure = (line: string) => line.replace(/[A-Za-zÀ-ÿ]/g, "x").replace(/\d/g, "#").slice(0, 240);
|
|
const prohibitedPosteContent = extraction.bulletins.some((bulletin) => /iban|rib|n°\s*ss|adresse|fr\d{2}/i.test(bulletin.poste));
|
|
console.log(JSON.stringify({
|
|
bulletins: extraction.bulletins.length,
|
|
statutExtraction: extraction.statutExtraction,
|
|
hasExtractionWarning: Boolean(extraction.erreurExtraction),
|
|
containsProhibitedPosteContent: prohibitedPosteContent,
|
|
preservedPageSeparators: (text.match(/\f/g) ?? []).length,
|
|
bulletinMarkers: (text.match(/##BULLETIN##/g) ?? []).length,
|
|
matriculeMatchCount: (text.match(/Matricule\s*:\s*(?:M|N|N°)?\s*\d+/g) ?? []).length,
|
|
emploiSameLineCount: lines.filter((line) => /Emploi\s*:.*(?:Monsieur|Madame)\b/i.test(line)).length,
|
|
baseLineCount: lines.filter((line) => line.trim().startsWith("Salaire de base")).length,
|
|
grossLineCount: lines.filter((line) => line.trim().startsWith("Salaire brut")).length,
|
|
emploiVicinityStructures: lines
|
|
.flatMap((line, index) => /Emploi\s*:/i.test(line) ? lines.slice(index, index + 4) : [])
|
|
.slice(0, 8)
|
|
.map(redactStructure),
|
|
}));
|