Sync BillingAccountContact deletes with Zuora
Background
At the time of writing this, we are working on building the syncing mechanism for Billing Account Contacts in Mechanism to keep BillingAccountContact data in... (#6285 - closed). A few of us were discussing what to do with contacts that are either deleted in Zuora or no longer marked as the BillTo or SoldTo.
Functionally, CDot only needs to know about BillTo or SoldTo contacts for a BillingAccount. There could be other contacts on the Account, but CDot will not display or use them. However, if a Contact starts as a BillTo or SoldTo but transitions away from that designation but still exists as a contact, we were not planning on building logic to remove these BillingAccountContact records in the DB. They would effectively not be used unless they were marked as BillTo/SoldTo again. The same is true if a contact was deleted in Zuora. We were not planning on deleting the BillingAccountContact in CDot, because there would be no difference in app behavior.
After checking with @snalamaru and the Data team, they recommended tracking when a BillingAccountContact is deleted in CDot. Take a look at the comment thread in #5117 (comment 1378726286) for more details.
Proposal
Update BillingAccountContacts when a Contact is deleted in Zuora.
-
Add a new Zuora custom event and callout triggered when a Zuora Contact is deleted - Engage with @gitlab-com/business-technology/enterprise-apps/zuora-architects to build the custom event and callout.
-
Add deleted_at
timestamp column to thebilling_account_contacts
table and create scope to filter out deleted contacts.- This scope should be used in most places so that deleted contacts are not considered in app logic.
-
Build delete_contact API endpoint in CDot -
Add delete contact worker to update set the deleted_at
timestamp for a BillingAccountContact. -
Update documentation in doc/zuora/zuora_callouts.md
Note: The work in this issue should not be a blocker for rolling out the usage of BillingAccountContacts in &10357 (closed). This could be implemented after that release as a follow-up.