feat: cashbox batch creation on machine cashbox removal

fix: cashbox batch creation with empty cashbox
This commit is contained in:
Sérgio Salgado 2021-04-28 16:41:27 +01:00 committed by Josh Harvey
parent 482e1afc3a
commit 61cc772816
5 changed files with 15 additions and 13 deletions

View file

@ -1,12 +1,15 @@
const express = require('express')
const router = express.Router()
const cashbox = require('../cashbox-batches')
const machine = require('../machine-loader')
function notifyCashboxRemoval (req, res, next) {
Promise.resolve()
.then(() => {
console.log(`Device ${req.deviceId} had its cashbox removed.`)
return res.status(200).send({ status: 'OK' })
})
.then(() => machine.getMachine(req.deviceId))
.then(machine => cashbox.createCashboxBatch(req.deviceId, machine.cashbox))
.then(() => machine.emptyCashInBills(req))
.then(() => res.status(200).send({ status: 'OK' }))
.catch(next)
}