feat: perform batch creation based on reset settings

This commit is contained in:
José Oliveira 2021-05-10 22:56:49 +01:00 committed by Josh Harvey
parent d1d4910555
commit b5c37442c3
2 changed files with 21 additions and 4 deletions

View file

@ -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,

View file

@ -3,12 +3,25 @@ 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' }))
.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)
}