mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add invoice verification functionality to track invoice checks
Implement database operations for managing invoice verification records and their cache, including creation and retrieval. Replit-Commit-Author: Agent Replit-Commit-Session-Id: c52a701b-4841-4d00-b8cf-5a41c12abdf3 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/c52a701b-4841-4d00-b8cf-5a41c12abdf3/3uCfEKb
This commit is contained in:
1 parent
5a16936591
commit
76a6d4c8ae
2 files changed
+105
No files matched your search
@@ -10,6 +10,8 @@ import {
|
||||
customerOrders,
|
||||
dlcProducts,
|
||||
tasks,
|
||||
invoiceVerificationCache,
|
||||
invoiceVerifications,
|
||||
type User,
|
||||
type UpsertUser,
|
||||
type Group,
|
||||
@@ -41,6 +43,10 @@ import {
|
||||
type DlcProductFrontend,
|
||||
type InsertDlcProductFrontend,
|
||||
type DlcProductWithRelations,
|
||||
type InvoiceVerificationCache,
|
||||
type InsertInvoiceVerificationCache,
|
||||
type InvoiceVerification,
|
||||
type InsertInvoiceVerification,
|
||||
type Task,
|
||||
type InsertTask,
|
||||
} from "@shared/schema";
|
||||
@@ -152,6 +158,12 @@ export interface IStorage {
|
||||
updateTask(id: number, task: Partial<InsertTask>): Promise<Task>;
|
||||
deleteTask(id: number): Promise<void>;
|
||||
completeTask(id: number, completedBy?: string): Promise<void>;
|
||||
|
||||
// Invoice Verification operations - Tables existantes en production
|
||||
getInvoiceVerifications(deliveryId?: number): Promise<InvoiceVerification[]>;
|
||||
createInvoiceVerification(verification: InsertInvoiceVerification): Promise<InvoiceVerification>;
|
||||
getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined>;
|
||||
createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache>;
|
||||
}
|
||||
|
||||
export class DatabaseStorage implements IStorage {
|
||||
@@ -2026,6 +2038,52 @@ export class DatabaseStorage implements IStorage {
|
||||
})
|
||||
.where(eq(tasks.id, id));
|
||||
}
|
||||
|
||||
// Invoice Verification operations - Utilise les tables existantes en production
|
||||
async getInvoiceVerifications(deliveryId?: number): Promise<InvoiceVerification[]> {
|
||||
const query = db.select().from(invoiceVerifications);
|
||||
if (deliveryId) {
|
||||
return await query.where(eq(invoiceVerifications.deliveryId, deliveryId));
|
||||
}
|
||||
return await query.orderBy(desc(invoiceVerifications.verifiedAt));
|
||||
}
|
||||
|
||||
async createInvoiceVerification(verification: InsertInvoiceVerification): Promise<InvoiceVerification> {
|
||||
const [newVerification] = await db
|
||||
.insert(invoiceVerifications)
|
||||
.values({
|
||||
...verification,
|
||||
verifiedAt: new Date(),
|
||||
lastCheckedAt: new Date(),
|
||||
})
|
||||
.returning();
|
||||
return newVerification;
|
||||
}
|
||||
|
||||
async getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined> {
|
||||
const [cache] = await db
|
||||
.select()
|
||||
.from(invoiceVerificationCache)
|
||||
.where(
|
||||
and(
|
||||
eq(invoiceVerificationCache.cacheKey, cacheKey),
|
||||
sql`expires_at > NOW()`
|
||||
)
|
||||
);
|
||||
return cache;
|
||||
}
|
||||
|
||||
async createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> {
|
||||
const [newCache] = await db
|
||||
.insert(invoiceVerificationCache)
|
||||
.values({
|
||||
...cache,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.returning();
|
||||
return newCache;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple in-memory storage for development
|
||||
|
||||
Reference in new issue
Block a user