Search code examples
apiquickbooksquickbooks-onlineintuit-partner-platform

How does QuickBooks online determine the ExpenseAccountRef.value? Do I need to QUERY an ACCOUNT object to determine the value?


My app will use QuickBooks Online API to to "Create a NonInventory Item"

I don't understand how this value is determined.
Do I have to initialize my NonInventory Item with an ExpenseAccountRef.value?
Should I QUERY the ACCOUNT object to determine which values exist before initializing a new one?

Below is an example of the required fields:

{ 
  "Name": "Garden Supplies",  
  "Type": "NonInventory", 
  "ExpenseAccountRef": { 
    "value": "80"
  }
}

In the documentation (found at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/item), it states:

ExpenseAccountRef
"Reference to the expense account used to pay the vendor for this item. Must be an account with account type of Cost of Goods Sold. Query the Account name list resource to determine the appropriate Account object for this reference. Use Account.Id and Account.Name from that object for ExpenseAccountRef.value and ExpenseAccountRef.name, respectively."

value String
"The ID for the referenced object as found in the Id field of the object payload. The context is set by the type of reference and is specific to the QuickBooks company file."


Solution

  • Do I have to initialize my NonInventory Item with an ExpenseAccountRef.value?

    Is it marked as a required field in the documentation? If so, then yes.

    Should I QUERY the ACCOUNT object to determine which values exist before initializing a new one?

    Yes. The docs you quoted indicate this as well:

    "Query the Account name list resource to determine the appropriate Account object for this reference. Use Account.Id and Account.Name from that object for ExpenseAccountRef.value and ExpenseAccountRef.name, respectively."