mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Fix date filtering for statistics to correctly display data
Adjust date filtering logic in storage modules to correctly handle and compare date values, resolving issues with displaying 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:
1 parent
3bd40f6c35
commit
7bd864d1f6
3 files changed
+30
-14
No files matched your search
@@ -27,10 +27,6 @@ externalPort = 3000
|
||||
localPort = 38451
|
||||
externalPort = 3002
|
||||
|
||||
[[ports]]
|
||||
localPort = 41035
|
||||
externalPort = 5000
|
||||
|
||||
[[ports]]
|
||||
localPort = 41343
|
||||
externalPort = 3001
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
+30
-10
@@ -2876,12 +2876,14 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
// Apply filters
|
||||
if (filters.startDate) {
|
||||
orderConditions.push(gte(orders.plannedDate, filters.startDate));
|
||||
deliveryConditions.push(gte(deliveries.scheduledDate, filters.startDate));
|
||||
const startDateStr = filters.startDate.toISOString().split('T')[0];
|
||||
orderConditions.push(gte(orders.plannedDate, startDateStr));
|
||||
deliveryConditions.push(gte(deliveries.scheduledDate, startDateStr));
|
||||
}
|
||||
if (filters.endDate) {
|
||||
orderConditions.push(lte(orders.plannedDate, filters.endDate));
|
||||
deliveryConditions.push(lte(deliveries.scheduledDate, filters.endDate));
|
||||
const endDateStr = filters.endDate.toISOString().split('T')[0];
|
||||
orderConditions.push(lte(orders.plannedDate, endDateStr));
|
||||
deliveryConditions.push(lte(deliveries.scheduledDate, endDateStr));
|
||||
}
|
||||
if (filters.supplierIds?.length) {
|
||||
orderConditions.push(inArray(orders.supplierId, filters.supplierIds));
|
||||
@@ -3053,8 +3055,14 @@ export class DatabaseStorage implements IStorage {
|
||||
groupIds?: number[];
|
||||
}): Promise<Array<{ supplierId: number; supplierName: string; deliveries: number; amount: number }>> {
|
||||
const conditions: any[] = [];
|
||||
if (filters.startDate) conditions.push(gte(deliveries.scheduledDate, filters.startDate));
|
||||
if (filters.endDate) conditions.push(lte(deliveries.scheduledDate, filters.endDate));
|
||||
if (filters.startDate) {
|
||||
const startDateStr = filters.startDate.toISOString().split('T')[0];
|
||||
conditions.push(gte(deliveries.scheduledDate, startDateStr));
|
||||
}
|
||||
if (filters.endDate) {
|
||||
const endDateStr = filters.endDate.toISOString().split('T')[0];
|
||||
conditions.push(lte(deliveries.scheduledDate, endDateStr));
|
||||
}
|
||||
if (filters.groupIds?.length) conditions.push(inArray(deliveries.groupId, filters.groupIds));
|
||||
|
||||
const query = db.select({
|
||||
@@ -5146,8 +5154,14 @@ export class MemStorage implements IStorage {
|
||||
|
||||
// Apply filters
|
||||
const filteredOrders = orders.filter(order => {
|
||||
if (filters.startDate && order.plannedDate < filters.startDate) return false;
|
||||
if (filters.endDate && order.plannedDate > filters.endDate) return false;
|
||||
if (filters.startDate) {
|
||||
const orderDate = new Date(order.plannedDate);
|
||||
if (orderDate < filters.startDate) return false;
|
||||
}
|
||||
if (filters.endDate) {
|
||||
const orderDate = new Date(order.plannedDate);
|
||||
if (orderDate > filters.endDate) return false;
|
||||
}
|
||||
if (filters.supplierIds?.length && !filters.supplierIds.includes(order.supplierId)) return false;
|
||||
if (filters.groupIds?.length && !filters.groupIds.includes(order.groupId)) return false;
|
||||
if (filters.status?.length && !filters.status.includes(order.status)) return false;
|
||||
@@ -5155,8 +5169,14 @@ export class MemStorage implements IStorage {
|
||||
});
|
||||
|
||||
const filteredDeliveries = deliveries.filter(delivery => {
|
||||
if (filters.startDate && delivery.scheduledDate < filters.startDate) return false;
|
||||
if (filters.endDate && delivery.scheduledDate > filters.endDate) return false;
|
||||
if (filters.startDate) {
|
||||
const deliveryDate = new Date(delivery.scheduledDate);
|
||||
if (deliveryDate < filters.startDate) return false;
|
||||
}
|
||||
if (filters.endDate) {
|
||||
const deliveryDate = new Date(delivery.scheduledDate);
|
||||
if (deliveryDate > filters.endDate) return false;
|
||||
}
|
||||
if (filters.supplierIds?.length && !filters.supplierIds.includes(delivery.supplierId)) return false;
|
||||
if (filters.groupIds?.length && !filters.groupIds.includes(delivery.groupId)) return false;
|
||||
if (filters.status?.length && !filters.status.includes(delivery.status)) return false;
|
||||
|
||||
Reference in new issue
Block a user