mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 14:08:15 +02:00
Improve NocoDB invoice verification and error handling
Enhance NocoDB invoice verification logic in the client and server to handle missing configurations and provide better debugging information. Update schema definitions to reflect changes in NocoDB configuration handling. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint
This commit is contained in:
1 parent
955f3d3b3d
commit
19ed96e48c
4 files changed
+49
-25
No files matched your search
@@ -132,7 +132,15 @@ export default function BLReconciliation() {
|
|||||||
|
|
||||||
// Fonction pour déclencher la vérification
|
// Fonction pour déclencher la vérification
|
||||||
const handleVerifyInvoice = (delivery: any) => {
|
const handleVerifyInvoice = (delivery: any) => {
|
||||||
if (!delivery.group?.webhookUrl) {
|
console.log('🔍 Debug vérification:', {
|
||||||
|
delivery: delivery,
|
||||||
|
group: delivery.group,
|
||||||
|
webhookUrl: delivery.group?.webhookUrl,
|
||||||
|
nocodbTableName: delivery.group?.nocodbTableName,
|
||||||
|
supplier: delivery.supplier
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!delivery.group?.nocodbTableName && !delivery.group?.webhookUrl) {
|
||||||
toast({
|
toast({
|
||||||
title: "Vérification non disponible",
|
title: "Vérification non disponible",
|
||||||
description: "Ce magasin n'a pas de configuration NocoDB",
|
description: "Ce magasin n'a pas de configuration NocoDB",
|
||||||
@@ -631,7 +639,7 @@ export default function BLReconciliation() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Icône de vérification de facture */}
|
{/* Icône de vérification de facture */}
|
||||||
{delivery.group?.webhookUrl && (
|
{(delivery.group?.webhookUrl || delivery.group?.nocodbTableName) && (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{verifyingDeliveries.has(delivery.id) ? (
|
{verifyingDeliveries.has(delivery.id) ? (
|
||||||
<Clock className="h-4 w-4 text-blue-500 animate-spin" title="Vérification en cours..." />
|
<Clock className="h-4 w-4 text-blue-500 animate-spin" title="Vérification en cours..." />
|
||||||
|
|||||||
@@ -20,17 +20,30 @@ interface NocodbInvoice {
|
|||||||
|
|
||||||
class InvoiceVerificationService {
|
class InvoiceVerificationService {
|
||||||
private async getNocodbConfig(): Promise<any> {
|
private async getNocodbConfig(): Promise<any> {
|
||||||
const [config] = await db
|
try {
|
||||||
.select()
|
const [config] = await db
|
||||||
.from(nocodbConfig)
|
.select()
|
||||||
.where(eq(nocodbConfig.isActive, true))
|
.from(nocodbConfig)
|
||||||
.limit(1);
|
.where(eq(nocodbConfig.isActive, true))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
throw new Error('Aucune configuration NocoDB active trouvée');
|
console.log('⚠️ Aucune configuration NocoDB active trouvée dans la table nocodb_config');
|
||||||
|
throw new Error('Aucune configuration NocoDB active trouvée');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Configuration NocoDB trouvée:', {
|
||||||
|
id: config.id,
|
||||||
|
name: config.name,
|
||||||
|
baseUrl: config.baseUrl,
|
||||||
|
projectId: config.projectId
|
||||||
|
});
|
||||||
|
|
||||||
|
return config;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Erreur lors de la récupération de la configuration NocoDB:', error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateCacheKey(groupId: number, invoiceRef: string, supplierName: string): string {
|
private generateCacheKey(groupId: number, invoiceRef: string, supplierName: string): string {
|
||||||
|
|||||||
@@ -862,9 +862,24 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
const { invoiceReference, blNumber } = req.body;
|
const { invoiceReference, blNumber } = req.body;
|
||||||
|
|
||||||
if (!delivery.supplier || !delivery.group) {
|
if (!delivery.supplier || !delivery.group) {
|
||||||
|
console.log('❌ Livraison manque informations:', {
|
||||||
|
deliveryId,
|
||||||
|
hasSupplier: !!delivery.supplier,
|
||||||
|
hasGroup: !!delivery.group,
|
||||||
|
delivery: delivery
|
||||||
|
});
|
||||||
return res.status(400).json({ message: "Delivery missing supplier or group information" });
|
return res.status(400).json({ message: "Delivery missing supplier or group information" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('🔍 Tentative de vérification facture:', {
|
||||||
|
deliveryId,
|
||||||
|
invoiceReference: invoiceReference || delivery.invoiceReference,
|
||||||
|
blNumber: blNumber || delivery.blNumber,
|
||||||
|
supplierName: delivery.supplier.name,
|
||||||
|
groupId: delivery.groupId,
|
||||||
|
groupData: delivery.group
|
||||||
|
});
|
||||||
|
|
||||||
const result = await invoiceVerificationService.verifyInvoiceReference(
|
const result = await invoiceVerificationService.verifyInvoiceReference(
|
||||||
invoiceReference || delivery.invoiceReference || '',
|
invoiceReference || delivery.invoiceReference || '',
|
||||||
blNumber || delivery.blNumber || '',
|
blNumber || delivery.blNumber || '',
|
||||||
|
|||||||
+2
-14
@@ -174,18 +174,6 @@ export const invoiceVerificationCache = pgTable("invoice_verification_cache", {
|
|||||||
updatedAt: timestamp("updated_at").defaultNow(),
|
updatedAt: timestamp("updated_at").defaultNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const insertNocodbConfigSchema = createInsertSchema(nocodbConfig).omit({
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const insertInvoiceVerificationCacheSchema = createInsertSchema(invoiceVerificationCache).omit({
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Customer Orders (Commandes Client)
|
// Customer Orders (Commandes Client)
|
||||||
export const customerOrders = pgTable("customer_orders", {
|
export const customerOrders = pgTable("customer_orders", {
|
||||||
id: serial("id").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
@@ -465,8 +453,6 @@ export const insertPublicityParticipationSchema = createInsertSchema(publicityPa
|
|||||||
createdAt: true,
|
createdAt: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const insertNocodbConfigSchema = createInsertSchema(nocodbConfig).omit({
|
export const insertNocodbConfigSchema = createInsertSchema(nocodbConfig).omit({
|
||||||
id: true,
|
id: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
@@ -479,6 +465,8 @@ export const insertInvoiceVerificationCacheSchema = createInsertSchema(invoiceVe
|
|||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const insertCustomerOrderSchema = createInsertSchema(customerOrders).omit({
|
export const insertCustomerOrderSchema = createInsertSchema(customerOrders).omit({
|
||||||
id: true,
|
id: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
|
|||||||
Reference in new issue
Block a user