Update invoice verification to use specific NocoDB table IDs

Refactor invoice verification service to correctly utilize `nocodbTableId` for NocoDB API calls, defaulting to 'mrr733dfb8wtt9b' if not provided. Updates column names for invoice and delivery slip searches to 'RefFacture' and 'Numero_BL' respectively. Also, corrects NocoDB configuration URLs and project IDs for production environments.

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/t34W525
This commit is contained in:
michaelschal committed 2025-08-13 13:30:44 +00:00
1 parent d7241e857e
commit 87c111741b
6 files changed
+356 -13

No files matched your search

@@ -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
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

+16 -6
View File
@@ -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
});
+7 -5
View File
@@ -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<NocodbConfig | undefined> {
// 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(),
+1 -2
View File
@@ -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<typeof insertNocodbConfigSchema>;
export type InvoiceVerificationCache = typeof invoiceVerificationCache.$inferSelect;
export type InsertInvoiceVerificationCache = z.infer<typeof insertInvoiceVerificationCacheSchema>;
// Task with relations type
export type TaskWithRelations = Task & {