mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve reconciliation display and fix statistics calculations
Update reconciliation logic to use cache invalidation and refetch for immediate UI updates, and correct statistical calculations by using `deliveredDate` for monthly delivery metrics. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/csL8uKw
This commit is contained in:
1 parent
cc37f4cceb
commit
7fcd550147
4 files changed
+33
-19
No files matched your search
+10
-2
@@ -612,11 +612,12 @@ export class DatabaseStorage implements IStorage {
|
||||
try {
|
||||
console.log('📊 Calcul statistiques mensuelles:', { year, month, startDate, endDate, groupIds });
|
||||
|
||||
// Construire les conditions pour le filtrage par groupe
|
||||
// Construire les conditions pour le filtrage par groupe - UTILISER LE BON CHAMP DE DATE
|
||||
let ordersWhereCondition = and(
|
||||
gte(orders.plannedDate, startDate),
|
||||
lt(orders.plannedDate, endDate)
|
||||
);
|
||||
// Pour les livraisons, utiliser deliveredDate pour celles livrées, sinon scheduledDate
|
||||
let deliveriesWhereCondition = and(
|
||||
gte(deliveries.scheduledDate, startDate),
|
||||
lt(deliveries.scheduledDate, endDate)
|
||||
@@ -652,12 +653,19 @@ export class DatabaseStorage implements IStorage {
|
||||
.where(pendingWhereCondition);
|
||||
|
||||
// Calculer les totaux de palettes et colis du mois (SEULEMENT livraisons delivered)
|
||||
// IMPORTANT: Utiliser deliveredDate pour filtrer par le mois de livraison effective
|
||||
let deliveredWhereCondition = and(
|
||||
deliveriesWhereCondition,
|
||||
gte(deliveries.deliveredDate, startDate),
|
||||
lt(deliveries.deliveredDate, endDate),
|
||||
eq(deliveries.status, 'delivered'),
|
||||
isNotNull(deliveries.deliveredDate)
|
||||
);
|
||||
|
||||
// Ajouter le filtre par groupe pour les livraisons delivered
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
deliveredWhereCondition = and(deliveredWhereCondition, inArray(deliveries.groupId, groupIds));
|
||||
}
|
||||
|
||||
const deliveriesStatsResult = await db
|
||||
.select({
|
||||
totalPalettes: sql<number>`COALESCE(SUM(CAST(${deliveries.quantity} as INTEGER)), 0)`,
|
||||
|
||||
Reference in new issue
Block a user