Add photo data to Excel exports and correct database column mappings

Adds a "Photos" sheet to Excel exports with links to images and fixes DB column mappings for sales photos.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e80fed01-7137-4997-b9af-dad57132d430
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/e80fed01-7137-4997-b9af-dad57132d430/z4eyzzt
This commit is contained in:
michaelschal committed 2025-07-19 11:28:02 +00:00
1 parent 58a06455f6
commit 91f5c13f33
4 files changed
+73 -42

No files matched your search

-39
View File
@@ -172,8 +172,6 @@ export class DatabaseStorage implements IStorage {
}
async getSalesByStore(storeId: number, startDate?: string, endDate?: string): Promise<Sale[]> {
console.log('DEBUG: getSalesByStore called with storeId:', storeId, 'startDate:', startDate, 'endDate:', endDate);
let query = db.select().from(sales).where(eq(sales.storeId, storeId));
if (startDate && endDate) {
@@ -191,7 +189,6 @@ export class DatabaseStorage implements IStorage {
}
const salesData = await query.orderBy(desc(sales.timestamp));
console.log('DEBUG: Raw sales data count:', salesData.length);
// Get products for each sale and map photo column names correctly
const salesWithProducts = await Promise.all(
@@ -207,32 +204,14 @@ export class DatabaseStorage implements IStorage {
products
};
if (sale.id === 17) {
console.log('DEBUG: Sale 17 photo mapping:', {
original_photo_recto: sale.photo_recto ? 'PRESENT' : 'NULL',
original_photo_verso: sale.photo_verso ? 'PRESENT' : 'NULL',
original_photo_ticket: sale.photo_ticket ? 'PRESENT' : 'NULL',
mapped_photoRecto: mappedSale.photoRecto ? 'PRESENT' : 'NULL',
mapped_photoVerso: mappedSale.photoVerso ? 'PRESENT' : 'NULL',
mapped_photoTicket: mappedSale.photoTicket ? 'PRESENT' : 'NULL'
});
}
return mappedSale;
})
);
const salesWithPhotos = salesWithProducts.filter(s => s.photoRecto || s.photoVerso || s.photoTicket);
console.log('DEBUG: Sales with photos found:', salesWithPhotos.length);
if (salesWithPhotos.length > 0) {
console.log('DEBUG: First sale with photos:', salesWithPhotos[0].id);
}
return salesWithProducts;
}
async getAllSales(storeId?: number): Promise<any[]> {
console.log('DEBUG: getAllSales called with storeId:', storeId);
// Récupérer les ventes avec leurs produits
const query = db
.select({
@@ -277,14 +256,6 @@ export class DatabaseStorage implements IStorage {
const salesMap = new Map();
results.forEach(row => {
if (row.id === 17) {
console.log('DEBUG: Row data for sale 17:', {
id: row.id,
photoRecto: row.photoRecto ? 'PRESENT' : 'NULL',
photoVerso: row.photoVerso ? 'PRESENT' : 'NULL',
photoTicket: row.photoTicket ? 'PRESENT' : 'NULL'
});
}
if (!salesMap.has(row.id)) {
salesMap.set(row.id, {
id: row.id,
@@ -321,16 +292,6 @@ export class DatabaseStorage implements IStorage {
});
const result = Array.from(salesMap.values());
const saleWithPhotos = result.find(s => s.photoRecto || s.photoVerso || s.photoTicket);
console.log('DEBUG: Total sales returned:', result.length);
console.log('DEBUG: Sample sale with photos:', saleWithPhotos);
if (saleWithPhotos) {
console.log('DEBUG: Photos found in sale:', saleWithPhotos.id, {
photoRecto: saleWithPhotos.photoRecto ? 'PRESENT' : 'NULL',
photoVerso: saleWithPhotos.photoVerso ? 'PRESENT' : 'NULL',
photoTicket: saleWithPhotos.photoTicket ? 'PRESENT' : 'NULL'
});
}
return result;
}