feat: create batch when machine detects stacker open

This commit is contained in:
André Sá 2021-11-15 19:29:41 +00:00
parent dde26b8dc2
commit d9cd896d33
2 changed files with 6 additions and 6 deletions

View file

@ -118,7 +118,7 @@ function getMachine (machineId, config) {
.then(([machine, events, config]) => { .then(([machine, events, config]) => {
const pings = checkPings([machine]) const pings = checkPings([machine])
return [machine].map(addName(pings, events, config))[0] return addName(pings, events, config)(machine)
}) })
} }

View file

@ -10,6 +10,7 @@ const express = require('express')
const nmd = require('nano-markdown') const nmd = require('nano-markdown')
const semver = require('semver') const semver = require('semver')
const cashbox = require('./cashbox-batches')
const dbErrorCodes = require('./db-error-codes') const dbErrorCodes = require('./db-error-codes')
const options = require('./options') const options = require('./options')
const logger = require('./logger') const logger = require('./logger')
@ -207,11 +208,10 @@ function stateChange (req, res, next) {
} }
function notifyCashboxRemoval (req, res, next) { function notifyCashboxRemoval (req, res, next) {
Promise.resolve() return machineLoader.getMachine(req.deviceId)
.then(() => { .then(machineLoader => cashbox.createCashboxBatch(req.deviceId, machineLoader.cashbox))
logger.log(`Device ${req.deviceId} had its cashbox removed.`) .then(() => machineLoader.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }))
return res.status(200).send({ status: 'OK' }) .then(() => res.status(200).send({ status: 'OK' }))
})
.catch(next) .catch(next)
} }