feat: cashbox batch creation on machine cashbox removal
fix: cashbox batch creation with empty cashbox
This commit is contained in:
parent
482e1afc3a
commit
61cc772816
5 changed files with 15 additions and 13 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue