mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update delivery information based on matched invoice or bill of lading
Adjusted the auto-fill logic in `BLReconciliation.tsx` to populate `invoiceReference`, `invoiceAmount`, and `dueDate` if they exist in the `result`. Also modified `server/routes.ts` to correctly parse `dueDate` as a Date object. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 25b35a21-13c0-4deb-8f7d-88d73b7e8d28 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/Tx7N1IN
This commit is contained in:
1 parent
1bf457be78
commit
228977ae2b
3 files changed
+34
-12
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 157 KiB |
@@ -153,18 +153,37 @@ export default function BLReconciliation() {
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-remplissage si facture trouvée via BL
|
||||
if (result.exists && result.matchType === 'bl_number' && result.invoiceReference) {
|
||||
// Auto-remplissage si facture trouvée (référence facture OU numéro BL)
|
||||
if (result.exists) {
|
||||
// Auto-remplir les champs dans la livraison via API
|
||||
apiRequest(`/api/deliveries/${variables.deliveryId}`, "PUT", {
|
||||
invoiceReference: result.invoiceReference,
|
||||
invoiceAmount: result.invoiceAmount
|
||||
}).then(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
||||
}).catch((error) => {
|
||||
console.error('Erreur auto-remplissage:', error);
|
||||
});
|
||||
const updateData: any = {};
|
||||
|
||||
// Ajouter la référence de facture si trouvée et pas déjà renseignée
|
||||
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'] });
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Erreur auto-remplissage:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setVerifyingDeliveries(prev => {
|
||||
|
||||
+4
-1
@@ -1407,10 +1407,13 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
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') {
|
||||
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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user