mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 22:18:17 +02:00
Improve task management by optimizing cache updates for reconciled invoices
Add new functionality to update invoice verification cache to permanent status after reconciliation. Introduce a new API endpoint for admins to trigger bulk updates of existing reconciled caches, addressing potential performance issues with repeated checks on verified items. Replit-Commit-Author: Agent Replit-Commit-Session-Id: daf3525c-b971-454a-b0c0-7a9845e786cc Replit-Commit-Checkpoint-Type: full_checkpoint
This commit is contained in:
1 parent
97b63b61e8
commit
9ed380a279
2 files changed
+128
-3
No files matched your search
@@ -1124,6 +1124,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
await storage.validateDelivery(id, blData);
|
||||
|
||||
// MISE À JOUR DU CACHE : Marquer le cache comme permanent pour cette livraison validée
|
||||
try {
|
||||
if (delivery.invoiceReference && delivery.invoiceReference.trim()) {
|
||||
console.log('🔄 [CACHE] Mise à jour cache permanent après validation livraison');
|
||||
await invoiceVerificationService.updateCacheAsReconciled(delivery.invoiceReference, delivery.groupId);
|
||||
}
|
||||
if (delivery.blNumber && delivery.blNumber.trim()) {
|
||||
console.log('🔄 [CACHE] Mise à jour cache permanent BL après validation livraison');
|
||||
await invoiceVerificationService.updateCacheAsReconciled(delivery.blNumber, delivery.groupId);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur mise à jour cache après validation:', error);
|
||||
}
|
||||
|
||||
// SYNCHRONISATION AUTOMATIQUE : Quand validation, marquer la commande associée comme "delivered"
|
||||
if (delivery.orderId) {
|
||||
try {
|
||||
@@ -1142,6 +1156,35 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
// Route pour mettre à jour les caches existants des livraisons validées
|
||||
app.post('/api/cache/update-reconciled', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const user = await storage.getUserWithGroups(req.user.claims ? req.user.claims.sub : req.user.id);
|
||||
if (!user) {
|
||||
return res.status(404).json({ message: "User not found" });
|
||||
}
|
||||
|
||||
// Vérifier que c'est un admin
|
||||
if (user.role !== 'admin') {
|
||||
return res.status(403).json({ message: "Seuls les admins peuvent exécuter cette opération" });
|
||||
}
|
||||
|
||||
console.log('🔧 [ADMIN] Exécution mise à jour des caches permanents...');
|
||||
await invoiceVerificationService.updateExistingReconciledCaches();
|
||||
|
||||
res.json({
|
||||
message: "Mise à jour des caches permanents terminée avec succès",
|
||||
success: true
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur mise à jour caches:", error);
|
||||
res.status(500).json({
|
||||
message: "Erreur lors de la mise à jour des caches",
|
||||
error: error instanceof Error ? error.message : 'Unknown error'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// DLC Products routes
|
||||
app.get('/api/dlc-products', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user