diff --git a/pages/admin/orders/index.js b/pages/admin/orders/index.js index 5b38f9c..7abc502 100644 --- a/pages/admin/orders/index.js +++ b/pages/admin/orders/index.js @@ -54,14 +54,19 @@ function getShippingEstimate(order){ } function getAmountPaid(order){ - return formatMoney(order.transactions.map(({payment}) => payment.value_cents) + return formatMoney(order.transactions.map(({payments}) => payments.map(payment => payment.value_cents)) + .flat() .reduce((a,b)=>(a+b))) } -function parsePaymentTime({payment}){ - if(typeof payment.time === 'string') - payment.time = DateTime.fromISO(payment.time) - return payment.time +function parsePaymentTime({payments}){ + for(const payment of payments) { + if(typeof payment.time === 'string') + payment.time = DateTime.fromISO(payment.time) + } + + payments.sort((a,b) => b.time.diff(a.time)) + return payments[0].time } function sortTransactions(a,b){