mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
feat(commandes-auto): cadencier d'alertes de commande par fournisseur et magasin
Ajoute un onglet "Cadencier / Alertes" dans la page Commandes auto. Depuis la liste des fournisseurs, on active un fournisseur en alerte de commande sur un magasin (292/579) avec une fréquence en X semaines, gérée indépendamment par magasin. L'échéance est calculée à partir de la dernière réception réelle (mvtart, genremvt 1/2, fournisseur principal artfou1.preference=1) + X semaines. Statut: à commander / bientôt / OK, avec temps restant. - Table commande_cadences (schema + db-init) - pgGetDerniereReceptionParFournisseur (mvtart par fournisseur/site) - Server actions CRUD (list/upsert/toggle/remove) - UI à onglets + cadencier (ajout, édition intervalle, activer/supprimer)
This commit is contained in:
7 files changed
+668
-4
No files matched your search
@@ -74,6 +74,28 @@ async function main() {
|
||||
`);
|
||||
console.log("[DB Init] Table users is verified/created.");
|
||||
|
||||
await tempPool.query(`
|
||||
CREATE TABLE IF NOT EXISTS "commande_cadences" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"code_fournisseur" varchar(20) NOT NULL,
|
||||
"nom_fournisseur" varchar(255),
|
||||
"site" varchar(20) NOT NULL,
|
||||
"intervalle_semaines" integer NOT NULL,
|
||||
"actif" boolean NOT NULL DEFAULT true,
|
||||
"created_at" timestamp DEFAULT now(),
|
||||
"updated_at" timestamp DEFAULT now()
|
||||
);
|
||||
`);
|
||||
await tempPool.query(`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "uq_cadence_fou_site"
|
||||
ON "commande_cadences" ("code_fournisseur", "site");
|
||||
`);
|
||||
await tempPool.query(`
|
||||
CREATE INDEX IF NOT EXISTS "idx_cadence_site"
|
||||
ON "commande_cadences" ("site");
|
||||
`);
|
||||
console.log("[DB Init] Table commande_cadences is verified/created.");
|
||||
|
||||
await tempPool.end();
|
||||
console.log("[DB Init] Initialization successful. Exiting.");
|
||||
process.exit(0);
|
||||
|
||||
Reference in new issue
Block a user