Improve handling of undefined or null amounts in financial documents

Adjusted client-side logic in `Avoirs.tsx` to correctly display financial amounts, preventing errors when amounts are not explicitly set.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/H30E1Dv
This commit is contained in:
michaelschal committed 2025-09-08 18:53:27 +00:00
1 parent 11d1b999fe
commit 559d26aa38
3 files changed
+204 -3

No files matched your search

@@ -0,0 +1,201 @@
✅ Résultat vérification avoir: {
exists: true,
matchType: 'invoice_reference',
errorMessage: null,
invoiceReference: 'FC-25-00005972',
supplierName: 'Artyfete',
fromCache: true,
permanent: false
}
POST /api/avoirs/7/verify-invoice 200 in 15ms
🔍 Vérification facture avoir: {
avoirId: 7,
invoiceReference: 'FC-25-00005972',
supplier: 'Artyfete',
group: 'Frouard',
␍ groupId: 1
}
🔍 [INVOICE] Début vérification facture: { invoiceReference: 'FC-25-00005972', groupId: 1, forceRefresh: true }
🔄 [INVOICE] Refresh forcé, ignorant le cache
🔧 Configuration groupe: {
groupName: 'Frouard',
hasNocodbConfig: true,
hasTableName: true,
hasWebhook: true
}
🔍 Vérification NocoDB en production...
🔧 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
}
🔧 Utilisation table ID: {
groupTable: 'CommandeF',
configuredId: 'mrr733dfb8wtt9b',
resolvedId: 'mrr733dfb8wtt9b'
}
🔍 Recherche NocoDB: { tableId: 'mrr733dfb8wtt9b', column: 'RefFacture' }
💾 [CACHE] Tentative sauvegarde: {
invoiceReference: 'FC-25-00005972',
groupId: 1,
cacheKey: '1_fc-25-00005972',
exists: true,
isReconciled: false,
cacheType: 'temporaire 6h (trouvé)',
expiresAt: '2025-09-09T00:51:46.386Z'
}
✅ [CACHE] Résultat sauvé en cache: {
␍ id: 23216,
invoiceReference: 'FC-25-00005972',
groupId: 1,
exists: true,
isReconciled: false,
cacheType: 'temporaire 6h (trouvé)',
cacheKey: '1_fc-25-00005972'
}
✅ Résultat vérification avoir: {
exists: true,
matchType: 'invoice_reference',
invoiceReference: 'FC-25-00005972',
invoiceAmount: -47.976,
supplierName: 'Artyfete'
}
POST /api/avoirs/7/verify-invoice 200 in 89ms
💰 PUT Avoir - Raw body received: {
"supplierId": 3,
"groupId": 1,
"invoiceReference": "FC-25-00005972",
"amount": -47.976,
"comment": "",
"commercialProcessed": false,
"status": "Reçu"
}
💰 PUT Avoir - Validated data: {
"supplierId": 3,
"groupId": 1,
"invoiceReference": "FC-25-00005972",
"amount": -47.976,
"comment": "",
"commercialProcessed": false,
"status": "Reçu"
}
✅ Avoir updated: 7 by user: admin_local
PUT /api/avoirs/7 200 in 16ms
🔍 Avoirs API called with: { groupIds: [ 1 ], userRole: 'admin' }
📋 Avoirs returned: 1 items
GET /api/avoirs 200 in 7ms
HEAD /api/health 200 in 0ms
Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

+3 -3
View File
@@ -1119,7 +1119,7 @@ export default function Avoirs() {
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
<div className="flex items-center">
{avoir.amount ? `${avoir.amount.toFixed(2)} €` : 'Non spécifié'}
{avoir.amount !== null && avoir.amount !== undefined ? `${avoir.amount.toFixed(2)} €` : 'Non spécifié'}
{avoir.commercialProcessed && (
<div title="Avoir fait par commercial">
<UserCheck className="h-4 w-4 text-blue-600 ml-2" />
@@ -1407,7 +1407,7 @@ export default function Avoirs() {
<div className="text-sm">
<div><strong>Fournisseur:</strong> {selectedAvoir.supplier?.name || 'Fournisseur non défini'}</div>
<div><strong>Référence:</strong> {selectedAvoir.invoiceReference || 'Sans référence'}</div>
<div><strong>Montant:</strong> {selectedAvoir.amount ? `${selectedAvoir.amount.toFixed(2)} €` : 'Non spécifié'}</div>
<div><strong>Montant:</strong> {selectedAvoir.amount !== null && selectedAvoir.amount !== undefined ? `${selectedAvoir.amount.toFixed(2)} €` : 'Non spécifié'}</div>
</div>
</div>
)}
@@ -1444,7 +1444,7 @@ export default function Avoirs() {
Magasin: {selectedAvoirForUpload.group?.name || 'Magasin non défini'}
</div>
<div className="text-gray-600">
Montant: {selectedAvoirForUpload.amount ? `${selectedAvoirForUpload.amount.toFixed(2)} €` : 'Non spécifié'}
Montant: {selectedAvoirForUpload.amount !== null && selectedAvoirForUpload.amount !== undefined ? `${selectedAvoirForUpload.amount.toFixed(2)} €` : 'Non spécifié'}
</div>
</div>
</div>