From 437193711052cad9223c0da64ad9fd578a90e152 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 2 Jun 2021 23:41:25 +0200 Subject: [PATCH] =?UTF-8?q?Message=20expliquant=20les=20diff=C3=A9rences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/item.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/module/item.js b/module/item.js index 21db5b80..26b0fb7e 100644 --- a/module/item.js +++ b/module/item.js @@ -195,9 +195,15 @@ export class RdDItem extends Item { if (itemData.name != otherData.name) return false; if (tplData.quantite == undefined) return false; - for (const [key, value] of Object.entries(tplData)) { - if (['quantite', 'encTotal', 'prixTotal', 'cout'].includes(key)) continue; - if (value != otherTplData[key]) return false; + const differences = Object.entries(tplData).filter(([key, value]) => !['quantite', 'encTotal', 'prixTotal', 'cout'].includes(key)) + .filter(([key, value]) => value != otherTplData[key]); + if (differences.length > 0) { + let message = `Impossible de regrouper les ${itemData.type} ${itemData.name}: `; + for (const [key, value] of differences){ + message += `
${key}: ${value} vs ${otherTplData[key]}`; + } + ui.notifications.info(message) + return false; } return true; }