mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 10:49:10 +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
@@ -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 || '',
|
||||
|
||||
Reference in new issue
Block a user