mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +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
+50
-26
No files matched your search
@@ -132,7 +132,15 @@ export default function BLReconciliation() {
|
||||
|
||||
// Fonction pour déclencher la vérification
|
||||
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({
|
||||
title: "Vérification non disponible",
|
||||
description: "Ce magasin n'a pas de configuration NocoDB",
|
||||
@@ -631,7 +639,7 @@ export default function BLReconciliation() {
|
||||
</div>
|
||||
|
||||
{/* Icône de vérification de facture */}
|
||||
{delivery.group?.webhookUrl && (
|
||||
{(delivery.group?.webhookUrl || delivery.group?.nocodbTableName) && (
|
||||
<div className="flex items-center">
|
||||
{verifyingDeliveries.has(delivery.id) ? (
|
||||
<Clock className="h-4 w-4 text-blue-500 animate-spin" title="Vérification en cours..." />
|
||||
|
||||
@@ -20,17 +20,30 @@ interface NocodbInvoice {
|
||||
|
||||
class InvoiceVerificationService {
|
||||
private async getNocodbConfig(): Promise<any> {
|
||||
const [config] = await db
|
||||
.select()
|
||||
.from(nocodbConfig)
|
||||
.where(eq(nocodbConfig.isActive, true))
|
||||
.limit(1);
|
||||
|
||||
if (!config) {
|
||||
throw new Error('Aucune configuration NocoDB active trouvée');
|
||||
try {
|
||||
const [config] = await db
|
||||
.select()
|
||||
.from(nocodbConfig)
|
||||
.where(eq(nocodbConfig.isActive, true))
|
||||
.limit(1);
|
||||
|
||||
if (!config) {
|
||||
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 {
|
||||
|
||||
@@ -862,9 +862,24 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const { invoiceReference, blNumber } = req.body;
|
||||
|
||||
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" });
|
||||
}
|
||||
|
||||
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(
|
||||
invoiceReference || delivery.invoiceReference || '',
|
||||
blNumber || delivery.blNumber || '',
|
||||
|
||||
+2
-14
@@ -174,18 +174,6 @@ export const invoiceVerificationCache = pgTable("invoice_verification_cache", {
|
||||
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)
|
||||
export const customerOrders = pgTable("customer_orders", {
|
||||
id: serial("id").primaryKey(),
|
||||
@@ -465,8 +453,6 @@ export const insertPublicityParticipationSchema = createInsertSchema(publicityPa
|
||||
createdAt: true,
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const insertNocodbConfigSchema = createInsertSchema(nocodbConfig).omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
@@ -479,6 +465,8 @@ export const insertInvoiceVerificationCacheSchema = createInsertSchema(invoiceVe
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
|
||||
|
||||
export const insertCustomerOrderSchema = createInsertSchema(customerOrders).omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
|
||||
Reference in new issue
Block a user