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