mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add NocoDB invoice verification system and enhance existing configurations
Integrate NocoDB invoice verification with new schema and storage operations, streamline existing NocoDB configuration endpoints, and introduce cache management for invoice verification. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/ehBF9El
This commit is contained in:
1 parent
382fb4c112
commit
88d2c4a4c8
4 files changed
+102
-1008
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 289 KiB |
+21
-1008
File diff suppressed because it is too large.
Load diff
@@ -10,6 +10,8 @@ import {
|
||||
customerOrders,
|
||||
dlcProducts,
|
||||
tasks,
|
||||
nocodbConfig,
|
||||
invoiceVerificationCache,
|
||||
type User,
|
||||
type UpsertUser,
|
||||
type Group,
|
||||
@@ -42,6 +44,10 @@ import {
|
||||
type DlcProductWithRelations,
|
||||
type Task,
|
||||
type InsertTask,
|
||||
type NocodbConfig,
|
||||
type InsertNocodbConfig,
|
||||
type InvoiceVerificationCache,
|
||||
type InsertInvoiceVerificationCache,
|
||||
} from "@shared/schema";
|
||||
import { db } from "./db";
|
||||
import { eq, and, inArray, desc, sql, gte, lte } from "drizzle-orm";
|
||||
@@ -120,10 +126,16 @@ export interface IStorage {
|
||||
// NocoDB Configuration operations
|
||||
getNocodbConfigs(): Promise<NocodbConfig[]>;
|
||||
getNocodbConfig(id: number): Promise<NocodbConfig | undefined>;
|
||||
getActiveNocodbConfig(): Promise<NocodbConfig | undefined>;
|
||||
createNocodbConfig(config: InsertNocodbConfig): Promise<NocodbConfig>;
|
||||
updateNocodbConfig(id: number, config: Partial<InsertNocodbConfig>): Promise<NocodbConfig>;
|
||||
deleteNocodbConfig(id: number): Promise<void>;
|
||||
|
||||
// Invoice Verification Cache operations
|
||||
getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined>;
|
||||
createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache>;
|
||||
clearExpiredCache(): Promise<void>;
|
||||
|
||||
// Customer Order operations
|
||||
getCustomerOrders(groupIds?: number[]): Promise<CustomerOrderWithRelations[]>;
|
||||
getCustomerOrder(id: number): Promise<CustomerOrderWithRelations | undefined>;
|
||||
@@ -1104,6 +1116,26 @@ export class DatabaseStorage implements IStorage {
|
||||
await db.delete(nocodbConfig).where(eq(nocodbConfig.id, id));
|
||||
}
|
||||
|
||||
async getActiveNocodbConfig(): Promise<NocodbConfig | undefined> {
|
||||
const [config] = await db.select().from(nocodbConfig).where(eq(nocodbConfig.isActive, true));
|
||||
return config;
|
||||
}
|
||||
|
||||
// Invoice Verification Cache operations
|
||||
async getInvoiceVerificationCache(cacheKey: string): Promise<InvoiceVerificationCache | undefined> {
|
||||
const [cache] = await db.select().from(invoiceVerificationCache).where(eq(invoiceVerificationCache.cacheKey, cacheKey));
|
||||
return cache;
|
||||
}
|
||||
|
||||
async createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> {
|
||||
const [newCache] = await db.insert(invoiceVerificationCache).values(cache).returning();
|
||||
return newCache;
|
||||
}
|
||||
|
||||
async clearExpiredCache(): Promise<void> {
|
||||
await db.delete(invoiceVerificationCache).where(sql`${invoiceVerificationCache.expiresAt} < NOW()`);
|
||||
}
|
||||
|
||||
// Customer Order operations
|
||||
async getCustomerOrders(groupIds?: number[]): Promise<CustomerOrderWithRelations[]> {
|
||||
try {
|
||||
|
||||
@@ -141,6 +141,37 @@ export const publicityParticipations = pgTable("publicity_participations", {
|
||||
pk: primaryKey({ columns: [table.publicityId, table.groupId] })
|
||||
}));
|
||||
|
||||
// Configuration NocoDB globale pour la vérification des factures
|
||||
export const nocodbConfig = pgTable("nocodb_config", {
|
||||
id: serial("id").primaryKey(),
|
||||
name: varchar("name").notNull(),
|
||||
baseUrl: varchar("base_url").notNull(),
|
||||
projectId: varchar("project_id").notNull(),
|
||||
apiToken: varchar("api_token").notNull(),
|
||||
description: text("description"),
|
||||
isActive: boolean("is_active").default(true),
|
||||
createdBy: varchar("created_by"),
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
|
||||
// Cache de vérification des factures
|
||||
export const invoiceVerificationCache = pgTable("invoice_verification_cache", {
|
||||
id: serial("id").primaryKey(),
|
||||
cacheKey: varchar("cache_key", { length: 255 }).notNull(),
|
||||
groupId: integer("group_id").notNull(),
|
||||
invoiceReference: varchar("invoice_reference", { length: 255 }).notNull(),
|
||||
supplierName: varchar("supplier_name", { length: 255 }),
|
||||
exists: boolean("exists").notNull(),
|
||||
matchType: varchar("match_type", { length: 50 }).notNull(),
|
||||
errorMessage: text("error_message"),
|
||||
cacheHit: boolean("cache_hit").default(false),
|
||||
apiCallTime: integer("api_call_time"),
|
||||
expiresAt: timestamp("expires_at").notNull(),
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -472,6 +503,21 @@ export const insertTaskSchema = createInsertSchema(tasks).omit({
|
||||
dueDate: z.coerce.date().optional().nullable(), // Convertit automatiquement les chaînes en Date
|
||||
});
|
||||
|
||||
export const insertNocodbConfigSchema = createInsertSchema(nocodbConfig).omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
export const insertInvoiceVerificationCacheSchema = createInsertSchema(invoiceVerificationCache).omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
export type InsertNocodbConfig = z.infer<typeof insertNocodbConfigSchema>;
|
||||
export type InsertInvoiceVerificationCache = z.infer<typeof insertInvoiceVerificationCacheSchema>;
|
||||
|
||||
// Types
|
||||
export type User = typeof users.$inferSelect;
|
||||
export type UpsertUser = z.infer<typeof insertUserSchema>;
|
||||
@@ -586,6 +632,9 @@ export type PublicityWithRelations = Publicity & {
|
||||
export type NocodbConfig = typeof nocodbConfig.$inferSelect;
|
||||
export type InsertNocodbConfig = z.infer<typeof insertNocodbConfigSchema>;
|
||||
|
||||
export type InvoiceVerificationCache = typeof invoiceVerificationCache.$inferSelect;
|
||||
export type InsertInvoiceVerificationCache = z.infer<typeof insertInvoiceVerificationCacheSchema>;
|
||||
|
||||
export type CustomerOrder = typeof customerOrders.$inferSelect;
|
||||
export type InsertCustomerOrder = z.infer<typeof insertCustomerOrderSchema>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user