feat: perform batch creation based on reset settings
This commit is contained in:
parent
d1d4910555
commit
b5c37442c3
2 changed files with 21 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue