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[]; }