Skip to content

Commit 476cf7f

Browse files
committed
PM-1111 - send challenge fee to finance api
1 parent 8464a84 commit 476cf7f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/domain/Challenge.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
934934
return 0;
935935
}
936936

937-
let totalAmount = 0;
937+
const totalAmount = payments.reduce((sum, payment) => sum + payment.amount, 0);
938938
// TODO: Make this list exhaustive
939939
const mapType = (type: string) => {
940940
if (type === "placement") {
@@ -961,7 +961,6 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
961961
installmentNumber: 1,
962962
currency: "USD",
963963
billingAccount: `${billingAccountId}`,
964-
challengeMarkup,
965964
},
966965
];
967966

@@ -974,8 +973,6 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
974973
: title;
975974
}
976975

977-
totalAmount += payment.amount;
978-
979976
const payload = {
980977
winnerId: payment.userId.toString(),
981978
type: "PAYMENT",
@@ -988,6 +985,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
988985
attributes: {
989986
billingAccountId,
990987
payroll: false,
988+
challengeFee: totalAmount * challengeMarkup,
991989
},
992990
};
993991

src/util/FinanceApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export interface PaymentDetail {
66
installmentNumber: number;
77
currency: string;
88
billingAccount: string;
9-
challengeMarkup: number;
109
}
1110

1211
export interface PaymentPayload {
@@ -19,6 +18,7 @@ export interface PaymentPayload {
1918
externalId: string;
2019
attributes?: {
2120
[key: string]: string | boolean | number;
21+
challengeFee: number;
2222
};
2323
details: PaymentDetail[];
2424
}

0 commit comments

Comments
 (0)