mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 10:49:10 +02:00
Add extensive logging to the storage layer and backend routes to diagnose and resolve an issue where customer orders and DLC products are being assigned to store #1 instead of the intended store #2, even when created by users associated with store #2. This includes detailed console logs within the `createCustomerOrder` and `createDlcProduct` functions in both the routes and storage layers, focusing on the `groupId` before and after database operations. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/32z3sin
2.2 KiB
2.2 KiB
Debug Production Storage - GroupId Mystery
Problème Production
Utilisateur assigné magasin #2 crée DLC/commandes → apparaît magasin #1
Analyse Couche Storage
Il y a 2 implémentations storage :
1. MemStorage (Développement)
async createDlcProduct(dlcProduct: any): Promise<any> {
const newProduct = { id, ...dlcProduct, createdAt, updatedAt };
// Enregistre directement les données passées
}
2. Drizzle ORM (Production)
async createDlcProduct(dlcProductData: InsertDlcProductFrontend): Promise<DlcProductFrontend> {
const { dlcDate, ...restData } = dlcProductData as any;
const [dlcProduct] = await db.insert(dlcProducts).values({
...restData, // ⚠️ SI restData.groupId = 1, il sera enregistré tel quel
expiryDate: dlcDate,
});
}
Hypothèses du Problème
- Frontend envoie groupId: 1 malgré les corrections
- Backend force finalGroupId: 2 mais quelque chose le rechange
- Storage reçoit groupId: 1 et l'enregistre tel quel
- Base de données a une contrainte/trigger qui force groupId: 1
Debug Ajouté
1. Logs Storage Drizzle (Production)
console.log("🔍 STORAGE DEBUG - DLC insertData:", insertData);
console.log("🔍 STORAGE DEBUG - DLC insertData.groupId:", insertData.groupId, typeof insertData.groupId);
console.log("🔍 STORAGE DEBUG - DLC returned from DB:", dlcProduct);
console.log("🔍 STORAGE DEBUG - DLC returned groupId:", dlcProduct.groupId, typeof dlcProduct.groupId);
2. Même Logs pour Customer Orders
Plan de Debug Production
- ✅ Logs routse backend - Voir finalGroupId calculé
- ✅ Logs storage layer - Voir données envoyées à DB
- ✅ Logs retour DB - Voir ce que la DB retourne
- 🔄 Déployer en production
- 🧪 Tester création DLC/commande avec employé magasin #2
- 📋 Analyser logs complets pour identifier où groupId change
Résultat Attendu
Les logs révéleront :
- Frontend calcule-t-il groupId: 2 ?
- Backend force-t-il finalGroupId: 2 ?
- Storage reçoit-il groupId: 2 ?
- DB retourne-t-elle groupId: 1 ou 2 ?
POINT DE RUPTURE IDENTIFIÉ = PROBLÈME RÉSOLU