mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Synchronize order and delivery statuses and dates in the calendar view
Fixes an issue where orders linked to delivered deliveries were not displaying the correct delivery date or status in the calendar. This includes updating the OrderDetailModal to show the correct dates, automatically updating order statuses when deliveries are marked as delivered, and providing a SQL script to correct existing data inconsistencies. 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/0tRkXvo
This commit is contained in:
1 parent
0e2f017305
commit
d14a4a31f6
6 files changed
+128
-2
No files matched your search
@@ -640,11 +640,27 @@ export class DatabaseStorage implements IStorage {
|
||||
}
|
||||
|
||||
async updateDelivery(id: number, delivery: Partial<InsertDelivery>): Promise<Delivery> {
|
||||
const currentDelivery = await this.getDelivery(id);
|
||||
if (!currentDelivery) throw new Error("Delivery not found");
|
||||
|
||||
const [updatedDelivery] = await db
|
||||
.update(deliveries)
|
||||
.set({ ...delivery, updatedAt: new Date() })
|
||||
.where(eq(deliveries.id, id))
|
||||
.returning();
|
||||
|
||||
// Si la livraison est marquée comme livrée et qu'elle est liée à une commande
|
||||
if (delivery.status === 'delivered' && currentDelivery.orderId) {
|
||||
console.log('🔄 Delivery marked as delivered, updating linked order status');
|
||||
await db
|
||||
.update(orders)
|
||||
.set({
|
||||
status: 'delivered',
|
||||
updatedAt: new Date()
|
||||
})
|
||||
.where(eq(orders.id, currentDelivery.orderId));
|
||||
}
|
||||
|
||||
return updatedDelivery;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user