Merge pull request #98 from R0m1k3/1.1

1.1
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-13 18:02:07 +02:00
commit 6ad1eefafb
4 files changed
+178 -20

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

+1 -1
View File
@@ -2,4 +2,4 @@
# https://curl.se/docs/http-cookies.html # https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk. # This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE / FALSE 1755183185 connect.sid s%3AxTPuuN1dUat5K1LvTsYkjYaDC926cZjY.4W%2BK%2BIU7DM07t06FKGvyXRrE8Qinz%2FxfWhQvEdYD89w #HttpOnly_localhost FALSE / FALSE 1755183951 connect.sid s%3A5AoIK-t2wOxXHZXR8IfvVc8xyfwMVSB8.wszhmo%2FyUviNdYS5uw4KwFZ7AoexEQiDD3olvfqQfHM
+1 -5
View File
@@ -7,11 +7,7 @@ import type { Permission, Module } from '@shared/permissions';
// Interface pour les requêtes authentifiées // Interface pour les requêtes authentifiées
interface AuthRequest extends Request { interface AuthRequest extends Request {
user: { user: any;
id: string;
role: string;
claims?: { sub: string };
};
} }
// Middleware pour vérifier l'accès à un module // Middleware pour vérifier l'accès à un module
+176 -14
View File
@@ -129,6 +129,7 @@ export interface IStorage {
// Invoice Verification Cache operations // Invoice Verification Cache operations
getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined>; getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined>;
saveInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache>;
createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache>; createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache>;
clearExpiredCache(): Promise<void>; clearExpiredCache(): Promise<void>;
@@ -940,6 +941,10 @@ export class DatabaseStorage implements IStorage {
return cache; return cache;
} }
async saveInvoiceVerificationCache(cacheData: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> {
return this.createInvoiceVerificationCache(cacheData);
}
async clearExpiredCache(): Promise<void> { async clearExpiredCache(): Promise<void> {
await db.delete(invoiceVerificationCache).where( await db.delete(invoiceVerificationCache).where(
sql`expires_at < NOW()` sql`expires_at < NOW()`
@@ -1228,6 +1233,12 @@ export class MemStorage implements IStorage {
}; };
this.users.set(adminUser.id, adminUser); this.users.set(adminUser.id, adminUser);
// Initialize group counter
this.idCounters.group = 2;
// Initialize supplier counter
this.idCounters.supplier = 2;
// Create test groups // Create test groups
const testGroup: Group = { const testGroup: Group = {
id: 1, id: 1,
@@ -1507,25 +1518,176 @@ export class MemStorage implements IStorage {
return newCache; return newCache;
} }
async saveInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> {
return this.createInvoiceVerificationCache(cache);
}
async clearExpiredCache(): Promise<void> { async clearExpiredCache(): Promise<void> {
// No-op en développement // No-op en développement
} }
// Placeholder implementations for remaining methods // MemStorage implementations with actual data handling
async getOrders(): Promise<OrderWithRelations[]> { return []; } async getOrders(groupIds?: number[]): Promise<OrderWithRelations[]> {
async getOrdersByDateRange(): Promise<OrderWithRelations[]> { return []; } let orders = Array.from(this.orders.values());
async getOrder(): Promise<OrderWithRelations | undefined> { return undefined; } if (groupIds && groupIds.length > 0) {
async createOrder(): Promise<Order> { return {} as Order; } orders = orders.filter(order => groupIds.includes(order.groupId));
async updateOrder(): Promise<Order> { return {} as Order; } }
async deleteOrder(): Promise<void> {} return orders.map(order => ({
...order,
supplier: this.suppliers.get(order.supplierId),
group: this.groups.get(order.groupId),
creator: this.users.get(order.createdBy)
}));
}
async getDeliveries(): Promise<DeliveryWithRelations[]> { return []; } async getOrdersByDateRange(startDate: string, endDate: string, groupIds?: number[]): Promise<OrderWithRelations[]> {
async getDeliveriesByDateRange(): Promise<DeliveryWithRelations[]> { return []; } const start = new Date(startDate);
async getDelivery(): Promise<DeliveryWithRelations | undefined> { return undefined; } const end = new Date(endDate);
async createDelivery(): Promise<Delivery> { return {} as Delivery; } let orders = Array.from(this.orders.values()).filter(order => {
async updateDelivery(): Promise<Delivery> { return {} as Delivery; } const orderDate = new Date(order.plannedDate);
async deleteDelivery(): Promise<void> {} return orderDate >= start && orderDate <= end;
async validateDelivery(): Promise<void> {} });
if (groupIds && groupIds.length > 0) {
orders = orders.filter(order => groupIds.includes(order.groupId));
}
return orders.map(order => ({
...order,
supplier: this.suppliers.get(order.supplierId),
group: this.groups.get(order.groupId),
creator: this.users.get(order.createdBy)
}));
}
async getOrder(id: number): Promise<OrderWithRelations | undefined> {
const order = this.orders.get(id);
if (!order) return undefined;
return {
...order,
supplier: this.suppliers.get(order.supplierId),
group: this.groups.get(order.groupId),
creator: this.users.get(order.createdBy)
};
}
async createOrder(orderData: InsertOrder): Promise<Order> {
const id = this.idCounters.order++;
const order: Order = {
id,
...orderData,
createdAt: new Date(),
updatedAt: new Date(),
};
this.orders.set(id, order);
return order;
}
async updateOrder(id: number, orderData: Partial<InsertOrder>): Promise<Order> {
const existingOrder = this.orders.get(id);
if (!existingOrder) throw new Error('Order not found');
const updatedOrder = {
...existingOrder,
...orderData,
updatedAt: new Date(),
};
this.orders.set(id, updatedOrder);
return updatedOrder;
}
async deleteOrder(id: number): Promise<void> {
this.orders.delete(id);
}
async getDeliveries(groupIds?: number[]): Promise<DeliveryWithRelations[]> {
let deliveries = Array.from(this.deliveries.values());
if (groupIds && groupIds.length > 0) {
deliveries = deliveries.filter(delivery => groupIds.includes(delivery.groupId));
}
return deliveries.map(delivery => ({
...delivery,
supplier: this.suppliers.get(delivery.supplierId),
group: this.groups.get(delivery.groupId),
creator: this.users.get(delivery.createdBy || '')
}));
}
async getDeliveriesByDateRange(startDate: string, endDate: string, groupIds?: number[]): Promise<DeliveryWithRelations[]> {
const start = new Date(startDate);
const end = new Date(endDate);
let deliveries = Array.from(this.deliveries.values()).filter(delivery => {
const deliveryDate = new Date(delivery.scheduledDate);
return deliveryDate >= start && deliveryDate <= end;
});
if (groupIds && groupIds.length > 0) {
deliveries = deliveries.filter(delivery => groupIds.includes(delivery.groupId));
}
return deliveries.map(delivery => ({
...delivery,
supplier: this.suppliers.get(delivery.supplierId),
group: this.groups.get(delivery.groupId),
creator: this.users.get(delivery.createdBy || '')
}));
}
async getDelivery(id: number): Promise<DeliveryWithRelations | undefined> {
const delivery = this.deliveries.get(id);
if (!delivery) return undefined;
return {
...delivery,
supplier: this.suppliers.get(delivery.supplierId),
group: this.groups.get(delivery.groupId),
creator: this.users.get(delivery.createdBy || '')
};
}
async createDelivery(deliveryData: InsertDelivery): Promise<Delivery> {
const id = this.idCounters.delivery++;
const delivery: Delivery = {
id,
...deliveryData,
status: 'pending',
createdAt: new Date(),
updatedAt: new Date(),
};
this.deliveries.set(id, delivery);
return delivery;
}
async updateDelivery(id: number, deliveryData: Partial<InsertDelivery>): Promise<Delivery> {
const existingDelivery = this.deliveries.get(id);
if (!existingDelivery) throw new Error('Delivery not found');
const updatedDelivery = {
...existingDelivery,
...deliveryData,
updatedAt: new Date(),
};
this.deliveries.set(id, updatedDelivery);
return updatedDelivery;
}
async deleteDelivery(id: number): Promise<void> {
this.deliveries.delete(id);
}
async validateDelivery(id: number, blData?: { blNumber: string; blAmount: number }): Promise<void> {
const delivery = this.deliveries.get(id);
if (!delivery) throw new Error('Delivery not found');
const updatedDelivery = {
...delivery,
status: 'delivered' as const,
deliveredDate: new Date(),
blNumber: blData?.blNumber || delivery.blNumber,
blAmount: blData?.blAmount || delivery.blAmount,
updatedAt: new Date(),
};
this.deliveries.set(id, updatedDelivery);
}
async getUserGroups(): Promise<UserGroup[]> { return []; } async getUserGroups(): Promise<UserGroup[]> { return []; }
async assignUserToGroup(): Promise<UserGroup> { return {} as UserGroup; } async assignUserToGroup(): Promise<UserGroup> { return {} as UserGroup; }