fix: batch creation and UI details

This commit is contained in:
José Oliveira 2021-05-13 14:38:48 +01:00 committed by Josh Harvey
parent c83b3cda56
commit 3281df1a91
4 changed files with 20 additions and 14 deletions

View file

@ -2,22 +2,20 @@ const express = require('express')
const router = express.Router()
const cashbox = require('../cashbox-batches')
const machine = require('../machine-loader')
const { getMachine, setMachine } = require('../machine-loader')
const { loadLatestConfig } = require('../new-settings-loader')
const { getCashInSettings } = require('../new-config-manager')
function notifyCashboxRemoval (req, res, next) {
console.log('We got a notification for the cashbox removal!!')
return machine.getMachine(req.deviceId)
return getMachine(req.deviceId)
.then(machine => {
loadLatestConfig()
.then(async config => {
console.log('entered the config')
const cashInSettings = getCashInSettings(config)
console.log(cashInSettings)
if (cashInSettings.cashboxReset === 'Automatic') {
console.log('We proceed with the cashbox reset!!')
await cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
await machine.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' })
await setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' })
return res.status(200).send({ status: 'OK' })
}
})