feat: transactions table

This commit is contained in:
Rafael Taranto 2025-06-05 14:02:07 +01:00
parent 1ead9fe359
commit d6166ce752
29 changed files with 1204 additions and 726 deletions

View file

@ -59,22 +59,6 @@ function massage(tx) {
return mapper(tx)
}
function cancel(txId) {
const promises = [
CashInTx.cancel(txId)
.then(() => true)
.catch(() => false),
CashOutTx.cancel(txId)
.then(() => true)
.catch(() => false),
]
return Promise.all(promises).then(r => {
if (_.some(r)) return
throw new Error('No such transaction')
})
}
function customerHistory(customerId, thresholdDays) {
const sql = `SELECT ch.id, ch.created, ch.fiat, ch.direction FROM (
SELECT txIn.id, txIn.created, txIn.fiat, 'cashIn' AS direction,
@ -99,4 +83,4 @@ function customerHistory(customerId, thresholdDays) {
return db.any(sql, [customerId, `${days} days`, '60 minutes', REDEEMABLE_AGE])
}
module.exports = { post, cancel, customerHistory }
module.exports = { post, customerHistory }