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:
michaelschal committed 2025-08-13 11:29:42 +00:00
1 parent 382fb4c112
commit 88d2c4a4c8
4 files changed
+102 -1008

No files matched your search

+21 -1008
View File
File diff suppressed because it is too large. Load diff
+32
View File
@@ -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 {