mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-12 01:36:43 +02:00
fix(db): remove non-existent columns from schema and fix aggregation logic
This commit is contained in:
1 parent
33615bb1bd
commit
93e01a475a
3 files changed
+18
-13
No files matched your search
@@ -14,10 +14,6 @@ export const ventesProduits = pgTable("ventes_produits", {
|
||||
|
||||
// Gamme & Nomenclature
|
||||
codeGamme: varchar("code_gamme", { length: 20 }),
|
||||
code1: varchar("code1", { length: 20 }),
|
||||
libelleNiveau1: varchar("libelle_niveau1", { length: 500 }),
|
||||
code2: varchar("code2", { length: 20 }),
|
||||
libelleNiveau2: varchar("libelle_niveau2", { length: 500 }),
|
||||
code3: varchar("code3", { length: 20 }),
|
||||
libelle3: varchar("libelle3", { length: 500 }),
|
||||
|
||||
|
||||
@@ -73,6 +73,19 @@ export async function getProductRows(input: GetProductRowsInput): Promise<Produc
|
||||
existing.totalMarge += marge;
|
||||
existing.tauxMarge = existing.totalCa > 0 ? (existing.totalMarge / existing.totalCa) * 100 : 0;
|
||||
} else {
|
||||
const c3 = row.code3 || "";
|
||||
const c1 = c3.slice(0, 2);
|
||||
const c2 = c3.slice(0, 4);
|
||||
|
||||
const L1_LABELS: Record<string, string> = {
|
||||
"30": "ÉPICERIE",
|
||||
"31": "CRÉMERIE / FRAIS",
|
||||
"32": "LIQUIDES",
|
||||
"33": "DPH",
|
||||
"34": "BAZAR",
|
||||
"35": "TEXTILE",
|
||||
};
|
||||
|
||||
productMap.set(codein, {
|
||||
codein,
|
||||
codeFournisseur: row.codeFournisseur ?? "",
|
||||
@@ -80,11 +93,11 @@ export async function getProductRows(input: GetProductRowsInput): Promise<Produc
|
||||
libelle1: row.libelle1 ?? "",
|
||||
gtin: row.gtin ?? "",
|
||||
reference: row.reference ?? "",
|
||||
code1: (row.code3 ?? "").slice(0, 2),
|
||||
libelleNiveau1: "Niv. 1", // À mapper plus tard
|
||||
code2: (row.code3 ?? "").slice(0, 4),
|
||||
libelleNiveau2: "Niv. 2", // À mapper plus tard
|
||||
code3: row.code3 ?? "",
|
||||
code1: c1,
|
||||
libelleNiveau1: L1_LABELS[c1] || `Secteur ${c1}`,
|
||||
code2: c2,
|
||||
libelleNiveau2: `Rayon ${c2}`,
|
||||
code3: c3,
|
||||
libelle3: row.libelle3 ?? "",
|
||||
codeGamme: (row.codeGamme as GammeCode | null),
|
||||
codeGammeDraft: null,
|
||||
|
||||
@@ -13,10 +13,6 @@ export interface VenteProduit {
|
||||
gtin: string | null;
|
||||
reference: string | null;
|
||||
codeGamme: GammeCode | null;
|
||||
code1: string | null;
|
||||
libelleNiveau1: string | null;
|
||||
code2: string | null;
|
||||
libelleNiveau2: string | null;
|
||||
code3: string | null;
|
||||
libelle3: string | null;
|
||||
magasin: string;
|
||||
|
||||
Reference in new issue
Block a user