Customer matching logic
This is the Customer matching logic that myKaarma backend follows to make sure we do not create duplicates while saving customers.
Logic

Detailed explanations for selected steps in the workflow
Find customers list by communications and VINs:
In this step, the system checks whether communication details are present. If available, it retrieves a list of customers from the database by matching the provided communications. Similarly, it retrieves a list of customers by matching the provided VINs. The resulting customer lists are then merged into a single list.
Find matching customer by input name:
In this step, the system filters the customer list by matching it against the input name. If the resulting list becomes empty, the matching process is aborted. If the list contains exactly one customer, that customer is returned. Otherwise, the system proceeds to the next matching steps.
Find matching customer by customerKey:
In this step, the system filters the customer list using the input customerKey. If the filtered list contains exactly one customer, that customer is returned. If the filtered list becomes empty, this step is skipped and the original (unfiltered) list is retained. Otherwise, the system proceeds to the next step using the filtered list.
Filter list by VINs and communications:
In this step, the system filters the customer list to retain only those customers that have both matching communications and matching VINs.