diff --git a/lib/new-config-manager.js b/lib/new-config-manager.js index ecc57a05..3739b576 100644 --- a/lib/new-config-manager.js +++ b/lib/new-config-manager.js @@ -10,6 +10,7 @@ const namespaces = { COIN_ATM_RADAR: 'coinAtmRadar', TERMS_CONDITIONS: 'termsConditions', CASH_OUT: 'cashOut', + CASH_IN: 'cashInt', COMPLIANCE: 'compliance' } @@ -110,8 +111,11 @@ const getCryptosFromWalletNamespace = config => { return _.uniq(_.map(splitGetFirst, _.keys(fromNamespace('wallets', config)))) } +const getCashInSettings = config => fromNamespace(namespaces.CASH_IN)(config) + module.exports = { getWalletSettings, + getCashInSettings, getOperatorInfo, getNotifications, getGlobalNotifications, diff --git a/lib/routes/cashboxRoutes.js b/lib/routes/cashboxRoutes.js index 40e83905..527708c8 100644 --- a/lib/routes/cashboxRoutes.js +++ b/lib/routes/cashboxRoutes.js @@ -3,13 +3,26 @@ const router = express.Router() const cashbox = require('../cashbox-batches') const machine = require('../machine-loader') +const { loadLatestConfig } = require('../new-settings-loader') +const { getCashInSettings } = require('../new-config-manager') function notifyCashboxRemoval (req, res, next) { + console.log('We got a notification for the cashbox removal!!') return machine.getMachine(req.deviceId) - .then(machine => cashbox.createCashboxBatch(req.deviceId, machine.cashbox)) - .then(() => machine.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' })) - .then(() => res.status(200).send({ status: 'OK' })) - .catch(next) + .then(machine => { + loadLatestConfig() + .then(async config => { + console.log('entered the config') + const cashInSettings = getCashInSettings(config) + if (cashInSettings.automaticCashboxReset) { + console.log('We proceed with the cashbox reset!!') + await cashbox.createCashboxBatch(req.deviceId, machine.cashbox) + await machine.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }) + return res.status(200).send({ status: 'OK' }) + } + }) + }) + .catch(next) } router.post('/removal', notifyCashboxRemoval)