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

Introduce Account-level matching & mapping to allow supporting Account-level fields on PersonAccounts #269

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jbachelet-osf
Copy link

@jbachelet-osf jbachelet-osf commented Apr 19, 2024

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

  1. B2C to Core resolution -> the B2C customer profile data is filled within a PersonAccount instead of a Contact, and so the matching rule and duplicate rules which fires to resolve the right customer are the PersonAccount-based ones, and not the Contact-ones anymore. Thus, the Contact-based duplicate and matching rules are not used anymore within the code, they are only used by the unit tests.
  2. B2C to Core mapping -> the B2C customer profile data is mapped to a PersonAccount directly, instead of being mapped to a contact and then merged to an account. This makes the data being able to be mapped to both Account-level and Contact-level fields at the same time.
  3. Core to B2C mapping -> the customer profile data that needs to be synched back to B2C are applied in a way that the contact-level mapping are applied first, then the account-level mapping are applied on top of this mapped contact-level data. This ensures that contact-level mapping have the priority in terms of mapping. Then this merged mapping customer profile is sent back to B2C the same way as before.

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.
Screenshot 2024-05-14 at 6 37 58 PM

Screenshot 2024-04-19 at 10 44 17 AM

Use cases

Creation of the Account-level field

In order to make our use case working, we create an Account-level field:
Screenshot 2024-04-19 at 10 10 34 AM

Configuration of Integration Mapping

In order to make our use cases working, we create an integration mapping for an account-level mapping:
Screenshot 2024-04-19 at 10 08 28 AM
Screenshot 2024-04-19 at 10 08 38 AM

1 - Customer resolution (no existing customer in Core, so PersonAccount creation):

Creation of a brand new B2C customer profile, containing an account-level field:
Screenshot 2024-04-19 at 10 10 12 AM

The account is actually created within Core, including the account-level field:
Screenshot 2024-04-19 at 10 22 58 AM

2 - Synching back customer data from Core to B2C

Modifying the Core PersonAccount record:
Screenshot 2024-04-19 at 10 23 30 AM

The B2C customer profile is modified, including the account-level field:
Screenshot 2024-04-19 at 10 23 51 AM

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:
Screenshot 2024-04-19 at 10 54 39 AM

The existing Core PersonAccount is resolved and correctly mapped with both Contact-level and Account-level fields:
Screenshot 2024-04-19 at 10 25 30 AM

@jbachelet-osf jbachelet-osf force-pushed the feature/account-level-mapping-matching branch 3 times, most recently from 4736947 to 1880072 Compare April 25, 2024 19:13
@jbachelet-osf jbachelet-osf force-pushed the feature/account-level-mapping-matching branch 3 times, most recently from 3509b6c to e0ae0c1 Compare April 30, 2024 07:53
@jbachelet-osf jbachelet-osf force-pushed the feature/account-level-mapping-matching branch from e0ae0c1 to ae6d1e3 Compare May 14, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant