From 67e79280b2ab06f4a1d880215d7b36535d4ab795 Mon Sep 17 00:00:00 2001 From: Fadli Date: Fri, 22 Jul 2022 03:16:52 +0700 Subject: [PATCH] - fix total modal in dashboard admin --- src/transaction/transaction.service.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index e02dd67..622ab38 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1884,15 +1884,24 @@ export class TransactionService { const data = await baseQuery .select('SUM(transactions.amount) as total_amount') - .addSelect('SUM(product_price.price) as total_modal') .addSelect('SUM(product_price.mark_up_price) as total_profit') .addSelect('COUNT(transactions.id) as total_transaction') .getRawOne(); + const dataCoa = this.coaRepository + .createQueryBuilder('coa') + .where( + `coa.type = '0'` + ); + + const coa = await dataCoa + .select('SUM(coa.amount) as total_modal') + .getRawOne(); + return { + total_modal: parseInt(coa.total_modal), total_amount: parseInt(data.total_amount), total_transaction: parseInt(data.total_transaction), - total_modal: parseInt(data.total_modal), total_profit: parseInt(data.total_profit), }; }