@@ -861,10 +861,10 @@ async function createChallenge (currentUser, challenge) {
861
861
}
862
862
const { track, type } = await validateChallengeData ( challenge )
863
863
const { billingAccountId, markup } = await helper . getProjectBillingInformation ( _ . get ( challenge , 'projectId' ) )
864
- if ( _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
864
+ if ( billingAccountId && _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
865
865
_ . set ( challenge , 'billing.billingAccountId' , billingAccountId )
866
866
}
867
- if ( _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
867
+ if ( markup && _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
868
868
_ . set ( challenge , 'billing.markup' , markup )
869
869
}
870
870
if ( _ . get ( type , 'isTask' ) ) {
@@ -1241,10 +1241,10 @@ async function update (currentUser, challengeId, data, isFull) {
1241
1241
1242
1242
const challenge = await helper . getById ( 'Challenge' , challengeId )
1243
1243
const { billingAccountId, markup } = await helper . getProjectBillingInformation ( _ . get ( challenge , 'projectId' ) )
1244
- if ( _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
1244
+ if ( billingAccountId && _ . isUndefined ( _ . get ( challenge , 'billing.billingAccountId' ) ) ) {
1245
1245
_ . set ( data , 'billing.billingAccountId' , billingAccountId )
1246
1246
}
1247
- if ( _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
1247
+ if ( markup && _ . isUndefined ( _ . get ( challenge , 'billing.markup' ) ) ) {
1248
1248
_ . set ( data , 'billing.markup' , markup )
1249
1249
}
1250
1250
if ( data . status ) {
@@ -1253,7 +1253,7 @@ async function update (currentUser, challengeId, data, isFull) {
1253
1253
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.' )
1254
1254
}
1255
1255
// 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 ) &&
1257
1257
challenge . status === constants . challengeStatuses . Draft ) {
1258
1258
throw new errors . BadRequestError ( 'Cannot Activate this project, it has no active billing account.' )
1259
1259
}
0 commit comments