Fix issue with reconciled task count in statistics module

Adjusted SQL query in DatabaseStorage.ts to correctly count reconciled tasks by removing the `OR reconciled = 1` condition, ensuring accurate data in the statistics module.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/jnL5Pt5
This commit is contained in:
michaelschal committed 2025-09-23 14:30:05 +00:00
1 parent 7bd864d1f6
commit 6f00d9fe3e
1 file changed
+1 -1
+1 -1
View File
@@ -2907,7 +2907,7 @@ export class DatabaseStorage implements IStorage {
const deliveryQuery = db.select({
count: sql<number>`COUNT(*)`,
totalAmount: sql<number>`COALESCE(SUM(CAST(bl_amount AS NUMERIC)), 0) + COALESCE(SUM(CAST(invoice_amount AS NUMERIC)), 0)`,
reconciled: sql<number>`COUNT(CASE WHEN reconciled = true OR reconciled = 1 THEN 1 END)`,
reconciled: sql<number>`COUNT(CASE WHEN reconciled = true THEN 1 END)`,
avgDelay: sql<number>`AVG(EXTRACT(EPOCH FROM (delivered_date - scheduled_date)) / 86400)` // days
}).from(deliveries);
if (deliveryConditions.length) deliveryQuery.where(and(...deliveryConditions));