From 15ddf4cf83bd8a9a4826863df02e9e87ed7a8ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Wed, 20 Oct 2021 15:33:42 +0100 Subject: [PATCH] fix: cash cassette low condition --- lib/plugins.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index c2262476..5f0f5762 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -615,6 +615,7 @@ function plugins (settings, deviceId) { const denomination1 = cashOutConfig.top const denomination2 = cashOutConfig.bottom const cashOutEnabled = cashOutConfig.active + const isCassetteLow = (have, max, limit) => cashOutEnabled && ((have / max) * 100) < limit const notifications = configManager.getNotifications(null, device.deviceId, settings.config) @@ -629,7 +630,7 @@ function plugins (settings, deviceId) { } : null - const cassette1Alert = cashOutEnabled && (device.cassette1 / cassetteMaxCapacity) < notifications.fillingPercentageCassette1 + const cassette1Alert = isCassetteLow(device.cassette1, cassetteMaxCapacity, notifications.fillingPercentageCassette1) ? { code: 'LOW_CASH_OUT', cassette: 1, @@ -641,7 +642,7 @@ function plugins (settings, deviceId) { } : null - const cassette2Alert = cashOutEnabled && (device.cassette2 / cassetteMaxCapacity) < notifications.fillingPercentageCassette2 + const cassette2Alert = isCassetteLow(device.cassette2, cassetteMaxCapacity, notifications.fillingPercentageCassette2) ? { code: 'LOW_CASH_OUT', cassette: 2,