mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Merge pull request #488 from R0m1k3/1.1
Update delivery information based on matched invoice or bill of lading
This commit is contained in:
3 files changed
+30
-8
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 157 KiB |
@@ -153,19 +153,38 @@ export default function BLReconciliation() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-remplissage si facture trouvée via BL
|
// Auto-remplissage si facture trouvée (référence facture OU numéro BL)
|
||||||
if (result.exists && result.matchType === 'bl_number' && result.invoiceReference) {
|
if (result.exists) {
|
||||||
// Auto-remplir les champs dans la livraison via API
|
// Auto-remplir les champs dans la livraison via API
|
||||||
apiRequest(`/api/deliveries/${variables.deliveryId}`, "PUT", {
|
const updateData: any = {};
|
||||||
invoiceReference: result.invoiceReference,
|
|
||||||
invoiceAmount: result.invoiceAmount
|
// Ajouter la référence de facture si trouvée et pas déjà renseignée
|
||||||
}).then(() => {
|
if (result.invoiceReference && result.matchType === 'bl_number') {
|
||||||
|
updateData.invoiceReference = result.invoiceReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toujours mettre à jour le montant si disponible
|
||||||
|
if (result.invoiceAmount) {
|
||||||
|
updateData.invoiceAmount = result.invoiceAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toujours mettre à jour la date d'échéance si disponible
|
||||||
|
if (result.dueDate) {
|
||||||
|
updateData.dueDate = result.dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ne faire l'appel que si on a des données à mettre à jour
|
||||||
|
if (Object.keys(updateData).length > 0) {
|
||||||
|
apiRequest(`/api/deliveries/${variables.deliveryId}`, "PUT", updateData)
|
||||||
|
.then(() => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] });
|
queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
console.error('Erreur auto-remplissage:', error);
|
console.error('Erreur auto-remplissage:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setVerifyingDeliveries(prev => {
|
setVerifyingDeliveries(prev => {
|
||||||
const newSet = new Set(prev);
|
const newSet = new Set(prev);
|
||||||
|
|||||||
+4
-1
@@ -1407,10 +1407,13 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
transformedData.invoiceAmount = transformedData.invoiceAmount.toString();
|
transformedData.invoiceAmount = transformedData.invoiceAmount.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert validatedAt to Date object (schema expects Date for timestamp fields)
|
// Convert timestamp fields to Date objects (schema expects Date for timestamp fields)
|
||||||
if (transformedData.validatedAt && typeof transformedData.validatedAt === 'string') {
|
if (transformedData.validatedAt && typeof transformedData.validatedAt === 'string') {
|
||||||
transformedData.validatedAt = new Date(transformedData.validatedAt);
|
transformedData.validatedAt = new Date(transformedData.validatedAt);
|
||||||
}
|
}
|
||||||
|
if (transformedData.dueDate && typeof transformedData.dueDate === 'string') {
|
||||||
|
transformedData.dueDate = new Date(transformedData.dueDate);
|
||||||
|
}
|
||||||
|
|
||||||
const data = insertDeliverySchema.partial().parse(transformedData);
|
const data = insertDeliverySchema.partial().parse(transformedData);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user