1. Overview
QuickBooks lets each customer have a default payment term (for example Net 15), stored on the QuickBooks Customer as SalesTermRef. The connector now reads that term when customers are pulled into Salesforce. When a new invoice is sent to QuickBooks with no term of its own, it uses the customer's term and recalculates the Due Date from it. Invoices that already have a term are never changed.
2. What changed
|
Area |
Change |
|---|---|
|
Customer pull (QB → SF) |
The customer's |
|
Customer record |
The term's QuickBooks Id is saved in |
|
Invoice push (SF → QB) |
New invoices with no term get the customer's term and a recalculated Due Date before the request is sent. |
3. Objects and fields
|
Object |
Field |
Purpose |
|---|---|---|
|
|
|
QuickBooks Id of the customer's default term |
|
|
|
Lookup to the matching |
|
|
|
Term details, synced by |
4. How it works
4.1 Customer pull
-
WS_QuickbooksreadsSalesTermReffrom the QuickBooks customer and keeps itsnameandvalue. -
WS_Quickbooks.createCustomerRecordssaves the term's QuickBooks Id on the customer record. -
The
Term__clookup is first cleared, then linked only if aQuickbooks_Term__cexists with the sameQB_Id__cfor the same company. -
Terms are synced by
BatchAllQBSFTermSyncbefore customers, so the matching term records already exist when the customers are processed.
4.2 Invoice default term
CMQBConnectorUtility.applyCustomerDefaultTerm(invoices, companyRecordId) runs just before the invoice is sent to QuickBooks. It is called from:
-
BatchSFQBInvoiceSync -
QueueableAutomateQBService
An invoice gets the customer's term only when all of these are true:
-
It is a new invoice (no QuickBooks Id, no SyncToken, or a locally built placeholder Id).
-
It has no term of its own (
termsandsalesTermRefare both blank). -
It has a QuickBooks customer reference.
-
The customer record has a
Quickbooks_Term_QB_Id__cfor this company. -
That term exists and is active (
Active__c = true) for the company.
When it applies:
-
termsandsalesTermRef(value and name) are set to the customer's term. -
Due Date is recalculated as Invoice Date plus the term's
Due_Days__c. -
The date keeps its original format, either
yyyy-MM-ddor the running user's locale format.
4.3 When nothing changes
-
The invoice has an explicit term.
-
The invoice already exists in QuickBooks.
-
The customer has no term, or the term is inactive or not found.
-
Any error inside the method is caught and written to the debug log. The invoice is then sent as before, without a default term.
5. Prerequisites
-
Run the term sync (
BatchAllQBSFTermSync) before the customer sync, and again whenever terms change in QuickBooks. -
Customers must be synced from QuickBooks so their term fields are populated.
6. Testing
CustomerDefaultTermTest covers:
-
Mapping
SalesTermReffrom the customer response. -
Linking the
Term__clookup increateCustomerRecords. -
The invoice fallback: ISO and locale date formats, inactive term, no term, explicit term, and existing invoice.
7. Troubleshooting
|
Symptom |
Likely cause |
|---|---|
|
New invoice has no term |
The customer has no default term in QuickBooks, the term sync has not run, or the term is inactive. |
|
|
The term sync ran after the customer sync. Run the terms and then the customers again. |
|
Due Date unchanged |
The term has no |