From 47e617afd397ed05c8f8fe62293615b83aedb9d6 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Wed, 18 Mar 2026 18:08:21 +0100 Subject: [PATCH] feat: restore reference, gtin, gamme initiale and nomenclature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit api-ff-client.ts: - FfArticle: add reference (ref_fou_principale) and gtin fields - getArticlesByFournisseur: map ref_fou_principale → reference, gtin → gtin get-product-rows.ts: - ProductRow seeded with reference and gtin from API articles - Phase 6: read codeGamme, codeGammeInit, code3, libelle3 from ventesProduits (read-only, DISTINCT ON codein ordered by updated_at DESC) - Phase 7 snapshot still overrides DB gammes when a snapshot exists Co-Authored-By: Claude Sonnet 4.6 --- src/features/grid/api/get-product-rows.ts | 34 +++++++++++++++++++---- src/lib/api-ff-client.ts | 18 +++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/features/grid/api/get-product-rows.ts b/src/features/grid/api/get-product-rows.ts index 7ff99d9..7b980bc 100644 --- a/src/features/grid/api/get-product-rows.ts +++ b/src/features/grid/api/get-product-rows.ts @@ -9,8 +9,8 @@ import { buildLast12MonthsRange, } from "@/lib/api-ff-client"; import { db } from "@/db"; -import { sessionSnapshots } from "@/db/schema"; -import { eq, desc } from "drizzle-orm"; +import { sessionSnapshots, ventesProduits } from "@/db/schema"; +import { eq, desc, sql } from "drizzle-orm"; interface GetProductRowsInput { codeFournisseur: string; @@ -53,8 +53,8 @@ export async function getProductRows(input: GetProductRowsInput): Promise ({ - codein: r.codein ?? r.Codein ?? r.code_article ?? r.codeArticle ?? String(r.id ?? ""), - libelle1: r.libelle1 ?? r.Libelle1 ?? r.libelle ?? r.designation ?? r.nom ?? "", - codefou: r.codefou_principal ?? r.codefou ?? r.Codefou ?? r.code_fournisseur ?? r.codeFournisseur ?? codefou, - nomfou: r.nom_fou_principal ?? r.nomfou ?? r.Nomfou ?? r.nom_fournisseur ?? r.nomFournisseur ?? "", - pcb: r.pcb_principal ?? r.pcb ?? r.Pcb ?? r.conditionnement ?? r.colisage, - pv_central: r.pv_central ?? r.PvCentral ?? r.pv ?? r.prixVente, + codein: r.codein ?? r.Codein ?? r.code_article ?? r.codeArticle ?? String(r.id ?? ""), + libelle1: r.libelle1 ?? r.Libelle1 ?? r.libelle ?? r.designation ?? r.nom ?? "", + codefou: r.codefou_principal ?? r.codefou ?? r.Codefou ?? r.code_fournisseur ?? r.codeFournisseur ?? codefou, + nomfou: r.nom_fou_principal ?? r.nomfou ?? r.Nomfou ?? r.nom_fournisseur ?? r.nomFournisseur ?? "", + pcb: r.pcb_principal ?? r.pcb ?? r.Pcb ?? r.conditionnement ?? r.colisage, + pv_central: r.pv_central ?? r.PvCentral ?? r.pv ?? r.prixVente, noid: r.no_id ?? r.noid ?? r.NoId, + reference: r.ref_fou_principale ?? r.reference ?? r.ref_fournisseur ?? undefined, + gtin: r.gtin ?? r.Gtin ?? r.ean ?? r.barcode ?? undefined, })).filter(a => a.codein); }