Merge pull request #873 from chaotixkilla/feat-integrate-hedging-and-accounting-with-pazuz-admin
Integrate hedging and accounting with pazuz related screens
This commit is contained in:
commit
d138b26903
40 changed files with 761 additions and 386 deletions
|
|
@ -8,6 +8,7 @@ const { getCashInSettings } = require('../new-config-manager')
|
|||
const { AUTOMATIC } = require('../constants.js')
|
||||
|
||||
function notifyCashboxRemoval (req, res, next) {
|
||||
const operatorId = res.locals.operatorId
|
||||
return Promise.all([getMachine(req.deviceId), loadLatestConfig()])
|
||||
.then(([machine, config]) => {
|
||||
const cashInSettings = getCashInSettings(config)
|
||||
|
|
@ -15,7 +16,7 @@ function notifyCashboxRemoval (req, res, next) {
|
|||
return res.status(200).send({ status: 'OK' })
|
||||
}
|
||||
return cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
||||
.then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }))
|
||||
.then(() => setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' }, operatorId))
|
||||
.then(() => res.status(200).send({ status: 'OK' }))
|
||||
})
|
||||
.catch(next)
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
const state = require('../middlewares/state')
|
||||
|
||||
router.get('/pid', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pidRec = state.pids[deviceId]
|
||||
res.json(pidRec)
|
||||
})
|
||||
|
||||
router.post('/reboot', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.reboots[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
router.post('/shutdown', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.shutdowns[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
router.post('/restartServices', (req, res) => {
|
||||
const deviceId = req.query.device_id
|
||||
const pid = state.pids[deviceId] && state.pids[deviceId].pid
|
||||
|
||||
if (!deviceId || !pid) {
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
state.restartServicesMap[deviceId] = pid
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
|
@ -31,6 +31,7 @@ function poll (req, res, next) {
|
|||
const serialNumber = req.query.sn
|
||||
const pid = req.query.pid
|
||||
const settings = req.settings
|
||||
const operatorId = res.locals.operatorId
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
const zeroConfLimits = _.reduce((acc, cryptoCode) => {
|
||||
acc[cryptoCode] = configManager.getWalletSettings(cryptoCode, settings.config).zeroConfLimit
|
||||
|
|
@ -48,15 +49,15 @@ function poll (req, res, next) {
|
|||
const receipt = configManager.getReceipt(settings.config)
|
||||
const terms = configManager.getTermsConditions(settings.config)
|
||||
|
||||
state.pids[deviceId] = { pid, ts: Date.now() }
|
||||
state.pids[operatorId] = { [deviceId]: { pid, ts: Date.now() } }
|
||||
|
||||
return pi.pollQueries(serialNumber, deviceTime, req.query, machineVersion, machineModel)
|
||||
.then(results => {
|
||||
const cassettes = results.cassettes
|
||||
|
||||
const reboot = pid && state.reboots[deviceId] && state.reboots[deviceId] === pid
|
||||
const shutdown = pid && state.shutdowns[deviceId] && state.shutdowns[deviceId] === pid
|
||||
const restartServices = pid && state.restartServicesMap[deviceId] && state.restartServicesMap[deviceId] === pid
|
||||
const reboot = pid && state.reboots?.[operatorId]?.[deviceId] === pid
|
||||
const shutdown = pid && state.shutdowns?.[operatorId]?.[deviceId] === pid
|
||||
const restartServices = pid && state.restartServicesMap?.[operatorId]?.[deviceId] === pid
|
||||
const langs = localeConfig.languages
|
||||
|
||||
const locale = {
|
||||
|
|
|
|||
|
|
@ -66,4 +66,4 @@ router.post('/', postTx)
|
|||
router.get('/:id', getTx)
|
||||
router.get('/', getPhoneTx)
|
||||
|
||||
module.exports = router
|
||||
module.exports = { postTx, getTx, getPhoneTx, router }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue