Skip to content

Commit 525b1f7

Browse files
committed
PM-1027 - update wallet response
1 parent 215c408 commit 525b1f7

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/api/wallet/wallet.service.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
PaymentStatus,
99
} from 'src/dto/adminWinning.dto';
1010
import { WalletDetailDto } from 'src/dto/wallet.dto';
11+
import { TaxFormRepository } from '../repository/taxForm.repo';
12+
import { PaymentMethodRepository } from '../repository/paymentMethod.repo';
1113

1214
/**
1315
* The winning service.
@@ -18,7 +20,11 @@ export class WalletService {
1820
* Constructs the admin winning service with the given dependencies.
1921
* @param prisma the prisma service.
2022
*/
21-
constructor(private readonly prisma: PrismaService) {}
23+
constructor(
24+
private readonly prisma: PrismaService,
25+
private readonly taxFormRepo: TaxFormRepository,
26+
private readonly paymentMethodRepo: PaymentMethodRepository,
27+
) {}
2228

2329
/**
2430
* Get wallet detail.
@@ -63,6 +69,7 @@ export class WalletService {
6369

6470
// count PAYMENT and REWARD totals
6571
let paymentTotal = 0;
72+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6673
let rewardTotal = 0;
6774
winnings.forEach((item) => {
6875
if (item.type === WinningsType.PAYMENT) {
@@ -90,6 +97,10 @@ export class WalletService {
9097
}
9198
});
9299

100+
const hasActiveTaxForm = await this.taxFormRepo.hasActiveTaxForm(userId);
101+
const hasVerifiedPaymentMethod =
102+
await this.paymentMethodRepo.hasVerifiedPaymentMethod(userId);
103+
93104
const winningTotals: WalletDetailDto = {
94105
account: {
95106
balances: [
@@ -98,18 +109,19 @@ export class WalletService {
98109
amount: paymentTotal,
99110
unit: 'currency',
100111
},
101-
{
102-
type: WinningsType.REWARD,
103-
amount: rewardTotal,
104-
unit: 'points',
105-
},
112+
// hide rewards for now
113+
// {
114+
// type: WinningsType.REWARD,
115+
// amount: rewardTotal,
116+
// unit: 'points',
117+
// },
106118
],
107119
},
108120
withdrawalMethod: {
109-
isSetupComplete: true,
121+
isSetupComplete: hasVerifiedPaymentMethod,
110122
},
111123
taxForm: {
112-
isSetupComplete: true,
124+
isSetupComplete: hasActiveTaxForm,
113125
},
114126
};
115127

0 commit comments

Comments
 (0)