mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Display all product details for sales in history
Modify the sales history component to correctly display the type, category, and quantity for each product within a sale, and update the storage to return sales with their associated products. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a388004f-01c5-42b1-b1d1-f18daf8bdd0c Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/a388004f-01c5-42b1-b1d1-f18daf8bdd0c/pSitqax
This commit is contained in:
1 parent
b9ae743ffb
commit
01c005adea
3 files changed
+47
-9
No files matched your search
+8
-2
@@ -520,7 +520,7 @@ class MemStorage implements IStorage {
|
||||
return newSale;
|
||||
}
|
||||
|
||||
async getSalesByStore(storeId: number, startDate?: string, endDate?: string): Promise<Sale[]> {
|
||||
async getSalesByStore(storeId: number, startDate?: string, endDate?: string): Promise<(Sale & { products: SaleProduct[] })[]> {
|
||||
let filteredSales = this.sales.filter(s => s.storeId === storeId);
|
||||
|
||||
if (startDate) {
|
||||
@@ -534,7 +534,13 @@ class MemStorage implements IStorage {
|
||||
filteredSales = filteredSales.filter(s => s.timestamp && s.timestamp <= end);
|
||||
}
|
||||
|
||||
return filteredSales.sort((a, b) => (b.timestamp?.getTime() || 0) - (a.timestamp?.getTime() || 0));
|
||||
// Add products to each sale
|
||||
const salesWithProducts = filteredSales.map(sale => ({
|
||||
...sale,
|
||||
products: this.saleProducts.filter(p => p.saleId === sale.id)
|
||||
}));
|
||||
|
||||
return salesWithProducts.sort((a, b) => (b.timestamp?.getTime() || 0) - (a.timestamp?.getTime() || 0));
|
||||
}
|
||||
|
||||
async getSaleWithProducts(id: number): Promise<(Sale & { products: SaleProduct[] }) | undefined> {
|
||||
|
||||
Reference in new issue
Block a user