fix: expired column in customer transactions history

This commit is contained in:
André Sá 2021-10-13 18:21:45 +01:00
parent c819a354bc
commit 168192b708
4 changed files with 13 additions and 9 deletions

View file

@ -5,7 +5,9 @@ const CashInTx = require('./cash-in/cash-in-tx')
const CashOutTx = require('./cash-out/cash-out-tx')
const T = require('./time')
const REDEEMABLE_AGE = T.day
// FP operations on Postgres result in very big errors.
// E.g.: 1853.013808 * 1000 = 1866149.494
const REDEEMABLE_AGE = T.day / 1000
function process (tx, pi) {
const mtx = massage(tx, pi)
@ -76,7 +78,7 @@ function customerHistory (customerId, thresholdDays) {
AND txIn.created > now() - interval $2
UNION
SELECT txOut.id, txOut.created, txOut.fiat, 'cashOut' AS direction,
(extract(epoch FROM (now() - greatest(txOut.created, txOut.confirmed_at))) * 1000) >= $4 AS expired
(NOT txOut.dispense AND extract(epoch FROM (now() - greatest(txOut.created, txOut.confirmed_at))) >= $4) AS expired
FROM cash_out_txs txOut
WHERE txOut.customer_id = $1
AND txOut.created > now() - interval $2