chore: simplify conditional
This commit is contained in:
parent
f16be1d263
commit
b559434cbd
1 changed files with 3 additions and 1 deletions
|
|
@ -20,7 +20,9 @@ function createCashboxBatch (deviceId, cashboxCount) {
|
|||
}
|
||||
|
||||
function updateMachineWithBatch (machineContext, oldCashboxCount) {
|
||||
if (!_.has(['deviceId', 'cashbox', 'cassettes'], machineContext) && !_.inRange(constants.CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES, constants.CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES + 1, _.size(machineContext.cassettes)))
|
||||
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))
|
||||
if (!isValidContext && !isCassetteAmountWithinRange)
|
||||
throw new Error('Insufficient info to create a new cashbox batch')
|
||||
if (_.isEqual(0, oldCashboxCount)) throw new Error('Cashbox is empty. Cashbox batch could not be created.')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue