add cancel script
This commit is contained in:
parent
985e3811e3
commit
d2700b4eb3
4 changed files with 58 additions and 8 deletions
|
|
@ -12,7 +12,8 @@ module.exports = {
|
|||
post,
|
||||
monitorLiveIncoming,
|
||||
monitorStaleIncoming,
|
||||
monitorUnnotified
|
||||
monitorUnnotified,
|
||||
cancel
|
||||
}
|
||||
|
||||
const mapValuesWithKey = _.mapValues.convert({cap: false})
|
||||
|
|
@ -273,3 +274,21 @@ function monitorUnnotified (settings) {
|
|||
.then(txs => Promise.all(txs.map(notify)))
|
||||
.catch(logger.error)
|
||||
}
|
||||
|
||||
function cancel (txId) {
|
||||
const updateRec = {
|
||||
'dispense_time': 'now()^',
|
||||
dispense_error: 'Operator cancel',
|
||||
dispensed: true
|
||||
}
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
return pgp.helpers.update(updateRec, null, 'cash_out_txs') +
|
||||
pgp.as.format(' where id=$1', [txId])
|
||||
})
|
||||
.then(sql => db.result(sql, false))
|
||||
.then(res => {
|
||||
if (res.rowCount !== 1) throw new Error('No such tx-id')
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue