@@ -861,10 +861,10 @@ async function createChallenge (currentUser, challenge) {
861861 }
862862 const { track, type } = await validateChallengeData ( challenge )
863863 const { billingAccountId, markup } = await helper . getProjectBillingInformation ( _ . get ( challenge , 'projectId' ) )
864- if ( _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
864+ if ( billingAccountId && _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
865865 _ . set ( challenge , 'billing.billingAccountId' , billingAccountId )
866866 }
867- if ( _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
867+ if ( markup && _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
868868 _ . set ( challenge , 'billing.markup' , markup )
869869 }
870870 if ( _ . get ( type , 'isTask' ) ) {
@@ -1241,10 +1241,10 @@ async function update (currentUser, challengeId, data, isFull) {
12411241
12421242 const challenge = await helper . getById ( 'Challenge' , challengeId )
12431243 const { billingAccountId, markup } = await helper . getProjectBillingInformation ( _ . get ( challenge , 'projectId' ) )
1244- if ( _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
1244+ if ( billingAccountId && _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
12451245 _ . set ( data , 'billing.billingAccountId' , billingAccountId )
12461246 }
1247- if ( _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
1247+ if ( markup && _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
12481248 _ . set ( data , 'billing.markup' , markup )
12491249 }
12501250 if ( data . status ) {
@@ -1253,7 +1253,7 @@ async function update (currentUser, challengeId, data, isFull) {
12531253 throw new errors . BadRequestError ( 'You cannot activate the challenge as it has not been created on legacy yet. Please try again later or contact support.' )
12541254 }
12551255 // if activating a challenge, the challenge must have a billing account id
1256- if ( ( ! _ . get ( challenge , 'billing. billingAccountId' ) || _ . get ( challenge , 'billing. billingAccountId' ) === null ) &&
1256+ if ( ( ! billingAccountId || billingAccountId === null ) &&
12571257 challenge . status === constants . challengeStatuses . Draft ) {
12581258 throw new errors . BadRequestError ( 'Cannot Activate this project, it has no active billing account.' )
12591259 }
0 commit comments