Salesforce Schema — Existing Data Model

Current state in the Kaizen sandbox, annotated for the Salesforce-to-Xero integration project

Live & in use
Partial / needs decision
Empty / abandoned
Xero integration custom

Core Sales & Contract Model

erDiagram Account ||--o{ Opportunity : "has" Account ||--o{ Contract : "has" Account ||--o{ Asset : "owns" Opportunity ||--o{ OpportunityLineItem : "contains" Opportunity ||--o| Contract : "may produce" Contract ||--o{ Asset : "delivers via" OpportunityLineItem }o--|| Product2 : "is a" OpportunityLineItem }o--o| Asset : "previous_asset_lookup" Asset }o--|| Product2 : "is a" Asset }o--o| Contract : "linked to" Account { string Name string ParentId string Primary_RM__c "picklist of names" picklist Invoicing_platforms__c "Ariba/Coupa/Tungsten/etc" string What_regions_are_you_based_in__c "string not picklist" currency ARR_Sum__c string Xero_Contact_Id__c "Xero sync" picklist Billing_Schedule__c "exists but unused?" } Opportunity { string Name picklist StageName "Closed Won target" picklist Type "5 values today" currency ACV__c currency ARR__c currency ARR_delta__c date CloseDate date Service_Commencement_Date_Contract__c date Service_End_Date_Contract__c picklist Renewal_Confidence__c } OpportunityLineItem { string Service__c string Sub_Service__c currency ACV__c currency ARR__c currency One_Off__c currency ARR_delta__c date Service_Commencement_Date__c date Service_End_Date__c picklist Type_of_Billing_Schedule__c string Type__c "1300 char string!" reference Previous_Asset__c "lookup to Asset" string PO_Number__c string SOW_Number__c } Contract { date StartDate date EndDate picklist Status picklist Business_Line__c "Kaizen/SDS/SRB/etc - BILLING ENTITY" picklist Renewal_Clause__c "None/Auto/Rolling" picklist Trackers__c "CPI/RPI" percent Price_increase__c date Service_Commencement_Date__c date Service_Commencement_End_Date__c string PO_Number__c picklist Type_of_Billing_Schedule__c reference Previous_Contract__c reference Next_Contract__c } Asset { date Service_Commencement_Date__c date Service_End_Date__c date Revenue_Start_Date__c currency ACV__c currency ARR__c currency One_Off__c picklist Billing_Schedule__c "Annual/Quarterly/etc" picklist Type_of_Billing_Schedule__c "only 'test'" double Asset_Term__c string Previous_Asset_ID__c "string not lookup" reference Contract__c } Product2 { string Name picklist Family "23 product families" picklist Service__c picklist Subservice__c picklist Regulation__c picklist Jursidiction__c }

Xero Integration Model (custom)

erDiagram Account ||--o{ Xero_Invoice : "has" Account ||--o{ Xero_Credit_Note : "has" Account ||--o{ Xero_Journal : "has" Xero_Invoice ||--o{ Xero_Invoice_Line : "lines" Xero_Invoice ||--o{ Xero_Payment : "payments" Xero_Invoice ||--o{ Xero_Credit_Note : "credited by" Xero_Credit_Note ||--o{ Xero_Credit_Note_Line : "lines" Xero_Journal ||--o{ Xero_Journal_Line : "lines" Xero_Invoice { reference Account__c date Invoice_Date__c date Due_Date__c currency Total__c currency Sub_Total__c currency Total_Tax__c currency Amount_Paid__c currency Amount_Credited__c currency Amount_Due__c picklist Status__c "Draft/Authorised/Paid" string Xero_Invoice_Id__c string Xero_Invoice_Number__c datetime Xero_Last_Synced__c } Xero_Invoice_Line { reference Invoice__c string Description__c decimal Quantity__c decimal Unit_Price__c string Account_Code__c "Xero nominal" string Tax_Type__c } Xero_Credit_Note { reference Account__c reference Invoice__c currency Total__c currency Remaining_Credit__c picklist Status__c string Xero_Credit_Note_Id__c } Xero_Journal { reference Account__c date Journal_Date__c string Narration__c picklist Status__c string Xero_Journal_Id__c }

Bridging the Sales Model and the Xero Model

The integration project needs to wire the Sales Model into the Xero Model. The question is which objects/fields drive the sync triggers and what data flows where.

flowchart LR A[Account] --> B[Opportunity] B --> C[OpportunityLineItem] C -.may produce.-> D[Asset] B -.may produce.-> E[Contract] E -.governs.-> D C --> |"Closed Won + line
= billable event?"| F[Xero_Invoice] D --> |"or is Asset
the trigger?"| F F --> G[Xero_Invoice_Line] F -.credited by.-> H[Xero_Credit_Note] A --> |"Xero_Contact_Id__c
links to Xero"| I[(Xero API)] F --> I H --> I style A fill:#d4edda style B fill:#d4edda style C fill:#d4edda style D fill:#d4edda style E fill:#d4edda style F fill:#cce5ff style G fill:#cce5ff style H fill:#cce5ff style I fill:#fff3cd

Key observations & open questions