@@ -592,7 +592,8 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
592
592
completedChallenge . billing ?. billingAccountId ?? 0 ,
593
593
completedChallenge . legacy ?. subTrack ?? "Task" ,
594
594
completedChallenge . name ,
595
- completedChallenge . payments
595
+ completedChallenge . payments ,
596
+ completedChallenge . billing ?. markup ?? 0 ,
596
597
) ;
597
598
baValidation = {
598
599
challengeId : challenge ?. id ,
@@ -789,7 +790,8 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
789
790
completedChallenge . billing ?. billingAccountId ?? 0 ,
790
791
completedChallenge . legacy ?. subTrack ?? "Task" ,
791
792
completedChallenge . name ,
792
- completedChallenge . payments
793
+ completedChallenge . payments ,
794
+ completedChallenge . billing ?. markup ?? 0 ,
793
795
) ;
794
796
795
797
if ( baValidation != null ) {
@@ -914,7 +916,8 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
914
916
billingAccountId : number ,
915
917
challengeType : string ,
916
918
title : string ,
917
- payments : UpdateChallengeInputForACL_PaymentACL [ ]
919
+ payments : UpdateChallengeInputForACL_PaymentACL [ ] ,
920
+ challengeMarkup : number ,
918
921
) : Promise < number > {
919
922
const token = await m2mToken . getM2MToken ( ) ;
920
923
@@ -931,7 +934,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
931
934
return 0 ;
932
935
}
933
936
934
- let totalAmount = 0 ;
937
+ const totalAmount = payments . reduce ( ( sum , payment ) => sum + payment . amount , 0 ) ;
935
938
// TODO: Make this list exhaustive
936
939
const mapType = ( type : string ) => {
937
940
if ( type === "placement" ) {
@@ -958,6 +961,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
958
961
installmentNumber : 1 ,
959
962
currency : "USD" ,
960
963
billingAccount : `${ billingAccountId } ` ,
964
+ challengeFee : totalAmount * challengeMarkup ,
961
965
} ,
962
966
] ;
963
967
@@ -970,8 +974,6 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
970
974
: title ;
971
975
}
972
976
973
- totalAmount += payment . amount ;
974
-
975
977
const payload = {
976
978
winnerId : payment . userId . toString ( ) ,
977
979
type : "PAYMENT" ,
0 commit comments