fix: transaction order product

This commit is contained in:
ilham
2021-12-31 00:59:49 +07:00
parent d66e6eed93
commit a30a81cbb6
2 changed files with 35 additions and 6 deletions

View File

@@ -310,9 +310,6 @@ export class UsersService {
}
async findOne(id: string) {
const coa = await this.coaService.findByUser(id, coaType.WALLET);
const coaProfit = await this.coaService.findByUser(id, coaType.PROFIT);
try {
const userData = await this.usersRepository
.createQueryBuilder('users')
@@ -336,11 +333,17 @@ export class UsersService {
'userDetail.phone_number',
])
.getOne();
const coa = await this.coaService.findByUser(id, coaType.WALLET);
let coaProfit;
if(userData.roles.id != 'e4dfb6a3-2338-464a-8fb8-5cbc089d4209'){
coaProfit = await this.coaService.findByUser(id, coaType.PROFIT);
};
return {
...userData,
wallet: coa.amount,
profit: coaProfit.amount,
profit: coaProfit ? coaProfit.amount : coaProfit,
};
} catch (e) {
if (e instanceof EntityNotFoundError) {