diff --git a/lib/customers.js b/lib/customers.js
index 8912b0e7..e9081686 100644
--- a/lib/customers.js
+++ b/lib/customers.js
@@ -386,14 +386,16 @@ function batch () {
*/
function getCustomersList () {
const sql = `select name, phone, total_txs, total_spent,
- created as last_active, fiat as last_tx_fiat, fiat_code as last_tx_fiat_code,
+ coalesce(tx_created, customer_created) as last_active,
+ fiat as last_tx_fiat, fiat_code as last_tx_fiat_code,
tx_class as last_tx_class
from (
- select c.name, c.phone, t.tx_class, t.fiat, t.fiat_code, t.created,
+ select c.name, c.phone, c.created as customer_created,
+ t.tx_class, t.fiat, t.fiat_code, t.created as tx_created,
row_number() over (partition by c.id order by t.created desc) as rn,
- count(0) over (partition by c.id) as total_txs,
- sum(t.fiat) over (partition by c.id) as total_spent
- from customers c inner join (
+ sum(case when t.id is not null then 1 else 0 end) over (partition by c.id) as total_txs,
+ coalesce(sum(t.fiat) over (partition by c.id), 0) as total_spent
+ from customers c left outer join (
select 'cashIn' as tx_class, id, fiat, fiat_code, created, customer_id
from cash_in_txs where send_confirmed = true union
select 'cashOut' as tx_class, id, fiat, fiat_code, created, customer_id
diff --git a/new-lamassu-admin/src/components/fake-table/Table.js b/new-lamassu-admin/src/components/fake-table/Table.js
index efad75d3..5f3cdd90 100644
--- a/new-lamassu-admin/src/components/fake-table/Table.js
+++ b/new-lamassu-admin/src/components/fake-table/Table.js
@@ -90,6 +90,7 @@ const Tr = ({ error, errorMessage, children, className }) => {
const classes = useStyles()
const cardClasses = { root: classes.cardContentRoot }
const classNames = {
+ [classes.tr]: true,
[classes.trError]: error
}
diff --git a/new-lamassu-admin/src/pages/Customers/Customers.js b/new-lamassu-admin/src/pages/Customers/Customers.js
index 4d528210..e629eb1d 100644
--- a/new-lamassu-admin/src/pages/Customers/Customers.js
+++ b/new-lamassu-admin/src/pages/Customers/Customers.js
@@ -44,7 +44,7 @@ const Customers = () => {
{
header: 'Phone',
width: 166,
- view: it => parsePhoneNumberFromString(it.phone).formatInternational()
+ view: it => parsePhoneNumberFromString(it.phone)?.formatInternational()
},
{
header: 'Total TXs',
@@ -56,23 +56,28 @@ const Customers = () => {
header: 'Total spent',
width: 188,
textAlign: 'right',
- view: it => `${Number.parseFloat(it.totalSpent)} ${it.lastTxFiatCode}`
+ view: it =>
+ it.lastTxFiatCode
+ ? `${Number.parseFloat(it.totalSpent)} ${it.lastTxFiatCode}`
+ : null
},
{
header: 'Last active',
width: 197,
- view: it => moment.utc(it.lastActive).format('YYYY-MM-D')
+ view: it =>
+ it.lastActive ? moment.utc(it.lastActive).format('YYYY-MM-D') : null
},
{
header: 'Last transaction',
width: 198,
textAlign: 'right',
- view: it => (
- <>
- {`${Number.parseFloat(it.lastTxFiat)} ${it.lastTxFiatCode} `}
- {it.lastTxClass === 'cashOut' ?