chore: comments and better error message
This commit is contained in:
parent
8b1cf46f77
commit
3f46614ff5
2 changed files with 3 additions and 4 deletions
|
|
@ -27,11 +27,9 @@ function atomic (tx, pi, fromClient) {
|
|||
const isStale = fromClient && oldTx && (oldTx.txVersion >= tx.txVersion)
|
||||
if (isStale) throw new E.StaleTxError({ txId: tx.id })
|
||||
|
||||
// Server doesn't bump version, so we just prevent from version being older.
|
||||
const isStaleFromServer = !fromClient && oldTx && (oldTx.txVersion > tx.txVersion)
|
||||
if (isStaleFromServer) {
|
||||
logger.info('trying to update older version of tx', JSON.stringify(tx))
|
||||
return Promise.resolve()
|
||||
}
|
||||
if (isStaleFromServer) throw new Error('Stale Error: server triggered', tx.id)
|
||||
|
||||
return preProcess(t, oldTx, tx, pi)
|
||||
.then(preProcessedTx => cashOutLow.upsert(t, oldTx, preProcessedTx))
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ function diff (oldTx, newTx) {
|
|||
return updatedTx['customerId'] = newTx['customerId']
|
||||
}
|
||||
return
|
||||
// prevent dispense changing from 'true' to 'false'
|
||||
case 'dispense':
|
||||
if (!oldTx.dispense) {
|
||||
return updatedTx[fieldKey] = newTx[fieldKey]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue