From 3709d12cdfbda09cf80881175aa15554c2fbeb1f Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Wed, 14 Feb 2024 19:33:08 +0600 Subject: [PATCH] feat: send topgear payments to wipro payroll Signed-off-by: Rakib Ansary --- src/domain/Challenge.ts | 13 +++++++++++++ src/util/PaymentCreator.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/domain/Challenge.ts b/src/domain/Challenge.ts index a6fbf9c..4c2efd9 100644 --- a/src/domain/Challenge.ts +++ b/src/domain/Challenge.ts @@ -30,6 +30,7 @@ import { ES_INDEX, ES_REFRESH, PrizeSetTypes, + TGBillingAccounts, Topics, } from "../common/Constants"; import BusApi from "../helpers/BusApi"; @@ -580,6 +581,7 @@ class ChallengeDomain extends CoreOperations { const completedChallenge = updatedChallenge.items[0]; const totalAmount = await this.generatePayments( completedChallenge.id, + completedChallenge.billing?.billingAccountId ?? 0, completedChallenge.legacy?.subTrack ?? "Task", completedChallenge.name, completedChallenge.payments @@ -776,6 +778,7 @@ class ChallengeDomain extends CoreOperations { console.log("Payments to Generate", completedChallenge.payments); const totalAmount = await this.generatePayments( completedChallenge.id, + completedChallenge.billing?.billingAccountId ?? 0, completedChallenge.legacy?.subTrack ?? "Task", completedChallenge.name, completedChallenge.payments @@ -901,6 +904,7 @@ class ChallengeDomain extends CoreOperations { private async generatePayments( challengeId: string, + billingAccountId: number, challengeType: string, title: string, payments: UpdateChallengeInputForACL_PaymentACL[] @@ -975,7 +979,16 @@ class ChallengeDomain extends CoreOperations { description, externalId: challengeId, details, + attributes: { + billingAccountId, + payroll: false, + }, }; + + if (_.includes(TGBillingAccounts, billingAccountId)) { + payload.attributes.payroll = true; + } + console.log("Generate payment with payload", payload); await PaymentCreator.createPayment(payload, await m2mToken.getM2MToken()); } diff --git a/src/util/PaymentCreator.ts b/src/util/PaymentCreator.ts index c2ee98b..89ee1b5 100644 --- a/src/util/PaymentCreator.ts +++ b/src/util/PaymentCreator.ts @@ -16,7 +16,7 @@ export interface PaymentPayload { description: string; externalId: string; attributes?: { - [key: string]: string; + [key: string]: string | boolean | number; }; details: PaymentDetail[]; }