feat: add aveiro cash units to the devices table
feat: change data fetching to accomodate the new cash units
This commit is contained in:
parent
06f534fa48
commit
211c4b1ea7
19 changed files with 1011 additions and 155 deletions
|
|
@ -20,8 +20,10 @@ function createCashboxBatch (deviceId, cashboxCount) {
|
|||
}
|
||||
|
||||
function updateMachineWithBatch (machineContext, oldCashboxCount) {
|
||||
const isValidContext = _.has(['deviceId', 'cashbox', 'cassettes'], machineContext)
|
||||
const isCassetteAmountWithinRange = _.inRange(constants.CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES, constants.CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES + 1, _.size(machineContext.cassettes))
|
||||
const cashUnits = machineContext.cashUnits
|
||||
const isValidContext = _.has(['deviceId', 'cashUnits'], machineContext) && _.has(['cashbox', 'cassette1', 'cassette2', 'cassette3', 'cassette4', 'stacker1f', 'stacker1r', 'stacker2f', 'stacker2r', 'stacker3f', 'stacker3r'], cashUnits)
|
||||
const cassettes = _.filter(it => !_.isNil(it))([cashUnits.cassette1, cashUnits.cassette2, cashUnits.cassette3, cashUnits.cassette4])
|
||||
const isCassetteAmountWithinRange = _.inRange(constants.CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES, constants.CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES + 1, _.size(cassettes))
|
||||
if (!isValidContext && !isCassetteAmountWithinRange)
|
||||
throw new Error('Insufficient info to create a new cashbox batch')
|
||||
if (_.isEqual(0, oldCashboxCount)) throw new Error('Cash box is empty. Cash box batch could not be created.')
|
||||
|
|
@ -34,12 +36,18 @@ function updateMachineWithBatch (machineContext, oldCashboxCount) {
|
|||
WHERE bills.cash_in_txs_id = cash_in_txs.id AND
|
||||
cash_in_txs.device_id = $2 AND
|
||||
bills.cashbox_batch_id IS NULL`, [batchId, deviceId])
|
||||
const q3 = t.none(`UPDATE devices SET cashbox=$1, cassette1=$2, cassette2=$3, cassette3=$4, cassette4=$5 WHERE device_id=$6`, [
|
||||
machineContext.cashbox,
|
||||
machineContext.cassettes[0],
|
||||
machineContext.cassettes[1],
|
||||
machineContext.cassettes[2],
|
||||
machineContext.cassettes[3],
|
||||
const q3 = t.none(`UPDATE devices SET cashbox=$1, cassette1=$2, cassette2=$3, cassette3=$4, cassette4=$5, stacker1f=$6, stacker1r=$7, stacker1f=$8, stacker1r=$9, stacker1f=$10, stacker1r=$11 WHERE device_id=$12`, [
|
||||
cashUnits.cashbox,
|
||||
cashUnits.cassette1,
|
||||
cashUnits.cassette2,
|
||||
cashUnits.cassette3,
|
||||
cashUnits.cassette4,
|
||||
cashUnits.stacker1f,
|
||||
cashUnits.stacker1r,
|
||||
cashUnits.stacker2f,
|
||||
cashUnits.stacker2r,
|
||||
cashUnits.stacker3f,
|
||||
cashUnits.stacker3r,
|
||||
machineContext.deviceId
|
||||
])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue