refactor: async/await to then and log removal

This commit is contained in:
José Oliveira 2021-05-19 14:34:56 +01:00 committed by Josh Harvey
parent 3281df1a91
commit ad29650c36

View file

@ -10,13 +10,12 @@ function notifyCashboxRemoval (req, res, next) {
return getMachine(req.deviceId) return getMachine(req.deviceId)
.then(machine => { .then(machine => {
loadLatestConfig() loadLatestConfig()
.then(async config => { .then(config => {
const cashInSettings = getCashInSettings(config) const cashInSettings = getCashInSettings(config)
console.log(cashInSettings)
if (cashInSettings.cashboxReset === 'Automatic') { if (cashInSettings.cashboxReset === 'Automatic') {
await cashbox.createCashboxBatch(req.deviceId, machine.cashbox) return cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
await setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }) .then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }))
return res.status(200).send({ status: 'OK' }) .then(() => res.status(200).send({ status: 'OK' }))
} }
}) })
}) })