fix: customer compliance history
This commit is contained in:
parent
f57d6435a4
commit
e5ab87c2a5
1 changed files with 11 additions and 8 deletions
19
lib/tx.js
19
lib/tx.js
|
|
@ -65,14 +65,17 @@ function cancel (txId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function customerHistory (customerId, thresholdDays) {
|
function customerHistory (customerId, thresholdDays) {
|
||||||
const sql = ` select txIn.id, txIn.created, txIn.fiat, 'cashIn' as direction from cash_in_txs txIn
|
const sql = ` SELECT txIn.id, txIn.created, txIn.fiat, 'cashIn' AS direction
|
||||||
where txIn.customer_id = $1
|
FROM cash_in_txs txIn
|
||||||
and txIn.created > now() - interval $2
|
WHERE txIn.customer_id = $1
|
||||||
union
|
AND txIn.created > now() - interval $2
|
||||||
select txOut.id, txOut.created, txOut.fiat, 'cashOut' as direction from cash_out_txs txOut
|
UNION
|
||||||
where txOut.customer_id = $1
|
SELECT txOut.id, txOut.created, txOut.fiat, 'cashOut' AS direction
|
||||||
and txOut.created > now() - interval $2
|
FROM cash_out_txs txOut
|
||||||
order by created;`
|
WHERE txOut.customer_id = $1
|
||||||
|
AND txOut.created > now() - interval $2
|
||||||
|
AND (timedout = true OR error_code != 'operatorCancel')
|
||||||
|
ORDER BY created;`
|
||||||
|
|
||||||
const days = _.isNil(thresholdDays) ? 0 : thresholdDays
|
const days = _.isNil(thresholdDays) ? 0 : thresholdDays
|
||||||
return db.any(sql, [customerId, `${days} days`])
|
return db.any(sql, [customerId, `${days} days`])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue