mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
feat: add commandes-auto audit with franco_ht filtering to GET route
This commit is contained in:
1 parent
2cbf8a753a
commit
33ff92aec0
1 file changed
+25
@@ -221,6 +221,30 @@ export async function GET(req: NextRequest) {
|
||||
francoDiag = { error: String(e) };
|
||||
}
|
||||
|
||||
// Raw commandes-auto : récupère toutes les lignes et filtre celles avec franco_ht manquant
|
||||
let commandesAutoFrancoAudit: unknown;
|
||||
try {
|
||||
const caRes = await fetch(`${FF_API_BASE}/api/commandes-auto`, { cache: "no-store" });
|
||||
const caData = await caRes.json();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const caRows: any[] = Array.isArray(caData) ? caData : (caData?.propositions ?? caData?.data ?? []);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const withFranco = caRows.filter((r: any) => r.franco_ht != null && Number(r.franco_ht) > 0);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const withoutFranco = caRows.filter((r: any) => r.franco_ht == null || Number(r.franco_ht) === 0);
|
||||
commandesAutoFrancoAudit = {
|
||||
total: caRows.length,
|
||||
avecFranco: withFranco.length,
|
||||
sansFranco: withoutFranco.length,
|
||||
lignesSansFranco: withoutFranco.map((r: any) => ({
|
||||
site: r.site, codefou: r.codefou, nom_fou: r.nom_fou,
|
||||
franco_ht: r.franco_ht, franco_atteint: r.franco_atteint,
|
||||
})),
|
||||
};
|
||||
} catch (e) {
|
||||
commandesAutoFrancoAudit = { error: String(e) };
|
||||
}
|
||||
|
||||
// Raw commandes-auto (premier fournisseur) pour voir les champs réels retournés par l'API
|
||||
const rawCommandesAuto = await probe(`${FF_API_BASE}/api/commandes-auto`);
|
||||
|
||||
@@ -246,5 +270,6 @@ export async function GET(req: NextRequest) {
|
||||
mvtartDiag,
|
||||
francoDiag,
|
||||
rawCommandesAuto,
|
||||
commandesAutoFrancoAudit,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user