diff --git a/attached_assets/Pasted--Recherche-NocoDB-url-https-nocodb-ffnancy-fr-api-v1-db-data-v1-pcg4uw79ukvycxc-C-1755091396833_1755091396833.txt b/attached_assets/Pasted--Recherche-NocoDB-url-https-nocodb-ffnancy-fr-api-v1-db-data-v1-pcg4uw79ukvycxc-C-1755091396833_1755091396833.txt new file mode 100644 index 0000000..59755d9 --- /dev/null +++ b/attached_assets/Pasted--Recherche-NocoDB-url-https-nocodb-ffnancy-fr-api-v1-db-data-v1-pcg4uw79ukvycxc-C-1755091396833_1755091396833.txt @@ -0,0 +1,200 @@ +} + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'RefFacture', + + value: '37424' + +} + +🔧 Configuration NocoDB active rĂ©cupĂ©rĂ©e: { + + id: 1, + + name: 'Nocodb', + + baseUrl: 'https://nocodb.ffnancy.fr', + + projectId: 'pcg4uw79ukvycxc', + + apiToken: 'z4BAwLo6dgoN_E7PKJSHN7PA7kdBePtKOYcsDlwQ', + + description: '', + + isActive: true, + + createdBy: 'admin_local', + + createdAt: 2025-07-22T11:12:54.971Z, + + updatedAt: 2025-07-25T23:07:17.197Z + +} + +🔧 Configuration NocoDB trouvĂ©e: { + + configName: 'Nocodb', + + baseUrl: 'https://nocodb.ffnancy.fr', + + projectId: 'pcg4uw79ukvycxc', + + hasToken: true + +} + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'RefFacture', + + value: '000752796' + +} + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: 'F5164434' + +} + +POST /api/deliveries/38/verify-invoice 200 in 162ms + +POST /api/deliveries/43/verify-invoice 200 in 167ms + +POST /api/deliveries/11/verify-invoice 200 in 156ms + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +POST /api/deliveries/33/verify-invoice 200 in 149ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: '37424' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: '000752796' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/38/verify-invoice 200 in 166ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/28/verify-invoice 200 in 154ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/27/verify-invoice 200 in 166ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 2ms + diff --git a/attached_assets/Pasted--matchType-none-errorMessage-Aucune-correspondance-trouv-e-dans-NocoDB-Erreur-1755091313055_1755091313055.txt b/attached_assets/Pasted--matchType-none-errorMessage-Aucune-correspondance-trouv-e-dans-NocoDB-Erreur-1755091313055_1755091313055.txt new file mode 100644 index 0000000..2cab408 --- /dev/null +++ b/attached_assets/Pasted--matchType-none-errorMessage-Aucune-correspondance-trouv-e-dans-NocoDB-Erreur-1755091313055_1755091313055.txt @@ -0,0 +1,132 @@ + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: 'F5164434' + +} + +POST /api/deliveries/38/verify-invoice 200 in 162ms + +POST /api/deliveries/43/verify-invoice 200 in 167ms + +POST /api/deliveries/11/verify-invoice 200 in 156ms + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +POST /api/deliveries/33/verify-invoice 200 in 149ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: '37424' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +🔍 Recherche NocoDB: { + + url: 'https://nocodb.ffnancy.fr/api/v1/db/data/v1/pcg4uw79ukvycxc/CommandeF', + + column: 'Numero_BL', + + value: '000752796' + +} + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/38/verify-invoice 200 in 166ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/28/verify-invoice 200 in 154ms + +❌ Erreur rĂ©ponse NocoDB: 404 Not Found + +✅ RĂ©sultat vĂ©rification: { + + exists: false, + + matchType: 'none', + + errorMessage: 'Aucune correspondance trouvĂ©e dans NocoDB' + +} + +POST /api/deliveries/27/verify-invoice 200 in 166ms + +HEAD /api/health 200 in 1ms + diff --git a/attached_assets/{BB709EB0-3316-4102-810F-51930B5B9BD1}_1755091259314.png b/attached_assets/{BB709EB0-3316-4102-810F-51930B5B9BD1}_1755091259314.png new file mode 100644 index 0000000..3651f0b Binary files /dev/null and b/attached_assets/{BB709EB0-3316-4102-810F-51930B5B9BD1}_1755091259314.png differ diff --git a/server/invoiceVerification.ts b/server/invoiceVerification.ts index 9ac9052..20b8944 100644 --- a/server/invoiceVerification.ts +++ b/server/invoiceVerification.ts @@ -109,12 +109,20 @@ export class InvoiceVerificationService { hasToken: !!nocodbConfig.apiToken }); + // Utiliser l'ID de table configurĂ© dans le groupe + const tableId = group.nocodbTableId || 'mrr733dfb8wtt9b'; // Fallback par dĂ©faut + console.log('🔧 Utilisation table ID:', { + groupTable: group.nocodbTableName, + configuredId: group.nocodbTableId, + resolvedId: tableId + }); + // VĂ©rifier d'abord par rĂ©fĂ©rence de facture let matchResult = await this.searchInNocoDB( invoiceReference, - group.invoiceColumnName || 'invoice_reference', + group.invoiceColumnName || 'RefFacture', nocodbConfig, - group.nocodbTableName || 'invoices' + tableId ); if (matchResult.found) { @@ -131,9 +139,9 @@ export class InvoiceVerificationService { if (group.nocodbBlColumnName) { matchResult = await this.searchInNocoDB( invoiceReference, - group.nocodbBlColumnName, + group.nocodbBlColumnName || 'Numero_BL', nocodbConfig, - group.nocodbTableName || 'invoices' + tableId ); if (matchResult.found) { @@ -180,13 +188,15 @@ export class InvoiceVerificationService { searchValue: string, columnName: string, config: any, - tableName: string + tableId: string ): Promise<{ found: boolean; data?: any }> { try { - const searchUrl = `${config.baseUrl}/api/v1/db/data/v1/${config.projectId}/${tableName}`; + // Utiliser directement l'ID de table fourni + const searchUrl = `${config.baseUrl}/api/v1/db/data/v1/${config.projectId}/${tableId}`; console.log('🔍 Recherche NocoDB:', { url: searchUrl, + tableId: tableId, column: columnName, value: searchValue }); diff --git a/server/storage.ts b/server/storage.ts index 20c11fa..d7c823f 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -1165,6 +1165,7 @@ export class MemStorage implements IStorage { color: '#3B82F6', nocodbConfigId: 1, // RĂ©fĂ©rence vers la config NocoDB de test nocodbTableName: 'invoices', + nocodbTableId: 'mrr733dfb8wtt9b', // ID rĂ©el de la table NocoDB invoiceColumnName: 'invoice_reference', nocodbBlColumnName: 'bl_number', nocodbAmountColumnName: 'amount', @@ -1284,6 +1285,7 @@ export class MemStorage implements IStorage { color: groupData.color || null, nocodbConfigId: groupData.nocodbConfigId || null, nocodbTableName: groupData.nocodbTableName || null, + nocodbTableId: groupData.nocodbTableId || null, invoiceColumnName: groupData.invoiceColumnName || null, nocodbBlColumnName: groupData.nocodbBlColumnName || null, nocodbAmountColumnName: groupData.nocodbAmountColumnName || null, @@ -1353,14 +1355,14 @@ export class MemStorage implements IStorage { } async getActiveNocodbConfig(): Promise { - // En dĂ©veloppement, crĂ©er une config de test rĂ©aliste + // Configuration corrigĂ©e pour votre serveur NocoDB const testConfig: NocodbConfig = { id: 1, - name: 'Configuration Production NocoDB', - baseUrl: 'https://nocodb.lafoirfouille.com', // URL rĂ©aliste - projectId: 'p_invoice_management', + name: 'Configuration Production NocoDB FFNancy', + baseUrl: 'https://nocodb.ffnancy.fr', // URL corrigĂ©e + projectId: 'pcg4uw79ukvycxc', // Project ID de vos logs apiToken: 'xc-token-production-invoice-system', - description: 'Configuration de production pour vĂ©rification des factures', + description: 'Configuration de production pour vĂ©rification des factures FFNancy', isActive: true, createdBy: 'admin', createdAt: new Date(), diff --git a/shared/schema.ts b/shared/schema.ts index d9571da..93855d7 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -51,6 +51,7 @@ export const groups = pgTable("groups", { // Configuration NocoDB pour vĂ©rification automatique des factures nocodbConfigId: integer("nocodb_config_id"), // RĂ©fĂ©rence vers la configuration NocoDB globale nocodbTableName: varchar("nocodb_table_name"), // Nom de la table spĂ©cifique au magasin + nocodbTableId: varchar("nocodb_table_id"), // ID rĂ©el de la table dans NocoDB (ex: mrr733dfb8wtt9b) // Mapping des colonnes par magasin dans leur table NocoDB invoiceColumnName: varchar("invoice_column_name"), // Nom de la colonne facture dans leur table nocodbBlColumnName: varchar("nocodb_bl_column_name"), // Nom de la colonne BL dans leur table @@ -578,9 +579,7 @@ export type UserWithGroups = User & { }; export type NocodbConfig = typeof nocodbConfig.$inferSelect; -export type InsertNocodbConfig = z.infer; export type InvoiceVerificationCache = typeof invoiceVerificationCache.$inferSelect; -export type InsertInvoiceVerificationCache = z.infer; // Task with relations type export type TaskWithRelations = Task & {