fix: stop trying to write to database when present with redundant empty and refill events
This commit is contained in:
parent
9f2a29d5a7
commit
6fbb2b4c5b
1 changed files with 10 additions and 0 deletions
|
|
@ -213,6 +213,11 @@ function emptyMachineUnits ({ deviceId, newUnits, fiatCode }) {
|
|||
_.keys(_.omit(['cashbox'], movedBills))
|
||||
)
|
||||
|
||||
// This occurs when an empty unit is called when the units are already empty, hence, no bills moved around
|
||||
if (_.isEmpty(billArr) && _.isEmpty(operationsToCreate)) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
return db.tx(t => {
|
||||
const q1Cols = ['id', 'device_id', 'operation_type']
|
||||
const q1= t.none(pgp.helpers.insert(operationsToCreate, q1Cols, 'cash_unit_operation'))
|
||||
|
|
@ -260,6 +265,11 @@ function refillMachineUnits ({ deviceId, newUnits }) {
|
|||
operation_type: it
|
||||
}))(operationNames)
|
||||
|
||||
// This occurs when a refill unit is called when the loading boxes are empty, hence, no bills moved around
|
||||
if (_.isEmpty(operationsToCreate)) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
return db.tx(t => {
|
||||
const q1Cols = ['id', 'device_id', 'operation_type']
|
||||
const q1= t.none(pgp.helpers.insert(operationsToCreate, q1Cols, 'cash_unit_operation'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue