Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FN-3163): create new dtfs customer in sf feature branch #3892

Open
wants to merge 38 commits into
base: feat/FN-3163/create-new-dtfs-customers-in-sf
Choose a base branch
from

Conversation

natdeanlewissoftwire
Copy link
Contributor

@natdeanlewissoftwire natdeanlewissoftwire commented Nov 5, 2024

Introduction ✏️

As part of the CCM project, if a customer does exist in Salesforce, we are automatically creating it rather than relying on the manual process currently undertaken by Business Support Group. This change sends a request to a new createParty endpoint that will be merged in to the MDM codebase.

Tech docs of the full process are available here

Resolution ✔️

Feature flagged for now:
If the customer lookup fails, send a creation request to MDM.

Miscellaneous ➕

We also replace the current GET customer in SF (that uses Informatica) with a new one that goes direct (hence the new url with /direct/ in) via the SF API.

@natdeanlewissoftwire natdeanlewissoftwire changed the title Feat/fn 3163/create new dtfs customer in sf feature feat(FN-3163): create new dtfs customer in sf feature branch Nov 5, 2024
@natdeanlewissoftwire natdeanlewissoftwire changed the base branch from main to feat/FN-3163/create-new-dtfs-customers-in-sf November 5, 2024 09:07
@@ -820,13 +821,35 @@ const getPartyDbInfo = async ({ companyRegNo }) => {
url: `${EXTERNAL_API_URL}/party-db/${encodeURIComponent(companyRegNo)}`,
headers: headers.external,
});
return response.data;
return AUTOMATIC_SF_CUSTOMER_CREATION_ENABLED ? { status: 200, data: response.data } : response.data;
Copy link
Contributor Author

@natdeanlewissoftwire natdeanlewissoftwire Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response needs a status (following the pattern elsewhere in dtfs) so that we can distinguish between a 404 and an actual failure when querying SF - we don't want to create customers unless we definitely have a 404

@@ -60,7 +77,7 @@ const addPartyUrns = async (deal, auditDetails) => {
...deal.tfm,
parties: {
exporter: {
partyUrn: await getPartyUrn({ companyRegNo: deal.exporter.companiesHouseRegistrationNumber }),
partyUrn: await getPartyUrn({ companyRegNo: deal.exporter.companiesHouseRegistrationNumber, companyName: deal.exporter.companyName }),
Copy link
Contributor Author

@natdeanlewissoftwire natdeanlewissoftwire Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not flagged this additional input as that seems unnecessarily fiddly, let me know if I should!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by flagged please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry that was confusing of me - I mean I've added an extra parameter to this function but it's not behind a feature flag, is that okay?

@@ -21,7 +21,9 @@ export const lookup = async (req: Request, res: Response) => {

const response: { status: number; data: unknown } = await axios({
method: 'get',
url: `${APIM_MDM_URL}customers?companyReg=${companyReg}`,
url: AUTOMATIC_SF_CUSTOMER_CREATION_ENABLED
? `${APIM_MDM_URL}customers/direct?companyRegistrationNumber=${companyReg}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the new direct SF api in MDM, old route is Informatica

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we call this route customers/salesforce rather than customers/direct, makes it a little clearer/less tied to the fact that an endpoint already exists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I agree /salesforce is slightly clearer, will update my MDM work to match also

@natdeanlewissoftwire natdeanlewissoftwire force-pushed the feat/FN-3163/create-new-dtfs-customer-in-sf-feature branch 2 times, most recently from 40ddede to ca987fb Compare November 12, 2024 10:53
Copy link

sonarcloud bot commented Nov 12, 2024

@natdeanlewissoftwire natdeanlewissoftwire marked this pull request as ready for review November 13, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants