v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
44
packages/server/lib/routes/cashboxRoutes.js
Normal file
44
packages/server/lib/routes/cashboxRoutes.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
const express = require('express')
|
||||
const _ = require('lodash/fp')
|
||||
const router = express.Router()
|
||||
|
||||
const cashbox = require('../cashbox-batches')
|
||||
const notifier = require('../notifier')
|
||||
const { getMachine, getMachineName } = require('../machine-loader')
|
||||
const { loadConfig } = require('../new-settings-loader')
|
||||
const { getCashInSettings } = require('../new-config-manager')
|
||||
const { AUTOMATIC } = require('../constants')
|
||||
const logger = require('../logger')
|
||||
|
||||
function cashboxRemoval(req, res, next) {
|
||||
notifier.cashboxNotify(req.deviceId).catch(logger.error)
|
||||
|
||||
return Promise.all([getMachine(req.deviceId), loadConfig()])
|
||||
.then(([machine, config]) => {
|
||||
const cashInSettings = getCashInSettings(config)
|
||||
if (cashInSettings.cashboxReset !== AUTOMATIC) {
|
||||
return Promise.all([
|
||||
cashbox.getMachineUnbatchedBills(req.deviceId),
|
||||
getMachineName(req.deviceId),
|
||||
])
|
||||
}
|
||||
return cashbox
|
||||
.createCashboxBatch(req.deviceId, machine.cashbox)
|
||||
.then(batch =>
|
||||
Promise.all([
|
||||
cashbox.getBatchById(batch.id),
|
||||
getMachineName(batch.device_id),
|
||||
]),
|
||||
)
|
||||
})
|
||||
.then(([batch, machineName]) =>
|
||||
res
|
||||
.status(200)
|
||||
.send({ batch: _.merge(batch, { machineName }), status: 'OK' }),
|
||||
)
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
router.post('/removal', cashboxRemoval)
|
||||
|
||||
module.exports = router
|
||||
Loading…
Add table
Add a link
Reference in a new issue