feat: add debug logs for the cashbox removal and batch creation processes
This commit is contained in:
parent
d62db527de
commit
32b54b1596
1 changed files with 18 additions and 3 deletions
|
|
@ -6,21 +6,36 @@ const notifier = require('../notifier')
|
||||||
const { getMachine, setMachine } = require('../machine-loader')
|
const { getMachine, setMachine } = require('../machine-loader')
|
||||||
const { loadLatestConfig } = require('../new-settings-loader')
|
const { loadLatestConfig } = require('../new-settings-loader')
|
||||||
const { getCashInSettings } = require('../new-config-manager')
|
const { getCashInSettings } = require('../new-config-manager')
|
||||||
const { AUTOMATIC } = require('../constants.js')
|
const { AUTOMATIC } = require('../constants')
|
||||||
|
const logger = require('../logger')
|
||||||
|
|
||||||
function notifyCashboxRemoval (req, res, next) {
|
function notifyCashboxRemoval (req, res, next) {
|
||||||
const operatorId = res.locals.operatorId
|
const operatorId = res.locals.operatorId
|
||||||
|
|
||||||
|
logger.info(`** DEBUG ** - Cashbox removal - Received a cashbox opening request from device ${req.deviceId}`)
|
||||||
|
|
||||||
return notifier.cashboxNotify(req.deviceId)
|
return notifier.cashboxNotify(req.deviceId)
|
||||||
.then(() => Promise.all([getMachine(req.deviceId), loadLatestConfig()]))
|
.then(() => Promise.all([getMachine(req.deviceId), loadLatestConfig()]))
|
||||||
.then(([machine, config]) => {
|
.then(([machine, config]) => {
|
||||||
|
logger.info('** DEBUG ** - Cashbox removal - Retrieving system options for cash-in')
|
||||||
const cashInSettings = getCashInSettings(config)
|
const cashInSettings = getCashInSettings(config)
|
||||||
if (cashInSettings.cashboxReset !== AUTOMATIC) {
|
if (cashInSettings.cashboxReset !== AUTOMATIC) {
|
||||||
|
logger.info('** DEBUG ** - Cashbox removal - Cashbox reset is set to manual. A cashbox batch will NOT be created')
|
||||||
|
logger.info(`** DEBUG ** - Cashbox removal - Process finished`)
|
||||||
return res.status(200).send({ status: 'OK' })
|
return res.status(200).send({ status: 'OK' })
|
||||||
}
|
}
|
||||||
|
logger.info('** DEBUG ** - Cashbox removal - Cashbox reset is set to automatic. A cashbox batch WILL be created')
|
||||||
|
logger.info('** DEBUG ** - Cashbox removal - Creating new batch...')
|
||||||
return cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
return cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
||||||
.then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }, operatorId))
|
.then(() => {
|
||||||
.then(() => res.status(200).send({ status: 'OK' }))
|
logger.info(`** DEBUG ** - Cashbox removal - Finished creating the new cashbox batch`)
|
||||||
|
logger.info(`** DEBUG ** - Cashbox removal - Resetting the cashbox counter on device ${req.deviceId}`)
|
||||||
|
return setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }, operatorId)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info(`** DEBUG ** - Cashbox removal - Process finished`)
|
||||||
|
return res.status(200).send({ status: 'OK' })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(next)
|
.catch(next)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue