Merge pull request #394 from R0m1k3/1.1

Improve automatic data filling for credit notes with better error han…
This commit is contained in:
LogiFlow authored and GitHub committed 2025-09-08 20:57:19 +02:00
commit c72b7b8747
2 files changed
+20 -15

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

+20 -15
View File
@@ -442,22 +442,27 @@ export default function Avoirs() {
}));
// Auto-remplissage si facture trouvée et montant disponible
if (result.exists && result.invoiceAmount) {
if (result?.exists && result?.invoiceAmount !== undefined && result?.invoiceAmount !== null) {
// Auto-remplir le montant dans l'avoir via API
const avoir = avoirs.find(a => a.id === variables.avoirId);
if (avoir) {
editAvoirMutation.mutate({
id: variables.avoirId,
data: {
supplierId: avoir.supplierId,
groupId: avoir.groupId,
invoiceReference: avoir.invoiceReference || "",
amount: result.invoiceAmount, // Auto-remplissage du montant
comment: avoir.comment || "",
commercialProcessed: avoir.commercialProcessed,
status: avoir.status as "En attente de demande" | "Demandé" | "Reçu",
}
});
const avoir = avoirs?.find(a => a?.id === variables.avoirId);
if (avoir && avoir.supplierId && avoir.groupId) {
try {
editAvoirMutation.mutate({
id: variables.avoirId,
data: {
supplierId: avoir.supplierId,
groupId: avoir.groupId,
invoiceReference: avoir.invoiceReference || "",
amount: result.invoiceAmount, // Auto-remplissage du montant
comment: avoir.comment || "",
commercialProcessed: avoir.commercialProcessed || false,
status: avoir.status as "En attente de demande" | "Demandé" | "Reçu",
}
});
} catch (autoFillError) {
console.error('Erreur auto-remplissage montant:', autoFillError);
// Ne pas faire échouer la vérification si l'auto-remplissage échoue
}
}
}