WIP
This commit is contained in:
parent
11b5958c60
commit
e7960c217c
3 changed files with 21 additions and 4 deletions
|
|
@ -530,6 +530,22 @@ exports.fetchTx = function fetchTx (session, cb) {
|
|||
})
|
||||
}
|
||||
|
||||
exports.addDispenseRequest = function addDispenseRequest (session, tx, cb) {
|
||||
connect(function (cerr, client, done) {
|
||||
if (cerr) return
|
||||
|
||||
const originalSession = {id: tx.sessionId, fingerprint: session.fingerprint}
|
||||
async.waterfall([
|
||||
async.apply(updateDispense, client, true),
|
||||
async.apply(insertIncoming, client, originalSession, tx, 0, tx.fiat,
|
||||
'dispense', 'pending')
|
||||
], function (err) {
|
||||
done()
|
||||
if (err) logger.error(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateDispense (client, session, dispensed, cb) {
|
||||
var sql = 'UPDATE transactions SET dispense=$1 ' +
|
||||
'WHERE stage=$2 AND authority=$3 AND device_fingerprint=$4 AND session_id=$5'
|
||||
|
|
@ -557,7 +573,6 @@ exports.addDispense = function addDispense (session, tx, cartridges) {
|
|||
if (cerr) return
|
||||
|
||||
async.waterfall([
|
||||
async.apply(updateDispense, client, true),
|
||||
async.apply(insertIncoming, client, session, tx, 0, tx.fiat,
|
||||
'dispense', 'authorized'),
|
||||
async.apply(insertDispense, client, session, tx, cartridges)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue