mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 15:08:22 +02:00
Provide guide for immediate synchronization of order and delivery statuses
Add a guide document with SQL scripts and testing instructions for synchronizing order and delivery statuses, including fixing missing delivery dates. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/KuIk8gU
This commit is contained in:
1 parent
a512352d6b
commit
c648396f57
6 files changed
+366
No files matched your search
@@ -0,0 +1,38 @@
|
|||||||
|
# GUIDE URGENT : Synchronisation Commandes/Livraisons
|
||||||
|
|
||||||
|
## Problème
|
||||||
|
La commande #CMD-55 et d'autres commandes liées à des livraisons "livrées" n'apparaissent pas grisées dans le calendrier car elles gardent le statut "planned" au lieu de "delivered".
|
||||||
|
|
||||||
|
## Solution Immédiate (Production)
|
||||||
|
|
||||||
|
### Option 1: Script SQL Direct ✅ RECOMMANDÉ
|
||||||
|
```bash
|
||||||
|
# Connectez-vous à votre base PostgreSQL et exécutez :
|
||||||
|
psql $DATABASE_URL -f fix-delivery-order-sync-immediate.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Via Interface Web (après déploiement)
|
||||||
|
1. Déployez le nouveau code sur votre serveur
|
||||||
|
2. Connectez-vous comme admin sur https://logiflow-logiflow-1.c-2.us-east-2.aws.neon.tech
|
||||||
|
3. Allez dans le calendrier
|
||||||
|
4. Cliquez sur le bouton "Sync Status" (à côté de "Nouveau")
|
||||||
|
|
||||||
|
## Ce que fait le script
|
||||||
|
|
||||||
|
1. **Diagnostic** : Affiche toutes les commandes avec des livraisons livrées mais statut incorrect
|
||||||
|
2. **Correction automatique** : Met à jour le statut des commandes vers "delivered"
|
||||||
|
3. **Dates de livraison** : Corrige les delivered_date manquantes
|
||||||
|
4. **Vérification finale** : Affiche les résultats et la commande CMD-55 spécifiquement
|
||||||
|
|
||||||
|
## Résultat attendu
|
||||||
|
Après exécution du script :
|
||||||
|
- ✅ La commande #CMD-55 aura le statut "delivered"
|
||||||
|
- ✅ Elle apparaîtra grisée (bg-delivered) dans le calendrier
|
||||||
|
- ✅ Les dates de livraison seront affichées correctement
|
||||||
|
- ✅ Toutes les commandes similaires seront corrigées
|
||||||
|
|
||||||
|
## Test
|
||||||
|
Après avoir exécuté le script, actualisez votre calendrier sur https://logiflow-logiflow-1.c-2.us-east-2.aws.neon.tech et vérifiez que la commande CMD-55 apparaît maintenant grisée.
|
||||||
|
|
||||||
|
## Note Technique
|
||||||
|
Le bouton "Sync Status" dans l'interface n'est pas encore déployé sur votre serveur de production. Le script SQL est la solution immédiate.
|
||||||
+208
@@ -0,0 +1,208 @@
|
|||||||
|
ions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
Deliveries API called with: {
|
||||||
|
|
||||||
|
startDate: '2025-08-01',
|
||||||
|
|
||||||
|
endDate: '2025-08-31',
|
||||||
|
|
||||||
|
storeId: undefined,
|
||||||
|
|
||||||
|
withBL: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering deliveries with groupIds: undefined
|
||||||
|
|
||||||
|
Fetching deliveries by date range: 2025-08-01 to 2025-08-31
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
GET /api/user 304 in 67ms
|
||||||
|
|
||||||
|
GET /api/stats/monthly 304 in 57ms
|
||||||
|
|
||||||
|
Deliveries returned: 40 items
|
||||||
|
|
||||||
|
GET /api/deliveries 304 in 64ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
GET /api/user 304 in 5ms
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
Orders API called with: {
|
||||||
|
|
||||||
|
startDate: '2025-08-01',
|
||||||
|
|
||||||
|
endDate: '2025-08-31',
|
||||||
|
|
||||||
|
storeId: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering with groupIds: undefined
|
||||||
|
|
||||||
|
Fetching orders by date range: 2025-08-01 to 2025-08-31
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
GET /api/user 304 in 13ms
|
||||||
|
|
||||||
|
Orders returned: 15 items
|
||||||
|
|
||||||
|
GET /api/orders 304 in 111ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
GET /api/user 304 in 7ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
GET /api/groups 304 in 10ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 369 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
@@ -0,0 +1,74 @@
|
|||||||
|
-- Script de synchronisation immédiate des statuts commandes/livraisons
|
||||||
|
-- Exécuter directement sur la base de données de production
|
||||||
|
|
||||||
|
-- Étape 1: Diagnostic - Afficher les commandes problématiques
|
||||||
|
SELECT
|
||||||
|
o.id as order_id,
|
||||||
|
o.status as order_status,
|
||||||
|
d.id as delivery_id,
|
||||||
|
d.status as delivery_status,
|
||||||
|
d.delivered_date,
|
||||||
|
o.supplier_id,
|
||||||
|
s.name as supplier_name
|
||||||
|
FROM orders o
|
||||||
|
JOIN deliveries d ON d.order_id = o.id
|
||||||
|
JOIN suppliers s ON o.supplier_id = s.id
|
||||||
|
WHERE d.status = 'delivered' AND o.status != 'delivered'
|
||||||
|
ORDER BY o.id;
|
||||||
|
|
||||||
|
-- Étape 2: Mise à jour automatique des statuts
|
||||||
|
-- Marquer toutes les commandes comme "delivered" si au moins une de leurs livraisons est livrée
|
||||||
|
UPDATE orders
|
||||||
|
SET status = 'delivered'
|
||||||
|
WHERE id IN (
|
||||||
|
SELECT DISTINCT o.id
|
||||||
|
FROM orders o
|
||||||
|
JOIN deliveries d ON d.order_id = o.id
|
||||||
|
WHERE d.status = 'delivered' AND o.status != 'delivered'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Étape 3: Mise à jour des dates de livraison manquantes
|
||||||
|
-- Ajouter delivered_date aux livraisons qui ont le status 'delivered' mais pas de date
|
||||||
|
UPDATE deliveries
|
||||||
|
SET delivered_date = scheduled_date
|
||||||
|
WHERE status = 'delivered'
|
||||||
|
AND delivered_date IS NULL
|
||||||
|
AND scheduled_date IS NOT NULL;
|
||||||
|
|
||||||
|
-- Étape 4: Pour les livraisons sans scheduled_date, utiliser la date de création + 1 jour
|
||||||
|
UPDATE deliveries
|
||||||
|
SET delivered_date = DATE(created_at) + INTERVAL '1 day'
|
||||||
|
WHERE status = 'delivered'
|
||||||
|
AND delivered_date IS NULL
|
||||||
|
AND scheduled_date IS NULL;
|
||||||
|
|
||||||
|
-- Étape 5: Diagnostic final - Vérifier les résultats
|
||||||
|
SELECT
|
||||||
|
'RÉSULTAT FINAL' as status,
|
||||||
|
COUNT(*) as total_orders,
|
||||||
|
SUM(CASE WHEN status = 'delivered' THEN 1 ELSE 0 END) as delivered_orders,
|
||||||
|
SUM(CASE WHEN status = 'planned' THEN 1 ELSE 0 END) as planned_orders
|
||||||
|
FROM orders;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'LIVRAISONS MISES À JOUR' as status,
|
||||||
|
COUNT(*) as total_delivered_deliveries,
|
||||||
|
SUM(CASE WHEN delivered_date IS NOT NULL THEN 1 ELSE 0 END) as with_delivered_date,
|
||||||
|
SUM(CASE WHEN delivered_date IS NULL THEN 1 ELSE 0 END) as missing_delivered_date
|
||||||
|
FROM deliveries
|
||||||
|
WHERE status = 'delivered';
|
||||||
|
|
||||||
|
-- Afficher la commande CMD-55 spécifiquement
|
||||||
|
SELECT
|
||||||
|
'COMMANDE CMD-55' as status,
|
||||||
|
o.id,
|
||||||
|
o.status as order_status,
|
||||||
|
o.planned_date,
|
||||||
|
d.status as delivery_status,
|
||||||
|
d.delivered_date,
|
||||||
|
d.scheduled_date,
|
||||||
|
s.name as supplier
|
||||||
|
FROM orders o
|
||||||
|
LEFT JOIN deliveries d ON d.order_id = o.id
|
||||||
|
JOIN suppliers s ON o.supplier_id = s.id
|
||||||
|
WHERE o.id = 55;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// Script pour tester la synchronisation directement en production
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
const data = JSON.stringify({});
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
hostname: 'logiflow-logiflow-1.c-2.us-east-2.aws.neon.tech',
|
||||||
|
port: 443,
|
||||||
|
path: '/api/sync-order-delivery-status',
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Content-Length': Buffer.byteLength(data),
|
||||||
|
// Vous devez remplacer par votre cookie de session réel
|
||||||
|
'Cookie': 'connect.sid=VOTRE_SESSION_COOKIE_ICI'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('🔄 Testing production sync API...');
|
||||||
|
|
||||||
|
const req = https.request(options, (res) => {
|
||||||
|
console.log(`Status: ${res.statusCode}`);
|
||||||
|
console.log(`Headers:`, res.headers);
|
||||||
|
|
||||||
|
let responseData = '';
|
||||||
|
res.on('data', (chunk) => {
|
||||||
|
responseData += chunk;
|
||||||
|
});
|
||||||
|
|
||||||
|
res.on('end', () => {
|
||||||
|
console.log('Response:', responseData);
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(responseData);
|
||||||
|
console.log('✅ Sync result:', JSON.stringify(parsed, null, 2));
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Raw response:', responseData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (error) => {
|
||||||
|
console.error('❌ Error:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
req.write(data);
|
||||||
|
req.end();
|
||||||
Reference in new issue
Block a user