Search code examples
quickbooksquickbooks-onlineintuit-partner-platform

When I Query an Account with Type "Cost of Goods Sold" how do I return ExpenseAccountRef?


I currently need two more required fields to Create a NonInventory Item:
ExpenseAccountRef.value and ExpenseAccountRef.name

I have issued a Query for AccountType = 'Cost of Goods Sold'

Does Account.Id = ExpenseAccountRef.value?
Does Account.Name = ExpenseAccount.name?

Use Account.Id and Account.Name from that object for ExpenseAccountRef.value and ExpenseAccountRef.name, respectively.

Request URL:

GET /v3/company/4620816365171303340/query?query=select * from Account where AccountType = 'Cost of Goods Sold'&minorversion=59

Content type:text/plain
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com

Query:

select * from Account where AccountType = 
'Cost of Goods Sold'

Returns:

{
 "QueryResponse": {
  "Account": [
   {
    "Name": "Cost of Goods Sold",
    "SubAccount": false,
    "FullyQualifiedName": "Cost of Goods Sold",
    "Active": true,
    "Classification": "Expense",
    "AccountType": "Cost of Goods Sold",
    "AccountSubType": "SuppliesMaterialsCogs",
    "CurrentBalance": 0,
    "CurrentBalanceWithSubAccounts": 0,
    "CurrencyRef": {
     "value": "USD",
     "name": "United States Dollar"
    },
    "domain": "QBO",
    "sparse": false,
    "Id": "80",
    "SyncToken": "0",
    "MetaData": {
     "CreateTime": "2021-05-01T10:36:04-07:00",
     "LastUpdatedTime": "2021-05-01T10:36:04-07:00"
    }
   },
   {
    "Name": "MyJobs_test",
    "SubAccount": false,
    "FullyQualifiedName": "MyJobs_test",
    "Active": true,
    "Classification": "Expense",
    "AccountType": "Cost of Goods Sold",
    "AccountSubType": "CostOfLaborCos",
    "CurrentBalance": 0,
    "CurrentBalanceWithSubAccounts": 0,
    "CurrencyRef": {
     "value": "USD",
     "name": "United States Dollar"
    },
    "domain": "QBO",
    "sparse": false,
    "Id": "91",
    "SyncToken": "0",
    "MetaData": {
     "CreateTime": "2021-07-13T14:31:01-07:00",
     "LastUpdatedTime": "2021-07-13T14:31:01-07:00"
    }
   }
  ],
  "startPosition": 1,
  "maxResults": 2
 },
 "time": "2021-07-15T13:21:57.267-07:00"
}

Info for ExpenseAccountRef from the official Intuit Developer Documentation
"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."
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/item#create-an-item


Solution

  • Yep, you've got it right!

    As the documentation you quoted says:

    "Use Account.Id ... for ExpenseAccountRef.value

    and:

    "Account.Name ... for ExpenseAccountRef.name"

    Your questions here are correct statements!

    Does Account.Id = ExpenseAccountRef.value?

    Does Account.Name = ExpenseAccount.name?

    You answered your own questions. Woohoo! Go you! :-)