From d9415dbaa3ff39b894bd3239fa79d6fa46adff90 Mon Sep 17 00:00:00 2001 From: ilham Date: Thu, 23 Dec 2021 20:43:34 +0700 Subject: [PATCH] add: profit akun coa --- src/helper/enum-list.ts | 1 + src/transaction/transaction.service.ts | 2 +- src/users/users.service.ts | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/helper/enum-list.ts b/src/helper/enum-list.ts index aad950e..2be8537 100644 --- a/src/helper/enum-list.ts +++ b/src/helper/enum-list.ts @@ -30,6 +30,7 @@ export enum coaType { ACCOUNT_PAYABLE, BUDGET, CONTRA_BUDGET, + PROFIT, } export enum balanceType { diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index f7181a5..1018caf 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -737,7 +737,7 @@ export class TransactionService { supervisorData.map(async (it) => { const coaAccount = await this.coaService.findByUser( it.id, - coaType.WALLET, + coaType.PROFIT, ); const commissionValue = await this.commissionService.findOne( it.roles.id, diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 26730ff..197d5e9 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -95,6 +95,15 @@ export class UsersService { dataCoaAR.coaEntityManager = manager; await this.coaService.create(dataCoaAR); + if (roles.name == 'Supervisor' || roles.name == 'Sales') { + const dataCOAProfit = new InputCoaDto(); + dataCOAProfit.user = userData; + dataCOAProfit.balanceType = balanceType.CREDIT; + dataCOAProfit.type = coaType.PROFIT; + dataCOAProfit.coaEntityManager = manager; + await this.coaService.create(dataCOAProfit); + } + if (createUserDto.superior) { const dataCoaAP = new InputCoaDto(); dataCoaAP.user = userData;