Introduce Account-level matching & mapping to allow supporting Account-level fields on PersonAccounts #269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This PR aims to introduce a new feature: Being able to match and map B2C customer profile attributes to Account-level fields from Core.
A bit of technical background: From the Core platform, a PersonAccount is a merge of both the Account and the Contact records. This means that a given PersonAccount record may have Account-level fields, and Contact-level fields. Before this new feature, b2c-crm-sync was only relying on Contact-level fields to ensure the same codebase between the Account-Contact model and the PersonAccount model.
The issue with this logic is that when a business requirement is to create a given field at Account level because it makes more sense, but the data has to be mapped from B2C Commerce, b2c-crm-sync was unable to make it working properly in a standard way. In order to make it work, we would have to duplicate the field at the Contact level and copy over the data between both Contact-level and Account-level fields in order for the data to transit from the Contact to the Account.
Now, b2c-crm-sync is able to get the account-level field from B2C Commerce, use it within the matching rule if needed, and also map it to the PersonAccount record that is being resolved by b2c-crm-sync.
Breaking changes
Changes have been made from within the root code of b2c-crm-sync to make this feature working for PersonAccounts only.
If you enable the PersonAccount model, then the code behaves in a way that
Unit Test Coverage
Same as before, we ensure the solution is 100% passing unit test with a coverage higher than the required 80% for Core and 100% unit test coverage for B2C.
Use cases
Creation of the Account-level field
In order to make our use case working, we create an Account-level field:
Configuration of Integration Mapping
In order to make our use cases working, we create an integration mapping for an account-level mapping:
1 - Customer resolution (no existing customer in Core, so PersonAccount creation):
Creation of a brand new B2C customer profile, containing an account-level field:
The account is actually created within Core, including the account-level field:
2 - Synching back customer data from Core to B2C
Modifying the Core PersonAccount record:
The B2C customer profile is modified, including the account-level field:
3 - Customer resolution on an existing customer (removing the customer profile from b2c and creating it again, but leave the core profile as-is)
Creation of the B2C customer profile, containing the account-level field:
The existing Core PersonAccount is resolved and correctly mapped with both Contact-level and Account-level fields: