From 8df5f2ba11c874544da8628f4e0e03fadd511eda Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Wed, 3 Mar 2021 09:14:18 +0200 Subject: [PATCH 1/2] fix: sfdc billing account filed dev/prod config ref issue #631 --- config/default.json | 3 ++- config/development.json | 3 ++- config/production.json | 3 ++- src/services/salesforceService.js | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/default.json b/config/default.json index c67a8bdb..9e333c67 100644 --- a/config/default.json +++ b/config/default.json @@ -82,5 +82,6 @@ "CLIENT_AUDIENCE": "", "SUBJECT": "", "CLIENT_ID": "" - } + }, + "sfdcBillingAccountNameField": "Billing_Account_Name__c" } diff --git a/config/development.json b/config/development.json index d20cddd9..2730c285 100644 --- a/config/development.json +++ b/config/development.json @@ -7,5 +7,6 @@ "connectProjectsUrl": "https://connect.topcoder-dev.com/projects/", "memberServiceEndpoint": "https://api.topcoder-dev.com/v3/members", "identityServiceEndpoint": "https://api.topcoder-dev.com/v3/", - "taasJobApiUrl": "https://api.topcoder-dev.com/v5/jobs" + "taasJobApiUrl": "https://api.topcoder-dev.com/v5/jobs", + "sfdcBillingAccountNameField": "Billing_Account_Name__c" } diff --git a/config/production.json b/config/production.json index f7fd78b4..a800ab45 100644 --- a/config/production.json +++ b/config/production.json @@ -1,4 +1,5 @@ { "authDomain": "topcoder.com", - "connectProjectsUrl": "https://connect.topcoder.com/projects/" + "connectProjectsUrl": "https://connect.topcoder.com/projects/", + "sfdcBillingAccountNameField": "Billing_Account_name__c" } diff --git a/src/services/salesforceService.js b/src/services/salesforceService.js index b627704c..651f772f 100644 --- a/src/services/salesforceService.js +++ b/src/services/salesforceService.js @@ -70,7 +70,7 @@ class SalesforceService { 10, null, // fallback to null if cannot parse ), - name: _.get(o, 'Topcoder_Billing_Account__r.Billing_Account_name__c'), + name: _.get(o, `Topcoder_Billing_Account__r.${config.get('sfdcBillingAccountNameField')}`), startDate: _.get(o, 'Topcoder_Billing_Account__r.Start_Date__c'), endDate: _.get(o, 'Topcoder_Billing_Account__r.End_Date__c'), })); From 83bab6c882e2a3cb75f186c79a2be80cd80c0c1a Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Wed, 3 Mar 2021 18:21:39 +0200 Subject: [PATCH 2/2] feat: allow unset project billing account --- src/routes/projects/create.js | 2 +- src/routes/projects/update.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/projects/create.js b/src/routes/projects/create.js index 00b61ced..4f738acd 100644 --- a/src/routes/projects/create.js +++ b/src/routes/projects/create.js @@ -29,7 +29,7 @@ const createProjectValidations = { body: Joi.object().keys({ name: Joi.string().required(), description: Joi.string().allow(null).allow('').optional(), - billingAccountId: Joi.number().positive(), + billingAccountId: Joi.number().positive().allow(null), utm: Joi.object().keys({ source: Joi.string().allow(null), medium: Joi.string().allow(null), diff --git a/src/routes/projects/update.js b/src/routes/projects/update.js index 70ed8e6d..6c2b615d 100644 --- a/src/routes/projects/update.js +++ b/src/routes/projects/update.js @@ -41,7 +41,7 @@ const updateProjectValdiations = { id: Joi.number().valid(Joi.ref('$params.id')), name: Joi.string(), description: Joi.string().allow(null).allow('').optional(), - billingAccountId: Joi.number().positive(), + billingAccountId: Joi.number().positive().allow(null), directProjectId: Joi.number().positive().allow(null), status: Joi.any().valid(_.values(PROJECT_STATUS)), estimatedPrice: Joi.number().precision(2).positive().allow(null),