feat: show unpaired device names on transactions
This commit is contained in:
parent
ca68fdd0a2
commit
0caa5cbc9a
10 changed files with 96 additions and 90 deletions
|
|
@ -129,8 +129,6 @@ function getMachineNames (config) {
|
||||||
.then(([rawMachines, pings, events, config, heartbeat, performance]) => {
|
.then(([rawMachines, pings, events, config, heartbeat, performance]) => {
|
||||||
const mergeByDeviceId = (x, y) => _.values(_.merge(_.keyBy('deviceId', x), _.keyBy('deviceId', y)))
|
const mergeByDeviceId = (x, y) => _.values(_.merge(_.keyBy('deviceId', x), _.keyBy('deviceId', y)))
|
||||||
const machines = mergeByDeviceId(mergeByDeviceId(rawMachines, heartbeat), performance)
|
const machines = mergeByDeviceId(mergeByDeviceId(rawMachines, heartbeat), performance)
|
||||||
console.log('machines', machines)
|
|
||||||
console.log(machines.map(addName(pings, events, config)))
|
|
||||||
|
|
||||||
return machines.map(addName(pings, events, config))
|
return machines.map(addName(pings, events, config))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,29 @@ const { CASH_OUT_TRANSACTION_STATES } = require('../cash-out/cash-out-helper')
|
||||||
|
|
||||||
function transaction () {
|
function transaction () {
|
||||||
const sql = `SELECT DISTINCT * FROM (
|
const sql = `SELECT DISTINCT * FROM (
|
||||||
SELECT 'type' AS type, 'Cash In' AS value UNION
|
SELECT 'type' AS type, NULL AS label, 'Cash In' AS value UNION
|
||||||
SELECT 'type' AS type, 'Cash Out' AS value UNION
|
SELECT 'type' AS type, NULL AS label, 'Cash Out' AS value UNION
|
||||||
SELECT 'machine' AS type, name AS value FROM devices d INNER JOIN cash_in_txs t ON d.device_id = t.device_id UNION
|
SELECT 'machine' AS type, name AS label, d.device_id AS value FROM devices d INNER JOIN cash_in_txs t ON d.device_id = t.device_id UNION
|
||||||
SELECT 'machine' AS type, name AS value FROM devices d INNER JOIN cash_out_txs t ON d.device_id = t.device_id UNION
|
SELECT 'machine' AS type, name AS label, d.device_id AS value FROM devices d INNER JOIN cash_out_txs t ON d.device_id = t.device_id UNION
|
||||||
SELECT 'customer' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
|
SELECT 'customer' AS type, NULL AS label, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
|
||||||
FROM customers c INNER JOIN cash_in_txs t ON c.id = t.customer_id
|
FROM customers c INNER JOIN cash_in_txs t ON c.id = t.customer_id
|
||||||
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
|
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
|
||||||
SELECT 'customer' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
|
SELECT 'customer' AS type, NULL AS label, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
|
||||||
FROM customers c INNER JOIN cash_out_txs t ON c.id = t.customer_id
|
FROM customers c INNER JOIN cash_out_txs t ON c.id = t.customer_id
|
||||||
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
|
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
|
||||||
SELECT 'fiat' AS type, fiat_code AS value FROM cash_in_txs UNION
|
SELECT 'fiat' AS type, NULL AS label, fiat_code AS value FROM cash_in_txs UNION
|
||||||
SELECT 'fiat' AS type, fiat_code AS value FROM cash_out_txs UNION
|
SELECT 'fiat' AS type, NULL AS label, fiat_code AS value FROM cash_out_txs UNION
|
||||||
SELECT 'crypto' AS type, crypto_code AS value FROM cash_in_txs UNION
|
SELECT 'crypto' AS type, NULL AS label, crypto_code AS value FROM cash_in_txs UNION
|
||||||
SELECT 'crypto' AS type, crypto_code AS value FROM cash_out_txs UNION
|
SELECT 'crypto' AS type, NULL AS label, crypto_code AS value FROM cash_out_txs UNION
|
||||||
SELECT 'address' AS type, to_address AS value FROM cash_in_txs UNION
|
SELECT 'address' AS type, NULL AS label, to_address AS value FROM cash_in_txs UNION
|
||||||
SELECT 'address' AS type, to_address AS value FROM cash_out_txs UNION
|
SELECT 'address' AS type, NULL AS label, to_address AS value FROM cash_out_txs UNION
|
||||||
SELECT 'status' AS type, ${cashInTx.TRANSACTION_STATES} AS value FROM cash_in_txs UNION
|
SELECT 'status' AS type, NULL AS label, ${cashInTx.TRANSACTION_STATES} AS value FROM cash_in_txs UNION
|
||||||
SELECT 'status' AS type, ${CASH_OUT_TRANSACTION_STATES} AS value FROM cash_out_txs UNION
|
SELECT 'status' AS type, NULL AS label, ${CASH_OUT_TRANSACTION_STATES} AS value FROM cash_out_txs UNION
|
||||||
SELECT 'sweep status' AS type, CASE WHEN swept THEN 'Swept' WHEN NOT swept THEN 'Unswept' END AS value FROM cash_out_txs
|
SELECT 'sweep status' AS type, NULL AS label, CASE WHEN swept THEN 'Swept' WHEN NOT swept THEN 'Unswept' END AS value FROM cash_out_txs
|
||||||
) f`
|
) f`
|
||||||
|
|
||||||
return db.any(sql)
|
return db.any(sql)
|
||||||
}
|
}
|
||||||
|
|
||||||
function customer () {
|
function customer () {
|
||||||
const sql = `SELECT DISTINCT * FROM (
|
const sql = `SELECT DISTINCT * FROM (
|
||||||
SELECT 'phone' AS type, phone AS value FROM customers WHERE phone IS NOT NULL UNION
|
SELECT 'phone' AS type, phone AS value FROM customers WHERE phone IS NOT NULL UNION
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ const resolvers = {
|
||||||
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||||
},
|
},
|
||||||
Query: {
|
Query: {
|
||||||
transactions: (...[, { from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers }]) =>
|
transactions: (...[, { from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers }]) =>
|
||||||
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers),
|
transactions.batch(from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers),
|
||||||
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept, timezone, excludeTestingCustomers, simplified }]) =>
|
transactionsCsv: (...[, { from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, timezone, excludeTestingCustomers, simplified }]) =>
|
||||||
transactions.batch(from, until, limit, offset, null, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers, simplified)
|
transactions.batch(from, until, limit, offset, null, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers, simplified)
|
||||||
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime', 'publishedAt']))),
|
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime', 'publishedAt']))),
|
||||||
transactionCsv: (...[, { id, txClass, timezone }]) =>
|
transactionCsv: (...[, { id, txClass, timezone }]) =>
|
||||||
transactions.getTx(id, txClass).then(data =>
|
transactions.getTx(id, txClass).then(data =>
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,12 @@ const typeDef = gql`
|
||||||
type Filter {
|
type Filter {
|
||||||
type: String
|
type: String
|
||||||
value: String
|
value: String
|
||||||
|
label: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
transactions(from: Date, until: Date, limit: Int, offset: Int, deviceId: ID, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, swept: Boolean, excludeTestingCustomers: Boolean): [Transaction] @auth
|
transactions(from: Date, until: Date, limit: Int, offset: Int, txClass: String, deviceId: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, swept: Boolean, excludeTestingCustomers: Boolean): [Transaction] @auth
|
||||||
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, swept: Boolean, timezone: String, excludeTestingCustomers: Boolean, simplified: Boolean): String @auth
|
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, deviceId: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, swept: Boolean, timezone: String, excludeTestingCustomers: Boolean, simplified: Boolean): String @auth
|
||||||
transactionCsv(id: ID, txClass: String, timezone: String): String @auth
|
transactionCsv(id: ID, txClass: String, timezone: String): String @auth
|
||||||
txAssociatedDataCsv(id: ID, txClass: String, timezone: String): String @auth
|
txAssociatedDataCsv(id: ID, txClass: String, timezone: String): String @auth
|
||||||
transactionFilters: [Filter] @auth
|
transactionFilters: [Filter] @auth
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,6 @@ const { REDEEMABLE_AGE, CASH_OUT_TRANSACTION_STATES } = require('../../cash-out/
|
||||||
|
|
||||||
const NUM_RESULTS = 1000
|
const NUM_RESULTS = 1000
|
||||||
|
|
||||||
function addNames (txs) {
|
|
||||||
return machineLoader.getMachineNames()
|
|
||||||
.then(machines => {
|
|
||||||
const addName = tx => {
|
|
||||||
const machine = _.find(['deviceId', tx.deviceId], machines)
|
|
||||||
const name = machine ? machine.name : 'Unpaired'
|
|
||||||
return _.set('machineName', name, tx)
|
|
||||||
}
|
|
||||||
|
|
||||||
return _.map(addName, txs)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function addProfits (txs) {
|
function addProfits (txs) {
|
||||||
return _.map(it => {
|
return _.map(it => {
|
||||||
const profit = getProfit(it).toString()
|
const profit = getProfit(it).toString()
|
||||||
|
|
@ -33,14 +20,31 @@ function addProfits (txs) {
|
||||||
|
|
||||||
const camelize = _.mapKeys(_.camelCase)
|
const camelize = _.mapKeys(_.camelCase)
|
||||||
|
|
||||||
|
const DEVICE_NAME_QUERY = `
|
||||||
|
CASE
|
||||||
|
WHEN ud.name IS NOT NULL THEN ud.name || ' (unpaired)'
|
||||||
|
WHEN d.name IS NOT NULL THEN d.name
|
||||||
|
ELSE 'Unpaired'
|
||||||
|
END AS machine_name
|
||||||
|
`
|
||||||
|
|
||||||
|
const DEVICE_NAME_JOINS = `
|
||||||
|
LEFT JOIN devices d ON txs.device_id = d.device_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT device_id, name, unpaired, paired
|
||||||
|
FROM unpaired_devices
|
||||||
|
) ud ON txs.device_id = ud.device_id
|
||||||
|
AND ud.unpaired >= txs.created
|
||||||
|
AND (txs.created >= ud.paired)
|
||||||
|
`
|
||||||
|
|
||||||
function batch (
|
function batch (
|
||||||
from = new Date(0).toISOString(),
|
from = new Date(0).toISOString(),
|
||||||
until = new Date().toISOString(),
|
until = new Date().toISOString(),
|
||||||
limit = null,
|
limit = null,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
id = null,
|
|
||||||
txClass = null,
|
txClass = null,
|
||||||
machineName = null,
|
deviceId = null,
|
||||||
customerName = null,
|
customerName = null,
|
||||||
fiatCode = null,
|
fiatCode = null,
|
||||||
cryptoCode = null,
|
cryptoCode = null,
|
||||||
|
|
@ -61,8 +65,7 @@ function batch (
|
||||||
k
|
k
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
addProfits,
|
addProfits
|
||||||
addNames
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
||||||
|
|
@ -77,21 +80,20 @@ function batch (
|
||||||
txs.tx_customer_photo_at AS tx_customer_photo_at,
|
txs.tx_customer_photo_at AS tx_customer_photo_at,
|
||||||
txs.tx_customer_photo_path AS tx_customer_photo_path,
|
txs.tx_customer_photo_path AS tx_customer_photo_path,
|
||||||
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $1)) AS expired,
|
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $1)) AS expired,
|
||||||
tb.error_message AS batch_error
|
tb.error_message AS batch_error,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM (SELECT *, ${cashInTx.TRANSACTION_STATES} AS txStatus FROM cash_in_txs) AS txs
|
FROM (SELECT *, ${cashInTx.TRANSACTION_STATES} AS txStatus FROM cash_in_txs) AS txs
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
LEFT JOIN devices d ON txs.device_id = d.device_id
|
${DEVICE_NAME_JOINS}
|
||||||
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
||||||
WHERE txs.created >= $2 AND txs.created <= $3 ${
|
WHERE txs.created >= $2 AND txs.created <= $3
|
||||||
id !== null ? `AND txs.device_id = $6` : ``
|
AND ($6 is null or $6 = 'Cash In')
|
||||||
}
|
AND ($7 is null or txs.device_id = $7)
|
||||||
AND ($7 is null or $7 = 'Cash In')
|
AND ($8 is null or concat(c.id_card_data::json->>'firstName', ' ', c.id_card_data::json->>'lastName') = $8)
|
||||||
AND ($8 is null or d.name = $8)
|
AND ($9 is null or txs.fiat_code = $9)
|
||||||
AND ($9 is null or concat(c.id_card_data::json->>'firstName', ' ', c.id_card_data::json->>'lastName') = $9)
|
AND ($10 is null or txs.crypto_code = $10)
|
||||||
AND ($10 is null or txs.fiat_code = $10)
|
AND ($11 is null or txs.to_address = $11)
|
||||||
AND ($11 is null or txs.crypto_code = $11)
|
AND ($12 is null or txs.txStatus = $12)
|
||||||
AND ($12 is null or txs.to_address = $12)
|
|
||||||
AND ($13 is null or txs.txStatus = $13)
|
|
||||||
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
|
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
|
||||||
${isCsvExport && !simplified ? '' : 'AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0)'}
|
${isCsvExport && !simplified ? '' : 'AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0)'}
|
||||||
ORDER BY created DESC limit $4 offset $5`
|
ORDER BY created DESC limit $4 offset $5`
|
||||||
|
|
@ -109,23 +111,22 @@ function batch (
|
||||||
c.id_card_photo_path AS customer_id_card_photo_path,
|
c.id_card_photo_path AS customer_id_card_photo_path,
|
||||||
txs.tx_customer_photo_at AS tx_customer_photo_at,
|
txs.tx_customer_photo_at AS tx_customer_photo_at,
|
||||||
txs.tx_customer_photo_path AS tx_customer_photo_path,
|
txs.tx_customer_photo_path AS tx_customer_photo_path,
|
||||||
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $1) AS expired
|
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $1) AS expired,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM (SELECT *, ${CASH_OUT_TRANSACTION_STATES} AS txStatus FROM cash_out_txs) txs
|
FROM (SELECT *, ${CASH_OUT_TRANSACTION_STATES} AS txStatus FROM cash_out_txs) txs
|
||||||
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
||||||
AND actions.action = 'provisionAddress'
|
AND actions.action = 'provisionAddress'
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
LEFT JOIN devices d ON txs.device_id = d.device_id
|
${DEVICE_NAME_JOINS}
|
||||||
WHERE txs.created >= $2 AND txs.created <= $3 ${
|
WHERE txs.created >= $2 AND txs.created <= $3
|
||||||
id !== null ? `AND txs.device_id = $6` : ``
|
AND ($6 is null or $6 = 'Cash Out')
|
||||||
}
|
AND ($7 is null or txs.device_id = $7)
|
||||||
AND ($7 is null or $7 = 'Cash Out')
|
AND ($8 is null or concat(c.id_card_data::json->>'firstName', ' ', c.id_card_data::json->>'lastName') = $8)
|
||||||
AND ($8 is null or d.name = $8)
|
AND ($9 is null or txs.fiat_code = $9)
|
||||||
AND ($9 is null or concat(c.id_card_data::json->>'firstName', ' ', c.id_card_data::json->>'lastName') = $9)
|
AND ($10 is null or txs.crypto_code = $10)
|
||||||
AND ($10 is null or txs.fiat_code = $10)
|
AND ($11 is null or txs.to_address = $11)
|
||||||
AND ($11 is null or txs.crypto_code = $11)
|
AND ($12 is null or txs.txStatus = $12)
|
||||||
AND ($12 is null or txs.to_address = $12)
|
AND ($13 is null or txs.swept = $13)
|
||||||
AND ($13 is null or txs.txStatus = $13)
|
|
||||||
AND ($14 is null or txs.swept = $14)
|
|
||||||
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
|
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
|
||||||
${isCsvExport ? '' : 'AND fiat > 0'}
|
${isCsvExport ? '' : 'AND fiat > 0'}
|
||||||
ORDER BY created DESC limit $4 offset $5`
|
ORDER BY created DESC limit $4 offset $5`
|
||||||
|
|
@ -141,13 +142,13 @@ function batch (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCashInOnlyFilters) {
|
if (hasCashInOnlyFilters) {
|
||||||
promises = [db.any(cashInSql, [cashInTx.PENDING_INTERVAL, from, until, limit, offset, id, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status])]
|
promises = [db.any(cashInSql, [cashInTx.PENDING_INTERVAL, from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status])]
|
||||||
} else if (hasCashOutOnlyFilters) {
|
} else if (hasCashOutOnlyFilters) {
|
||||||
promises = [db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset, id, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept])]
|
promises = [db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept])]
|
||||||
} else {
|
} else {
|
||||||
promises = [
|
promises = [
|
||||||
db.any(cashInSql, [cashInTx.PENDING_INTERVAL, from, until, limit, offset, id, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status]),
|
db.any(cashInSql, [cashInTx.PENDING_INTERVAL, from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status]),
|
||||||
db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset, id, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, swept])
|
db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +250,7 @@ const getStatus = it => {
|
||||||
function getCustomerTransactionsBatch (ids) {
|
function getCustomerTransactionsBatch (ids) {
|
||||||
const packager = _.flow(it => {
|
const packager = _.flow(it => {
|
||||||
return it
|
return it
|
||||||
}, _.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addNames)
|
}, _.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize))
|
||||||
|
|
||||||
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
||||||
c.phone AS customer_phone,
|
c.phone AS customer_phone,
|
||||||
|
|
@ -261,9 +262,11 @@ function getCustomerTransactionsBatch (ids) {
|
||||||
c.front_camera_path AS customer_front_camera_path,
|
c.front_camera_path AS customer_front_camera_path,
|
||||||
c.id_card_photo_path AS customer_id_card_photo_path,
|
c.id_card_photo_path AS customer_id_card_photo_path,
|
||||||
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $2)) AS expired,
|
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $2)) AS expired,
|
||||||
tb.error_message AS batch_error
|
tb.error_message AS batch_error,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM cash_in_txs AS txs
|
FROM cash_in_txs AS txs
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
|
${DEVICE_NAME_JOINS}
|
||||||
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
||||||
WHERE c.id IN ($1^)
|
WHERE c.id IN ($1^)
|
||||||
ORDER BY created DESC limit $3`
|
ORDER BY created DESC limit $3`
|
||||||
|
|
@ -279,11 +282,13 @@ function getCustomerTransactionsBatch (ids) {
|
||||||
c.name AS customer_name,
|
c.name AS customer_name,
|
||||||
c.front_camera_path AS customer_front_camera_path,
|
c.front_camera_path AS customer_front_camera_path,
|
||||||
c.id_card_photo_path AS customer_id_card_photo_path,
|
c.id_card_photo_path AS customer_id_card_photo_path,
|
||||||
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $3) AS expired
|
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $3) AS expired,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM cash_out_txs txs
|
FROM cash_out_txs txs
|
||||||
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
||||||
AND actions.action = 'provisionAddress'
|
AND actions.action = 'provisionAddress'
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
|
${DEVICE_NAME_JOINS}
|
||||||
WHERE c.id IN ($1^)
|
WHERE c.id IN ($1^)
|
||||||
ORDER BY created DESC limit $2`
|
ORDER BY created DESC limit $2`
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
|
@ -297,7 +302,7 @@ function getCustomerTransactionsBatch (ids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function single (txId) {
|
function single (txId) {
|
||||||
const packager = _.flow(_.compact, _.map(camelize), addNames)
|
const packager = _.flow(_.compact, _.map(camelize))
|
||||||
|
|
||||||
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
||||||
c.phone AS customer_phone,
|
c.phone AS customer_phone,
|
||||||
|
|
@ -309,9 +314,11 @@ function single (txId) {
|
||||||
c.front_camera_path AS customer_front_camera_path,
|
c.front_camera_path AS customer_front_camera_path,
|
||||||
c.id_card_photo_path AS customer_id_card_photo_path,
|
c.id_card_photo_path AS customer_id_card_photo_path,
|
||||||
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $1)) AS expired,
|
((NOT txs.send_confirmed) AND (txs.created <= now() - interval $1)) AS expired,
|
||||||
tb.error_message AS batch_error
|
tb.error_message AS batch_error,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM cash_in_txs AS txs
|
FROM cash_in_txs AS txs
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
|
${DEVICE_NAME_JOINS}
|
||||||
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
LEFT OUTER JOIN transaction_batches tb ON txs.batch_id = tb.id
|
||||||
WHERE id=$2`
|
WHERE id=$2`
|
||||||
|
|
||||||
|
|
@ -325,13 +332,14 @@ function single (txId) {
|
||||||
c.id_card_data AS customer_id_card_data,
|
c.id_card_data AS customer_id_card_data,
|
||||||
c.name AS customer_name,
|
c.name AS customer_name,
|
||||||
c.front_camera_path AS customer_front_camera_path,
|
c.front_camera_path AS customer_front_camera_path,
|
||||||
|
|
||||||
c.id_card_photo_path AS customer_id_card_photo_path,
|
c.id_card_photo_path AS customer_id_card_photo_path,
|
||||||
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $2) AS expired
|
(NOT txs.dispense AND extract(epoch FROM (now() - greatest(txs.created, txs.confirmed_at))) >= $2) AS expired,
|
||||||
|
${DEVICE_NAME_QUERY}
|
||||||
FROM cash_out_txs txs
|
FROM cash_out_txs txs
|
||||||
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
INNER JOIN cash_out_actions actions ON txs.id = actions.tx_id
|
||||||
AND actions.action = 'provisionAddress'
|
AND actions.action = 'provisionAddress'
|
||||||
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
LEFT OUTER JOIN customers c ON txs.customer_id = c.id
|
||||||
|
${DEVICE_NAME_JOINS}
|
||||||
WHERE id=$1`
|
WHERE id=$1`
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ const SearchBox = memo(
|
||||||
classes={{ option: classes.autocomplete }}
|
classes={{ option: classes.autocomplete }}
|
||||||
value={filters}
|
value={filters}
|
||||||
options={options}
|
options={options}
|
||||||
getOptionLabel={it => it.value}
|
getOptionLabel={it => it.label || it.value}
|
||||||
renderOption={it => (
|
renderOption={it => (
|
||||||
<div className={classes.item}>
|
<div className={classes.item}>
|
||||||
<P className={classes.itemLabel}>{it.value}</P>
|
<P className={classes.itemLabel}>{it.label || it.value}</P>
|
||||||
<P className={classes.itemType}>{it.type}</P>
|
<P className={classes.itemType}>{it.type}</P>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ const SearchFilter = ({
|
||||||
<Chip
|
<Chip
|
||||||
key={idx}
|
key={idx}
|
||||||
classes={chipClasses}
|
classes={chipClasses}
|
||||||
label={`${onlyFirstToUpper(f.type)}: ${f.value}`}
|
label={`${onlyFirstToUpper(f.type)}: ${f.label || f.value}`}
|
||||||
onDelete={() => onFilterDelete(f)}
|
onDelete={() => onFilterDelete(f)}
|
||||||
deleteIcon={<CloseIcon className={classes.button} />}
|
deleteIcon={<CloseIcon className={classes.button} />}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ const MACHINE_LOGS = gql`
|
||||||
`
|
`
|
||||||
|
|
||||||
const createCsv = async ({ machineLogsCsv }) => {
|
const createCsv = async ({ machineLogsCsv }) => {
|
||||||
console.log(machineLogsCsv)
|
|
||||||
const machineLogs = new Blob([machineLogsCsv], {
|
const machineLogs = new Blob([machineLogsCsv], {
|
||||||
type: 'text/plain;charset=utf-8'
|
type: 'text/plain;charset=utf-8'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ const useStyles = makeStyles(mainStyles)
|
||||||
const NUM_LOG_RESULTS = 5
|
const NUM_LOG_RESULTS = 5
|
||||||
|
|
||||||
const GET_TRANSACTIONS = gql`
|
const GET_TRANSACTIONS = gql`
|
||||||
query transactions($limit: Int, $from: Date, $until: Date, $deviceId: ID) {
|
query transactions($limit: Int, $from: Date, $until: Date, $deviceId: String) {
|
||||||
transactions(
|
transactions(
|
||||||
limit: $limit
|
limit: $limit
|
||||||
from: $from
|
from: $from
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ const GET_TRANSACTION_FILTERS = gql`
|
||||||
transactionFilters {
|
transactionFilters {
|
||||||
type
|
type
|
||||||
value
|
value
|
||||||
|
label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
@ -71,7 +72,7 @@ const GET_TRANSACTIONS = gql`
|
||||||
$from: Date
|
$from: Date
|
||||||
$until: Date
|
$until: Date
|
||||||
$txClass: String
|
$txClass: String
|
||||||
$machineName: String
|
$deviceId: String
|
||||||
$customerName: String
|
$customerName: String
|
||||||
$fiatCode: String
|
$fiatCode: String
|
||||||
$cryptoCode: String
|
$cryptoCode: String
|
||||||
|
|
@ -84,7 +85,7 @@ const GET_TRANSACTIONS = gql`
|
||||||
from: $from
|
from: $from
|
||||||
until: $until
|
until: $until
|
||||||
txClass: $txClass
|
txClass: $txClass
|
||||||
machineName: $machineName
|
deviceId: $deviceId
|
||||||
customerName: $customerName
|
customerName: $customerName
|
||||||
fiatCode: $fiatCode
|
fiatCode: $fiatCode
|
||||||
cryptoCode: $cryptoCode
|
cryptoCode: $cryptoCode
|
||||||
|
|
@ -265,13 +266,13 @@ const Transactions = () => {
|
||||||
setVariables({
|
setVariables({
|
||||||
limit: NUM_LOG_RESULTS,
|
limit: NUM_LOG_RESULTS,
|
||||||
txClass: filtersObject.type,
|
txClass: filtersObject.type,
|
||||||
machineName: filtersObject.machine,
|
deviceId: filtersObject.machine,
|
||||||
customerName: filtersObject.customer,
|
customerName: filtersObject.customer,
|
||||||
fiatCode: filtersObject.fiat,
|
fiatCode: filtersObject.fiat,
|
||||||
cryptoCode: filtersObject.crypto,
|
cryptoCode: filtersObject.crypto,
|
||||||
toAddress: filtersObject.address,
|
toAddress: filtersObject.address,
|
||||||
status: filtersObject.status,
|
status: filtersObject.status,
|
||||||
swept: filtersObject.swept === 'Swept'
|
swept: filtersObject.swept && filtersObject.swept === 'Swept'
|
||||||
})
|
})
|
||||||
|
|
||||||
refetch && refetch()
|
refetch && refetch()
|
||||||
|
|
@ -289,13 +290,13 @@ const Transactions = () => {
|
||||||
setVariables({
|
setVariables({
|
||||||
limit: NUM_LOG_RESULTS,
|
limit: NUM_LOG_RESULTS,
|
||||||
txClass: filtersObject.type,
|
txClass: filtersObject.type,
|
||||||
machineName: filtersObject.machine,
|
deviceId: filtersObject.machine,
|
||||||
customerName: filtersObject.customer,
|
customerName: filtersObject.customer,
|
||||||
fiatCode: filtersObject.fiat,
|
fiatCode: filtersObject.fiat,
|
||||||
cryptoCode: filtersObject.crypto,
|
cryptoCode: filtersObject.crypto,
|
||||||
toAddress: filtersObject.address,
|
toAddress: filtersObject.address,
|
||||||
status: filtersObject.status,
|
status: filtersObject.status,
|
||||||
swept: filtersObject.swept === 'Swept'
|
swept: filtersObject.swept && filtersObject.swept === 'Swept'
|
||||||
})
|
})
|
||||||
|
|
||||||
refetch && refetch()
|
refetch && refetch()
|
||||||
|
|
@ -308,13 +309,13 @@ const Transactions = () => {
|
||||||
setVariables({
|
setVariables({
|
||||||
limit: NUM_LOG_RESULTS,
|
limit: NUM_LOG_RESULTS,
|
||||||
txClass: filtersObject.type,
|
txClass: filtersObject.type,
|
||||||
machineName: filtersObject.machine,
|
deviceId: filtersObject.machine,
|
||||||
customerName: filtersObject.customer,
|
customerName: filtersObject.customer,
|
||||||
fiatCode: filtersObject.fiat,
|
fiatCode: filtersObject.fiat,
|
||||||
cryptoCode: filtersObject.crypto,
|
cryptoCode: filtersObject.crypto,
|
||||||
toAddress: filtersObject.address,
|
toAddress: filtersObject.address,
|
||||||
status: filtersObject.status,
|
status: filtersObject.status,
|
||||||
swept: filtersObject.swept === 'Swept'
|
swept: filtersObject.swept && filtersObject.swept === 'Swept'
|
||||||
})
|
})
|
||||||
|
|
||||||
refetch && refetch()
|
refetch && refetch()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue