Skip to content

Commit 3b50c8b

Browse files
authored
feat: send topgear payments to wipro payroll (#72)
Signed-off-by: Rakib Ansary <rakibansary@topcoder.com>
1 parent 41e91d1 commit 3b50c8b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/domain/Challenge.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
ES_INDEX,
3131
ES_REFRESH,
3232
PrizeSetTypes,
33+
TGBillingAccounts,
3334
Topics,
3435
} from "../common/Constants";
3536
import BusApi from "../helpers/BusApi";
@@ -580,6 +581,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
580581
const completedChallenge = updatedChallenge.items[0];
581582
const totalAmount = await this.generatePayments(
582583
completedChallenge.id,
584+
completedChallenge.billing?.billingAccountId ?? 0,
583585
completedChallenge.legacy?.subTrack ?? "Task",
584586
completedChallenge.name,
585587
completedChallenge.payments
@@ -776,6 +778,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
776778
console.log("Payments to Generate", completedChallenge.payments);
777779
const totalAmount = await this.generatePayments(
778780
completedChallenge.id,
781+
completedChallenge.billing?.billingAccountId ?? 0,
779782
completedChallenge.legacy?.subTrack ?? "Task",
780783
completedChallenge.name,
781784
completedChallenge.payments
@@ -901,6 +904,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
901904

902905
private async generatePayments(
903906
challengeId: string,
907+
billingAccountId: number,
904908
challengeType: string,
905909
title: string,
906910
payments: UpdateChallengeInputForACL_PaymentACL[]
@@ -975,7 +979,16 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
975979
description,
976980
externalId: challengeId,
977981
details,
982+
attributes: {
983+
billingAccountId,
984+
payroll: false,
985+
},
978986
};
987+
988+
if (_.includes(TGBillingAccounts, billingAccountId)) {
989+
payload.attributes.payroll = true;
990+
}
991+
979992
console.log("Generate payment with payload", payload);
980993
await PaymentCreator.createPayment(payload, await m2mToken.getM2MToken());
981994
}

src/util/PaymentCreator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface PaymentPayload {
1616
description: string;
1717
externalId: string;
1818
attributes?: {
19-
[key: string]: string;
19+
[key: string]: string | boolean | number;
2020
};
2121
details: PaymentDetail[];
2222
}

0 commit comments

Comments
 (0)