GithubHelp home page GithubHelp logo

node-quickbooks's Introduction

node-quickbooks

nodejs client for Intuit's QuickBooks API

Installation

npm install node-quickbooks

Documentation

var QuickBooks = require('node-quickbooks')

var qbo = new QuickBooks(consumerKey,
                         consumerSecret,
                         oauthToken,
                         false, // no token secret for oAuth 2.0
                         realmId,
                         false, // use the sandbox?
                         true, // enable debugging?
                         null, // set minorversion, or null for the latest version
                         '2.0', //oAuth version
                         refreshToken);

qbo.createAttachable({Note: 'My File'}, function(err, attachable) {
  if (err) console.log(err)
  else console.log(attachable.Id)
})

qbo.getBillPayment('42', function(err, billPayment) {
  console.log(billPayment)
})

qbo.updateCustomer({
  Id: '42',
  SyncToken: '1',
  sparse: true,
  PrimaryEmailAddr: {Address: '[email protected]'}
}, function(err, customer) {
  if (err) console.log(err)
  else console.log(customer)
})

qbo.deleteAttachable('42', function(err, attachable) {
  if (err) console.log(err)
  else console.log(attachable)
}))

qbo.findAccounts({
  AccountType: 'Expense',
  desc: 'MetaData.LastUpdatedTime',
  limit: 5,
  offset: 5
  }, function(err, accounts) {
  accounts.QueryResponse.Account.forEach(function(account) {
    console.log(account.Name)
  })
})

qbo.reportBalanceSheet({department: '1,4,7'}, function(err, balanceSheet) {
  console.log(balanceSheet)
})

qbo.upload(
  'contractor.jpg',
  'image/jpeg',
  fs.createReadStream('contractor.jpg'),
  'Invoice',
  40,
  function(err, data) {
    console.log(err)
    console.log(data)
  })

Query

Filters

All query functions take an optional first argument object which will be converted to a where clause by means of the keys and values of the object used as column names and parameter values of the where clause. For example, in order to issue a query with a simple where clause such as, select * from attachable where Note = 'My sample note field', the following code would be needed:

qbo.findAttachables({
  Note: 'My sample note field'
}, function(e, attachables) {
  console.log(attachables)
})

Alternatively, the object can be an array of objects, each specifying a field, value and operator (optional) keys. This allows you to build a more complex query using operators such as =, IN, <, >, <=, >=, or LIKE.

qbo.findTimeActivities([
  {field: 'TxnDate', value: '2014-12-01', operator: '>'},
  {field: 'TxnDate', value: '2014-12-03', operator: '<'},
  {field: 'limit', value: 5}
], function (e, timeActivities) {
  console.log(timeActivities)
})
Sorting

Basic ordering is achieved via the optional first argument object as well. Include asc or desc keys in the object whose values are the columns you wish to sort on. For example:

qbo.findAttachables({
  desc: 'MetaData.LastUpdatedTime'
}, function(e, attachables) {
  console.log(attachables)
})
Pagination

Pagination is achieved via the optional first argument object as well. Include limit and/or offset keys in the object whose values are the number of rows you wish to limit the result set to or from respectively. For example:

qbo.findAttachables({
  limit: 10,
  offset: 10
}, function(e, attachables) {
  console.log(attachables)
})

The default (and max) limit is 1000 records returned in a single request. Adding a boolean fetchAll parameter will return all available records, transparently issuing as many requests as necessary to fetch them. So in the first example below, if your Quickbooks business contains 5,000 customers, 5 http requests will be issued behind the scenes and finally your callback will be invoked with an array of those 5,000 customers passed to it.

qbo.findCustomers({
  fetchAll: true
}, function(e, customers) {
  console.log(customers)
})

qbo.findCustomers([
  {field: 'fetchAll', value: true},
  {field: 'FamilyName', value: 'S%', operator: 'LIKE'}
], function(e, customers) {
  console.log(customers)
})
Counts

Row counts rather than full result sets can be obtained by passing the count key in the optional first argument object with a boolean true value. For example:

qbo.findAttachables({
  count: true
}, function(e, attachables) {
  console.log(attachables)
})

Example App

The example directory contains a barebones Express application that demonstrates the OAuth workflow.

Setup

First navigate to the example directory and install the required dependencies from NPM

npm install

You will need to create an Intuit Developer account at https://developer.intuit.com and add your app's OAuth Consumer Key and Secret to app.js. Pay attention to which APIs (Payments, QuickBooks) you select during the application creation process, you will have to update example/views/intuit.ejs if you did not select both.

Running

Start the app

node app.js

Browse to http://localhost:3000/start and you will see a page containing only the Intuit Developer Javascript-rendered button. Clicking on this kicks off the OAuth exchange.

The Intuit Developer Javascript code calls back into the node application, which needs to invoke the OAuth Request Token URL at https://oauth.intuit.com/oauth/v1/get_request_token via a server-side http POST method. Note how the response from the http POST is parsed and the browser is redirected to the App Center URL at https://appcenter.intuit.com/Connect/Begin?oauth_token= with the oauth_token passed as a URL parameter. Note also how the oauth_token_secret needs to somehow be maintained across http requests, as it needs to be passed in the second server-side http POST to the Access Token URL at https://oauth.intuit.com/oauth/v1/get_access_token. This final step is invoked once the user has authenticated on Intuit's site and authorized the application, and then the user is redirected back to the node application at the callback URL specified as a parameter in the Request Token remote call, in the example app's case, http://localhost:3000/callback.

Configuration

The Intuit Developer Javascript code contained in intuit.ejs is configured with the grantUrl option set to "http://localhost:3000/requestToken". You will want to change this to an appropriate URL for your application, but you will need to write similar functionality to that contained in the '/requestToken' route configured in app.js, also taking care to configure your consumerKey and consumerSecret on lines 27-28 in app.js.

Running the tests

First you'll need to fill in the missing values in config.js. The consumerKey and consumerSecret you can get from the Intuit Developer portal, the token, tokenSecret, and realmId are easiest to obtain by running the example app, completing the OAuth workflow, and copying the values that are logged to the console. Once you've filled in the missing credentials in config.js you can simply run:

npm test

Public Api

QuickBooks(consumerKey, consumerSecret, oauth_token, oauth_token_secret, realmId, debug, minorVer, oAuthVer, refresh_token)

Arguments

  • consumerKey - The application's consumer key
  • consumerSecret - The application's consumer secret
  • oauth_token - The user's generated token
  • oauth_token_secret - The user's generated secret. Set this to false for oAuth 2.
  • realmId - The company ID
  • useSandbox - boolean flag to indicate whether to use Sandbox (i.e. for testing)
  • debug - boolean flag to log http requests, headers, and response bodies to the console
  • minorVer - Minor version for Intuit's API. Use null if you do not want to specify a version, to use the latest
  • oAuthVer - Use string '2.0' for oAuth 2
  • refresh_token - The user's generated refresh token. This is the code query parameter in the oAuth 2.0 callback

Create

Read

Update

Delete

Query

Reports

SalesReceipt and Invoice PDFs

Purchase Order Email

Miscellaneous

createAccount(object, callback)

Creates the Account in QuickBooks

Arguments

  • object - The unsaved account, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Account

createAttachable(object, callback)

Creates the Attachable in QuickBooks

Arguments

  • object - The unsaved attachable, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Attachable

createBill(object, callback)

Creates the Bill in QuickBooks

Arguments

  • object - The unsaved bill, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Bill

createBillPayment(object, callback)

Creates the BillPayment in QuickBooks

Arguments

  • object - The unsaved billPayment, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent BillPayment

createClass(object, callback)

Creates the Class in QuickBooks

Arguments

  • object - The unsaved class, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Class

createCreditMemo(object, callback)

Creates the CreditMemo in QuickBooks

Arguments

  • object - The unsaved creditMemo, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent CreditMemo

createCustomer(object, callback)

Creates the Customer in QuickBooks

Arguments

  • object - The unsaved customer, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Customer

createDepartment(object, callback)

Creates the Department in QuickBooks

Arguments

  • object - The unsaved department, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Department

createDeposit(object, callback)

Creates the Deposit in QuickBooks

Arguments

  • object - The unsaved deposit, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Deposit

createEmployee(object, callback)

Creates the Employee in QuickBooks

Arguments

  • object - The unsaved employee, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Employee

createEstimate(object, callback)

Creates the Estimate in QuickBooks

Arguments

  • object - The unsaved estimate, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Estimate

createInvoice(object, callback)

Creates the Invoice in QuickBooks

Arguments

  • object - The unsaved invoice, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Invoice

createItem(object, callback)

Creates the Item in QuickBooks

Arguments

  • object - The unsaved item, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Item

createJournalCode(object, callback)

Creates the JournalCode in QuickBooks

Arguments

  • object - The unsaved journalCode, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent JournalCode

createJournalEntry(object, callback)

Creates the JournalEntry in QuickBooks

Arguments

  • object - The unsaved journalEntry, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent JournalEntry

createPayment(object, callback)

Creates the Payment in QuickBooks

Arguments

  • object - The unsaved payment, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Payment

createPaymentMethod(object, callback)

Creates the PaymentMethod in QuickBooks

Arguments

  • object - The unsaved paymentMethod, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent PaymentMethod

createPurchase(object, callback)

Creates the Purchase in QuickBooks

Arguments

  • object - The unsaved purchase, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Purchase

createPurchaseOrder(object, callback)

Creates the PurchaseOrder in QuickBooks

Arguments

  • object - The unsaved purchaseOrder, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent PurchaseOrder

createRefundReceipt(object, callback)

Creates the RefundReceipt in QuickBooks

Arguments

  • object - The unsaved refundReceipt, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent RefundReceipt

createSalesReceipt(object, callback)

Creates the SalesReceipt in QuickBooks

Arguments

  • object - The unsaved salesReceipt, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent SalesReceipt

createTaxAgency(object, callback)

Creates the TaxAgency in QuickBooks

Arguments

  • object - The unsaved taxAgency, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent TaxAgency

createTaxService(object, callback)

Creates the TaxService in QuickBooks

Arguments

  • object - The unsaved taxService, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent TaxService

createTerm(object, callback)

Creates the Term in QuickBooks

Arguments

  • object - The unsaved term, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Term

createTimeActivity(object, callback)

Creates the TimeActivity in QuickBooks

Arguments

  • object - The unsaved timeActivity, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent TimeActivity

createTransfer(object, callback)

Creates the Transfer in QuickBooks

Arguments

  • object - The unsaved transfer, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Transfer

createVendor(object, callback)

Creates the Vendor in QuickBooks

Arguments

  • object - The unsaved vendor, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent Vendor

createVendorCredit(object, callback)

Creates the VendorCredit in QuickBooks

Arguments

  • object - The unsaved vendorCredit, to be persisted in QuickBooks
  • callback - Callback function which is called with any error and the persistent VendorCredit

getAccount(id, callback)

Retrieves the Account from QuickBooks

Arguments

  • id - The Id of persistent Account
  • callback - Callback function which is called with any error and the persistent Account

getAttachable(id, callback)

Retrieves the Attachable from QuickBooks

Arguments

  • id - The Id of persistent Attachable
  • callback - Callback function which is called with any error and the persistent Attachable

getBill(id, callback)

Retrieves the Bill from QuickBooks

Arguments

  • id - The Id of persistent Bill
  • callback - Callback function which is called with any error and the persistent Bill

getBillPayment(id, callback)

Retrieves the BillPayment from QuickBooks

Arguments

  • id - The Id of persistent BillPayment
  • callback - Callback function which is called with any error and the persistent BillPayment

getClass(id, callback)

Retrieves the Class from QuickBooks

Arguments

  • id - The Id of persistent Class
  • callback - Callback function which is called with any error and the persistent Class

getCompanyInfo(id, callback)

Retrieves the CompanyInfo from QuickBooks

Arguments

  • id - The Id of persistent CompanyInfo
  • callback - Callback function which is called with any error and the persistent CompanyInfo

getCreditMemo(id, callback)

Retrieves the CreditMemo from QuickBooks

Arguments

  • id - The Id of persistent CreditMemo
  • callback - Callback function which is called with any error and the persistent CreditMemo

getCustomer(id, callback)

Retrieves the Customer from QuickBooks

Arguments

  • id - The Id of persistent Customer
  • callback - Callback function which is called with any error and the persistent Customer

getDepartment(id, callback)

Retrieves the Department from QuickBooks

Arguments

  • id - The Id of persistent Department
  • callback - Callback function which is called with any error and the persistent Department

getDeposit(id, callback)

Retrieves the Deposit from QuickBooks

Arguments

  • id - The Id of persistent Deposit
  • callback - Callback function which is called with any error and the persistent Deposit

getEmployee(id, callback)

Retrieves the Employee from QuickBooks

Arguments

  • id - The Id of persistent Employee
  • callback - Callback function which is called with any error and the persistent Employee

getEstimate(id, callback)

Retrieves the Estimate from QuickBooks

Arguments

  • id - The Id of persistent Estimate
  • callback - Callback function which is called with any error and the persistent Estimate

getExchangeRate(options, callback)

Retrieves an ExchangeRate from QuickBooks

Arguments

  • options - An object with options including the required sourcecurrencycode parameter and optional asofdate parameter.
  • callback - Callback function which is called with any error and the ExchangeRate

getInvoice(id, callback)

Retrieves the Invoice from QuickBooks

Arguments

  • id - The Id of persistent Invoice
  • callback - Callback function which is called with any error and the persistent Invoice

getItem(id, callback)

Retrieves the Item from QuickBooks

Arguments

  • id - The Id of persistent Item
  • callback - Callback function which is called with any error and the persistent Item

getJournalCode(id, callback)

Retrieves the JournalCode from QuickBooks

Arguments

  • id - The Id of persistent JournalCode
  • callback - Callback function which is called with any error and the persistent JournalCode

getJournalEntry(id, callback)

Retrieves the JournalEntry from QuickBooks

Arguments

  • id - The Id of persistent JournalEntry
  • callback - Callback function which is called with any error and the persistent JournalEntry

getPayment(id, callback)

Retrieves the Payment from QuickBooks

Arguments

  • id - The Id of persistent Payment
  • callback - Callback function which is called with any error and the persistent Payment

getPaymentMethod(id, callback)

Retrieves the PaymentMethod from QuickBooks

Arguments

  • id - The Id of persistent PaymentMethod
  • callback - Callback function which is called with any error and the persistent PaymentMethod

getPreferences(callback)

Retrieves the Preferences from QuickBooks

Arguments

  • callback - Callback function which is called with any error and the Preferences of the authorised realm

getPurchase(id, callback)

Retrieves the Purchase from QuickBooks

Arguments

  • id - The Id of persistent Purchase
  • callback - Callback function which is called with any error and the persistent Purchase

getPurchaseOrder(id, callback)

Retrieves the PurchaseOrder from QuickBooks

Arguments

  • id - The Id of persistent PurchaseOrder
  • callback - Callback function which is called with any error and the persistent PurchaseOrder

getRefundReceipt(id, callback)

Retrieves the RefundReceipt from QuickBooks

Arguments

  • id - The Id of persistent RefundReceipt
  • callback - Callback function which is called with any error and the persistent RefundReceipt

getReports(id, callback)

Retrieves the Reports from QuickBooks

Arguments

  • id - The Id of persistent Reports
  • callback - Callback function which is called with any error and the persistent Reports

getSalesReceipt(id, callback)

Retrieves the SalesReceipt from QuickBooks

Arguments

  • id - The Id of persistent SalesReceipt
  • callback - Callback function which is called with any error and the persistent SalesReceipt

getTaxAgency(id, callback)

Retrieves the TaxAgency from QuickBooks

Arguments

  • id - The Id of persistent TaxAgency
  • callback - Callback function which is called with any error and the persistent TaxAgency

getTaxCode(id, callback)

Retrieves the TaxCode from QuickBooks

Arguments

  • id - The Id of persistent TaxCode
  • callback - Callback function which is called with any error and the persistent TaxCode

getTaxRate(id, callback)

Retrieves the TaxRate from QuickBooks

Arguments

  • id - The Id of persistent TaxRate
  • callback - Callback function which is called with any error and the persistent TaxRate

getTerm(id, callback)

Retrieves the Term from QuickBooks

Arguments

  • id - The Id of persistent Term
  • callback - Callback function which is called with any error and the persistent Term

getTimeActivity(id, callback)

Retrieves the TimeActivity from QuickBooks

Arguments

  • id - The Id of persistent TimeActivity
  • callback - Callback function which is called with any error and the persistent TimeActivity

getTransfer(id, callback)

Retrieves the Transfer from QuickBooks

Arguments

  • id - The Id of persistent Transfer
  • callback - Callback function which is called with any error and the persistent Transfer

getVendor(id, callback)

Retrieves the Vendor from QuickBooks

Arguments

  • id - The Id of persistent Vendor
  • callback - Callback function which is called with any error and the persistent Vendor

getVendorCredit(id, callback)

Retrieves the VendorCredit from QuickBooks

Arguments

  • id - The Id of persistent VendorCredit
  • callback - Callback function which is called with any error and the persistent VendorCredit

updateAccount(object, callback)

Updates QuickBooks version of Account

Arguments

  • object - The persistent Account, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Account

updateAttachable(object, callback)

Updates QuickBooks version of Attachable

Arguments

  • object - The persistent Attachable, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Attachable

updateBill(object, callback)

Updates QuickBooks version of Bill

Arguments

  • object - The persistent Bill, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Bill

updateBillPayment(object, callback)

Updates QuickBooks version of BillPayment

Arguments

  • object - The persistent BillPayment, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated BillPayment

updateClass(object, callback)

Updates QuickBooks version of Class

Arguments

  • object - The persistent Class, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Class

updateCompanyInfo(object, callback)

Updates QuickBooks version of CompanyInfo

Arguments

  • object - The persistent CompanyInfo, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated CompanyInfo

updateCreditMemo(object, callback)

Updates QuickBooks version of CreditMemo

Arguments

  • object - The persistent CreditMemo, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated CreditMemo

updateCustomer(object, callback)

Updates QuickBooks version of Customer

Arguments

  • object - The persistent Customer, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Customer

updateDepartment(object, callback)

Updates QuickBooks version of Department

Arguments

  • object - The persistent Department, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Department

updateDeposit(object, callback)

Updates QuickBooks version of Deposit

Arguments

  • object - The persistent Deposit, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Deposit

updateEmployee(object, callback)

Updates QuickBooks version of Employee

Arguments

  • object - The persistent Employee, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Employee

updateEstimate(object, callback)

Updates QuickBooks version of Estimate

Arguments

  • object - The persistent Estimate, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Estimate

updateInvoice(object, callback)

Updates QuickBooks version of Invoice

Arguments

  • object - The persistent Invoice, including Id and SyncToken fields. To void invoice set void:true in the object.
  • callback - Callback function which is called with any error and the updated Invoice

updateItem(object, callback)

Updates QuickBooks version of Item

Arguments

  • object - The persistent Item, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Item

updateJournalCode(object, callback)

Updates QuickBooks version of JournalCode

Arguments

  • object - The persistent JournalCode, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated JournalCode

updateJournalEntry(object, callback)

Updates QuickBooks version of JournalEntry

Arguments

  • object - The persistent JournalEntry, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated JournalEntry

updatePayment(object, callback)

Updates QuickBooks version of Payment

Arguments

  • object - The persistent Payment, including Id and SyncToken fields. To void payment set void:true in the object.
  • callback - Callback function which is called with any error and the updated Payment

updatePaymentMethod(object, callback)

Updates QuickBooks version of PaymentMethod

Arguments

  • object - The persistent PaymentMethod, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated PaymentMethod

updatePreferences(object, callback)

Updates QuickBooks version of Preferences

Arguments

  • object - The persistent Preferences, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Preferences

updatePurchase(object, callback)

Updates QuickBooks version of Purchase

Arguments

  • object - The persistent Purchase, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Purchase

updatePurchaseOrder(object, callback)

Updates QuickBooks version of PurchaseOrder

Arguments

  • object - The persistent PurchaseOrder, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated PurchaseOrder

updateRefundReceipt(object, callback)

Updates QuickBooks version of RefundReceipt

Arguments

  • object - The persistent RefundReceipt, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated RefundReceipt

updateSalesReceipt(object, callback)

Updates QuickBooks version of SalesReceipt

Arguments

  • object - The persistent SalesReceipt, including Id and SyncToken fields. To void sales receipt set void:true in the object.
  • callback - Callback function which is called with any error and the updated SalesReceipt

updateTaxAgency(object, callback)

Updates QuickBooks version of TaxAgency

Arguments

  • object - The persistent TaxAgency, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated TaxAgency

updateTaxCode(object, callback)

Updates QuickBooks version of TaxCode

Arguments

  • object - The persistent TaxCode, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated TaxCode

updateTaxRate(object, callback)

Updates QuickBooks version of TaxRate

Arguments

  • object - The persistent TaxRate, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated TaxRate

updateTerm(object, callback)

Updates QuickBooks version of Term

Arguments

  • object - The persistent Term, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Term

updateTimeActivity(object, callback)

Updates QuickBooks version of TimeActivity

Arguments

  • object - The persistent TimeActivity, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated TimeActivity

updateTransfer(object, callback)

Updates QuickBooks version of Transfer

Arguments

  • object - The persistent Transfer, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Transfer

updateVendor(object, callback)

Updates QuickBooks version of Vendor

Arguments

  • object - The persistent Vendor, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated Vendor

updateVendorCredit(object, callback)

Updates QuickBooks version of VendorCredit

Arguments

  • object - The persistent VendorCredit, including Id and SyncToken fields
  • callback - Callback function which is called with any error and the updated VendorCredit

updateExchangeRate(object, callback)

Updates QuickBooks version of ExchangeRate

Arguments

  • object - The persistent ExchangeRate
  • callback - Callback function which is called with any error and the updated ExchangeRate

deleteAttachable(idOrEntity, callback)

Deletes the Attachable from QuickBooks

Arguments

  • idOrEntity - The persistent Attachable to be deleted, or the Id of the Attachable, in which case an extra GET request will be issued to first retrieve the Attachable
  • callback - Callback function which is called with any error and the status of the persistent Attachable

deleteBill(idOrEntity, callback)

Deletes the Bill from QuickBooks

Arguments

  • idOrEntity - The persistent Bill to be deleted, or the Id of the Bill, in which case an extra GET request will be issued to first retrieve the Bill
  • callback - Callback function which is called with any error and the status of the persistent Bill

deleteBillPayment(idOrEntity, callback)

Deletes the BillPayment from QuickBooks

Arguments

  • idOrEntity - The persistent BillPayment to be deleted, or the Id of the BillPayment, in which case an extra GET request will be issued to first retrieve the BillPayment
  • callback - Callback function which is called with any error and the status of the persistent BillPayment

deleteCreditMemo(idOrEntity, callback)

Deletes the CreditMemo from QuickBooks

Arguments

  • idOrEntity - The persistent CreditMemo to be deleted, or the Id of the CreditMemo, in which case an extra GET request will be issued to first retrieve the CreditMemo
  • callback - Callback function which is called with any error and the status of the persistent CreditMemo

deleteDeposit(idOrEntity, callback)

Deletes the Deposit from QuickBooks

Arguments

  • idOrEntity - The persistent Deposit to be deleted, or the Id of the Deposit, in which case an extra GET request will be issued to first retrieve the Deposit
  • callback - Callback function which is called with any error and the status of the persistent Deposit

deleteEstimate(idOrEntity, callback)

Deletes the Estimate from QuickBooks

Arguments

  • idOrEntity - The persistent Estimate to be deleted, or the Id of the Estimate, in which case an extra GET request will be issued to first retrieve the Estimate
  • callback - Callback function which is called with any error and the status of the persistent Estimate

deleteInvoice(idOrEntity, callback)

Deletes the Invoice from QuickBooks

Arguments

  • idOrEntity - The persistent Invoice to be deleted, or the Id of the Invoice, in which case an extra GET request will be issued to first retrieve the Invoice
  • callback - Callback function which is called with any error and the status of the persistent Invoice

deleteJournalCode(idOrEntity, callback)

Deletes the JournalCode from QuickBooks

Arguments

  • idOrEntity - The persistent JournalCode to be deleted, or the Id of the JournalCode, in which case an extra GET request will be issued to first retrieve the JournalCode
  • callback - Callback function which is called with any error and the status of the persistent JournalCode

deleteJournalEntry(idOrEntity, callback)

Deletes the JournalEntry from QuickBooks

Arguments

  • idOrEntity - The persistent JournalEntry to be deleted, or the Id of the JournalEntry, in which case an extra GET request will be issued to first retrieve the JournalEntry
  • callback - Callback function which is called with any error and the status of the persistent JournalEntry

deletePayment(idOrEntity, callback)

Deletes the Payment from QuickBooks

Arguments

  • idOrEntity - The persistent Payment to be deleted, or the Id of the Payment, in which case an extra GET request will be issued to first retrieve the Payment
  • callback - Callback function which is called with any error and the status of the persistent Payment

deletePurchase(idOrEntity, callback)

Deletes the Purchase from QuickBooks

Arguments

  • idOrEntity - The persistent Purchase to be deleted, or the Id of the Purchase, in which case an extra GET request will be issued to first retrieve the Purchase
  • callback - Callback function which is called with any error and the status of the persistent Purchase

deletePurchaseOrder(idOrEntity, callback)

Deletes the PurchaseOrder from QuickBooks

Arguments

  • idOrEntity - The persistent PurchaseOrder to be deleted, or the Id of the PurchaseOrder, in which case an extra GET request will be issued to first retrieve the PurchaseOrder
  • callback - Callback function which is called with any error and the status of the persistent PurchaseOrder

deleteRefundReceipt(idOrEntity, callback)

Deletes the RefundReceipt from QuickBooks

Arguments

  • idOrEntity - The persistent RefundReceipt to be deleted, or the Id of the RefundReceipt, in which case an extra GET request will be issued to first retrieve the RefundReceipt
  • callback - Callback function which is called with any error and the status of the persistent RefundReceipt

deleteSalesReceipt(idOrEntity, callback)

Deletes the SalesReceipt from QuickBooks

Arguments

  • idOrEntity - The persistent SalesReceipt to be deleted, or the Id of the SalesReceipt, in which case an extra GET request will be issued to first retrieve the SalesReceipt
  • callback - Callback function which is called with any error and the status of the persistent SalesReceipt

deleteTimeActivity(idOrEntity, callback)

Deletes the TimeActivity from QuickBooks

Arguments

  • idOrEntity - The persistent TimeActivity to be deleted, or the Id of the TimeActivity, in which case an extra GET request will be issued to first retrieve the TimeActivity
  • callback - Callback function which is called with any error and the status of the persistent TimeActivity

deleteTransfer(idOrEntity, callback)

Deletes the Transfer from QuickBooks

Arguments

  • idOrEntity - The persistent Transfer to be deleted, or the Id of the Transfer, in which case an extra GET request will be issued to first retrieve the Transfer
  • callback - Callback function which is called with any error and the status of the persistent Transfer

deleteVendorCredit(idOrEntity, callback)

Deletes the VendorCredit from QuickBooks

Arguments

  • idOrEntity - The persistent VendorCredit to be deleted, or the Id of the VendorCredit, in which case an extra GET request will be issued to first retrieve the VendorCredit
  • callback - Callback function which is called with any error and the status of the persistent VendorCredit

findAccounts(criteria, callback)

Finds all Accounts in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Accounts

findAttachables(criteria, callback)

Finds all Attachables in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Attachables

findBills(criteria, callback)

Finds all Bills in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Bills

findBillPayments(criteria, callback)

Finds all BillPayments in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of BillPayments

findBudgets(criteria, callback)

Finds all Budgets in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Budgets

findClasses(criteria, callback)

Finds all Classs in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Classes

findCompanyInfos(criteria, callback)

Finds all CompanyInfos in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of CompanyInfos

findCreditMemos(criteria, callback)

Finds all CreditMemos in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of CreditMemos

findCustomers(criteria, callback)

Finds all Customers in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Customers

findDepartments(criteria, callback)

Finds all Departments in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Departments

findDeposits(criteria, callback)

Finds all Deposits in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Deposits

findEmployees(criteria, callback)

Finds all Employees in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Employees

findEstimates(criteria, callback)

Finds all Estimates in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Estimates

findInvoices(criteria, callback)

Finds all Invoices in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Invoices

findItems(criteria, callback)

Finds all Items in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Items

findJournalCodes(criteria, callback)

Finds all JournalCodes in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of JournalCodes

findJournalEntries(criteria, callback)

Finds all JournalEntrys in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of JournalEntries

findPayments(criteria, callback)

Finds all Payments in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Payments

findPaymentMethods(criteria, callback)

Finds all PaymentMethods in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of PaymentMethods

findPreferenceses(criteria, callback)

Finds all Preferencess in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Preferences

findPurchases(criteria, callback)

Finds all Purchases in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Purchases

findPurchaseOrders(criteria, callback)

Finds all PurchaseOrders in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of PurchaseOrders

findRefundReceipts(criteria, callback)

Finds all RefundReceipts in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of RefundReceipts

findSalesReceipts(criteria, callback)

Finds all SalesReceipts in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of SalesReceipts

findTaxAgencies(criteria, callback)

Finds all TaxAgencys in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of TaxAgencies

findTaxCodes(criteria, callback)

Finds all TaxCodes in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of TaxCodes

findTaxRates(criteria, callback)

Finds all TaxRates in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of TaxRates

findTerms(criteria, callback)

Finds all Terms in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Terms

findTimeActivities(criteria, callback)

Finds all TimeActivitys in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of TimeActivities

findVendors(criteria, callback)

Finds all Vendors in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of Vendors

findVendorCredits(criteria, callback)

Finds all VendorCredits in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of VendorCredits

findExchangeRates(criteria, callback)

Finds all ExchangeRates in QuickBooks, optionally matching the specified criteria

Arguments

  • criteria - (Optional) String or single-valued map converted to a where clause of the form "where key = 'value'"
  • callback - Callback function which is called with any error and the list of ExchangeRates

reportBalanceSheet(options, callback)

Retrieves the BalanceSheet Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the BalanceSheet Report

reportProfitAndLoss(options, callback)

Retrieves the ProfitAndLoss Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the ProfitAndLoss Report

reportProfitAndLossDetail(options, callback)

Retrieves the ProfitAndLossDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the ProfitAndLossDetail Report

reportTrialBalance(options, callback)

Retrieves the TrialBalance Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the TrialBalance Report

reportCashFlow(options, callback)

Retrieves the CashFlow Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the CashFlow Report

reportInventoryValuationSummary(options, callback)

Retrieves the InventoryValuationSummary Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the InventoryValuationSummary Report

reportCustomerSales(options, callback)

Retrieves the CustomerSales Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the CustomerSales Report

reportItemSales(options, callback)

Retrieves the ItemSales Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the ItemSales Report

reportCustomerIncome(options, callback)

Retrieves the CustomerIncome Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the CustomerIncome Report

reportCustomerBalance(options, callback)

Retrieves the CustomerBalance Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the CustomerBalance Report

reportCustomerBalanceDetail(options, callback)

Retrieves the CustomerBalanceDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the CustomerBalanceDetail Report

reportAgedReceivables(options, callback)

Retrieves the AgedReceivables Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the AgedReceivables Report

reportAgedReceivableDetail(options, callback)

Retrieves the AgedReceivableDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the AgedReceivableDetail Report

reportVendorBalance(options, callback)

Retrieves the VendorBalance Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the VendorBalance Report

reportVendorBalanceDetail(options, callback)

Retrieves the VendorBalanceDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the VendorBalanceDetail Report

reportAgedPayables(options, callback)

Retrieves the AgedPayables Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the AgedPayables Report

reportAgedPayableDetail(options, callback)

Retrieves the AgedPayableDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the AgedPayableDetail Report

reportVendorExpenses(options, callback)

Retrieves the VendorExpenses Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the VendorExpenses Report

reportTransactionList(options, callback)

Retrieves the TransactionList Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the TransactionList Report

reportGeneralLedgerDetail(options, callback)

Retrieves the GeneralLedgerDetail Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the GeneralLedgerDetail Report

reportDepartmentSales(options, callback)

Retrieves the DepartmentSales Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the DepartmentSales Report

reportClassSales(options, callback)

Retrieves the ClassSales Report from QuickBooks

Arguments

  • options - (Optional) Map of key-value pairs passed as options to the Report
  • callback - Callback function which is called with any error and the ClassSales Report

getInvoicePdf(id, callback)

Retrieves the Invoice PDF from QuickBooks

Arguments

  • id - The Id of persistent Invoice
  • callback - Callback function which is called with any error and the Invoice PDF

getCreditMemoPdf(id, callback)

Retrieves the Credit Memo PDF from QuickBooks

Arguments

  • id - The Id of persistent Credit Memo
  • callback - Callback function which is called with any error and the Credit Memo PDF

getSalesReceiptPdf(id, callback)

Retrieves the SalesReceipt PDF from QuickBooks

Arguments

  • id - The Id of persistent SalesReceipt
  • callback - Callback function which is called with any error and the persistent SalesReceipt PDF

sendInvoicePdf(id, sendTo, callback)

Emails the Invoice PDF from QuickBooks to the address supplied in Invoice.BillEmail.EmailAddress or the specified 'sendTo' address

Arguments

  • Id - The Id of persistent Invoice
  • sendTo - (Optional) optional email address to send the PDF to. If not provided, address supplied in Invoice.BillEmail.EmailAddress will be used
  • callback - Callback function which is called with any error and the Invoice PDF

sendCreditMemoPdf(id, sendTo, callback)

Emails the Credit Memo PDF from QuickBooks to the address supplied in CreditMemo.BillEmail.EmailAddress or the specified 'sendTo' address

Arguments

  • Id - The Id of persistent Credit Memo
  • sendTo - (Optional) optional email address to send the PDF to. If not provided, address supplied in Credit Memo.BillEmail.EmailAddress will be used
  • callback - Callback function which is called with any error and the Credit Memo PDF

sendEstimatePdf(id, sendTo, callback)

Emails the Estimate PDF from QuickBooks to the address supplied in Estimate.BillEmail.EmailAddress or the specified 'sendTo' address

Arguments

  • Id - The Id of persistent Estimate
  • sendTo - (Optional) optional email address to send the PDF to. If not provided, address supplied in Estimate.BillEmail.EmailAddress will be used
  • callback - Callback function which is called with any error and the Estimate PDF

sendSalesReceiptPdf(id, sendTo, callback)

Emails the SalesReceipt PDF from QuickBooks to the address supplied in SalesReceipt.BillEmail.EmailAddress or the specified 'sendTo' address

Arguments

  • Id - The Id of persistent SalesReceipt
  • sendTo - (Optional) optional email address to send the PDF to. If not provided, address supplied in SalesReceipt.BillEmail.EmailAddress will be used
  • callback - Callback function which is called with any error and the SalesReceipt PDF

sendPurchaseOrder(id, sendTo, callback)

Emails the Purchase Order from QuickBooks to the address supplied in PurchaseOrder.POEmail.Address or the specified 'sendTo' address

Arguments

  • Id - The Id of persistent Purchase Order
  • sendTo - (Optional) optional email address to send the email to. If not provided, address supplied in PurchaseOrder.POEmail.Address will be used
  • callback - Callback function which is called with any error and the PurchaseOrder PDF

batch(items, callback)

Batch operation to enable an application to perform multiple operations in a single request. The following batch items are supported:

  • create
  • update
  • delete
  • query
  • The maximum number of batch items in a single request is 30.

Arguments

  • items - JavaScript array of batch items
  • callback - Callback function which is called with any error and list of BatchItemResponses

changeDataCapture(entities, since, callback)

The change data capture (CDC) operation returns a list of entities that have changed since a specified time.

Arguments

  • entities - Comma separated list or JavaScript array of entities to search for changes
  • since - JavaScript Date or string representation of the form '2012-07-20T22:25:51-07:00' to look back for changes until
  • callback - Callback function which is called with any error and list of changes

upload(filename, contentType, stream, entityType, entityId, callback)

Uploads a file as an Attachable in QBO, optionally linking it to the specified QBO Entity.

Arguments

  • filename - the name of the file
  • contentType - the mime type of the file
  • stream - ReadableStream of file contents
  • entityType - optional string name of the QBO entity the Attachable will be linked to (e.g. Invoice)
  • entityId - optional Id of the QBO entity the Attachable will be linked to
  • callback - callback which receives the newly created Attachable

node-quickbooks's People

Contributors

ahmedk743 avatar amirovphilip avatar amitshahani avatar brendannee avatar dependabot[bot] avatar dhritzkiv avatar dimitry avatar drabinowitz avatar fiveladdercon avatar jponc avatar kevintowe avatar ljorgensen avatar macojaune avatar martinjbaker avatar mcohen01 avatar owlfloater898 avatar peterfaria-lula avatar pfullen avatar przemeq84 avatar rimvydas-urbonas avatar samox avatar shriharimohan avatar simonasdev avatar smclaughry avatar sparber avatar tristansokol avatar tszpinda avatar vayvala avatar viilveer avatar yasharf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-quickbooks's Issues

Getting error on QuickBooks charge method

Hi,
I'm trying to create a charge using QuickBooks charge method, but I always get this object error.
Using this request charge object:

charge =
{
amount: "25"
currency: "USD"
token: "jX1J4n+No16w9AXbUSSfXfWn/RA="
}

error =
{
arguments: undefined
code: "ENOTFOUND"
errno: "ENOTFOUND"
message: "getaddrinfo ENOTFOUND"
stack: undefined
syscall: "getaddrinfo"
type: undefined
}

Do you have any idea what is happened.

TaxService

The endpoint for createTaxService and updateTaxService is incorrect. Should be taxService/taxCode.

Can not get invoices with zero balance

{ request:
   { uri: 'https://quickbooks.api.intuit.com/v3/company/revoked/query?query=select%20%2A%20from%20invoice%20where%20Balance%20%3D%200%20startposition%201%20maxresults%201000&minorversion=4',
     method: 'GET',
     headers:
      { 'User-Agent': 'node-quickbooks: version 2.0.4',
        'Request-Id': '514dd100-d055-11e5-947c-9ff50fd6eb15',
        host: 'quickbooks.api.intuit.com',
        accept: 'application/json',
        Authorization: 'OAuth oauth_consumer_key="revoked",oauth_nonce="revoked",oauth_signature_method="HMAC-SHA1",oauth_timestamp="revoked",oauth_token="revoked",oauth_version="1.0",oauth_signature="revoked%3D"' } } }
{ response:
   { headers:
      { server: 'nginx/1.8.0',
        date: 'Thu, 11 Feb 2016 00:20:56 GMT',
        'content-type': 'application/json;charset=UTF-8',
        'transfer-encoding': 'chunked',
        connection: 'close',
        'strict-transport-security': 'max-age=15552000',
        intuit_tid: 'gw-b88c2c09-9b87-4e17-8ba9-b5ccf1afe77f',
        'qbo-version': '1601.525',
        'cache-control': 'max-age=0, no-cache, no-store, must-revalidate, private',
        expires: '0',
        vary: 'Accept-Encoding',
        via: '1.1 ipp-gateway-ap05' },
     statusCode: 200,
     body: { Fault: [Object], time: '2016-02-10T16:20:56.658-08:00' } } }
invoking endpoint: https://quickbooks.api.intuit.com/v3/company/revoked/query?query=select * from invoice where Balance %3D 0 startposition 1 maxresults 1000

{ Fault:
   { Error:
      [ { Message: 'Error parsing query',
          Detail: 'QueryParserError: Encountered " <INTEGER> "0 "" at line 1, column 39.\nWas expecting one of:\n    "false" ...\n    "true" ...\n    ',
          code: '4000' } ],
     type: 'ValidationFault' },
  time: '2016-02-10T16:20:56.658-08:00' }
{ '0':
   { Fault:
      { Error:
         [ { Message: 'Error parsing query',
             Detail: 'QueryParserError: Encountered " <INTEGER> "0 "" at line 1, column 39.\nWas expecting one of:\n    "false" ...\n    "true" ...\n    ',
             code: '4000' } ],
        type: 'ValidationFault' },
     time: '2016-02-10T16:20:56.658-08:00' },
  '1':
   { Fault:
      { Error:
         [ { Message: 'Error parsing query',
             Detail: 'QueryParserError: Encountered " <INTEGER> "0 "" at line 1, column 39.\nWas expecting one of:\n    "false" ...\n    "true" ...\n    ',
             code: '4000' } ],
        type: 'ValidationFault' },
     time: '2016-02-10T16:20:56.658-08:00' } }

qbo.findInvoices([{
        'field': 'Balance',
        'value': 0,
        'operator': '='
    }]

Use of "fetchAll" is breaking other query parameters.

When I initially wrote my code I did not use "fetchAll". There is the possibility that our requests could exceed the limit of 1000 records. So I would like to make use of the โ€œfetchAllโ€ parameter.

Before making changes to use โ€œfetchAllโ€, here is a snippet of our code used to get a Trial Balance report:

// Put the dates in the required format YYYY-MM-DD.
newStart = newStart.format('YYYY-MM-DD');
newEnd   = newEnd.format('YYYY-MM-DD');

// Get the trial balance for the required time period.
var query = {
    start_date: newStart,
    end_date:  newEnd
};
qbo.reportTrialBalance(query, function(err, theTrialBalance) {
    .
    .
    .
});

The above code is working and retrieves the trial balance report for the specified time period.

Iโ€™m not sure how the โ€œfetchAllโ€ parameter should be added. Weโ€™ve tried the following ways of creating the query object, but they have not worked:

var query = [
   {field: โ€˜fetchAllโ€™, value: true},
   {field: โ€˜start_dateโ€™, value: newStart},
   {field: โ€˜end_dateโ€™, value: newEnd}
];

var query = [
   {fetchAll: true},
   {start_date: newStart},
   {end_date: newEnd}
];

var query = [
   {field: โ€˜fetchAllโ€™, value: true},
   {โ€˜start_dateโ€™: newStart},
   {โ€˜end_dateโ€™: newEnd}
];

In each case, a trial balance is returned. But the data returned is for โ€˜this month-to-dateโ€™ and not for the date range specified by โ€˜start_dateโ€™ and โ€˜end_dateโ€™. Also wanting to use "fetchAll" with the following and experiencing similar issues:

  • qbo.reportBalanceSheet()
  • qbo.findAccounts()
  • qbo.reportProfitAndLoss()
  • qbo.reportGeneralLedgerDetail()
  • qbo.reportBalanceSheet()

Can you tell me the correct way to use โ€œfetchAllโ€ together with being able to set the start and end dates?

Query API by date range

Hi there,

The underlying QB API appears to support query by date ranges, but the node library doesn't (or at least I don't think so) support this. What do you think the right way to extend the node library to do this?

thanks,
andy

Business validation error on every request

var QuickBooks = require('node-quickbooks');

var QBO = new QuickBooks(
   config.quickbooks.consumerKey, 
   config.quickbooks.consumerSecret, 
   config.quickbooks.accessToken, 
   config.quickbooks.accessTokenSecret, 
   false, 
   true);

QBO.findCustomers({}, function(err, res) { if (err) { console.log(err.Fault.Error[0]) } });

 { Message: 'A business validation error has occurred while processing your request',
  Detail: 'Business Validation Error: Unexpected Internal Error. (-30000)',
  code: '6000',
  element: '' }

QBO.findInvoices({}, function(err, res) { if (err) { console.log(err.Fault.Error[0]) } });

 { Message: 'A business validation error has occurred while processing your request',
  Detail: 'Business Validation Error: Unexpected Internal Error. (-30000)',
  code: '6000',
  element: '' }

Do you know what may be the cause of this ?

oauth_problem: 'signature_invalid'

Hi, thank for putting this library together. I think I've followed the getting started instructions, gotten the secret and key entered correctly, but am getting this signature invalid error. Can you see where I might have gone wrong?

"statusCode": 401,
"body": "oauth_problem=signature_invalid",
"headers": {
    "date": "Tue, 05 Apr 2016 17:27:54 GMT",
    "server": "Apache",
    "www-authenticate": "OAuth oauth_problem=\"signature_invalid\"",
    "cache-control": "no-cache, no-store",
    "pragma": "no-cache",
    "content-length": "31",
    "connection": "close",
    "content-type": "text/plain",
    "x-pad": "avoid browser bug"
},
"request": {
    "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "oauth.intuit.com",
        "port": 443,
        "hostname": "oauth.intuit.com",
        "hash": null,
        "search": null,
        "query": null,
        "pathname": "/oauth/v1/get_request_token",
        "path": "/oauth/v1/get_request_token",
        "href": "https://oauth.intuit.com/oauth/v1/get_request_token"
    },
    "method": "POST",
    "headers": {
        "Authorization": "OAuth oauth_callback=\"http%3A%2F%2Flocalhost%3A3000%2Fcallback%2F\",oauth_consumer_key=\"qyprdowSUdCZUHEuLT7ferE56I940i\",oauth_nonce=\"9cb04e59470c4d84b853aadebfbf1052\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"1459877274\",oauth_version=\"1.0\",oauth_signature=\"tOqGLEMnqo3h0vLWiGWAucHbJYg%3D\"",
        "content-length": 0
    }
}

`
https://developer.intuit.com/hub/blog/2015/02/19/oauth-for-intuit-demystified
http://oauthbible.com/
http://stackoverflow.com/questions/19358388/how-properly-create-oauth-signature-base-string

endpoint query parameter : minor version

First, many thanks for the library!
I use qbo in France. There are some specific attributes accessible when requesting API with minorversion parameter (ex APAccountRef in Vendor object).
Ref: https://developer.intuit.com/docs/0100_Accounting/0300_Developer_Guides/Minor_versions

It could be useful to add this parameter to the Quickbooks object init function... because for now I don't know how to do this : )

Sorry for my bad english. As I said I'm French : ))

Can't connect to both Sandbox and Live Endpoints

It's not possible to build an app that can connect to the Sandbox and the Production endpoints. You can only do one or other. This is becuase all instances share the same endpoint variables.

I took a look at fixing this but it doesn't look like the request that gets made doesn't know much about the instance other then the props for authentication. I didn't see an easy way to make it work.

If you have time to point me in the right direction I'll see if I can figure it out.

Amount on debits not equal to credits

This is more of a general accounting question so I highly apologize if this is the wrong place to ask it. I just can't think of a better support forum at the moment.

Can somebody please check this logic?

Goods on hand should debit the Inventory account.
Sales could credit the Sales account.
Purchases should credit the Purchases account.
Cost of good sold should debit the Supplies account.

I don't understand how the system (and I'm aware this is accounting 101, so I'm absolutely missing something trivial here) is expecting everything to be zero sum here.

Why would purchasing ever be equal to sales?

Any advice is highly appreciated!

Get Invoice PDF Without Buffering

I think I know the answer - but just wanted to check.

Is there any way to get an invoice PDF without buffering it into memory? Ideally I'd like to stream it to the client if possible.

It looks like getInvoicePdf uses request to buffer the entire response in memory before calling back.

"Expense Accounts by AccountType" test fails with too many Accounts

It looks like line the Account.length check in test/index.js will currently fail with too many accounts, i.e.:

it('should fetch Expense Accounts by AccountType', function (done) {
     qbo.findAccounts({AccountType: 'Expense'}, function(err, accounts) {
      expect(err).toBe(null)
      expect(accounts.Fault).toBe(undefined)
      expect(accounts.QueryResponse.Account.length).toBeLessThan(40)
       expect(accounts.QueryResponse.Account[0].AccountType).toBe('Expense')
       done()
     })
   })
$ npm test
 2) Query should fetch Expense Accounts by AccountType:
     Uncaught AssertionError: 44 is not less than 40

This is what I'm getting back as a response using the Sample Company provided at the intuit developer site:

0: Advertising
1: Automobile
2: Fuel
3: Bank Charges
4: Commissions & fees
5: Disposal Fees
6: Dues & Subscriptions
7: Equipment Rental
8: Insurance
9: Workers Compensation
10: Job Expenses
11: Cost of Labor
12: Installation
13: Maintenance and Repairs
14: Equipment Rental
15: Job Materials
16: Decks and Patios
17: Fountain and Garden Lighting
18: Plants and Soil
19: Sprinklers and Drip Systems
20: Permits
21: Legal & Professional Fees
22: Accounting
23: Bookkeeper
24: Lawyer
25: Maintenance and Repair
26: Building Repairs
27: Computer Repairs
28: Equipment Repairs
29: Meals and Entertainment
30: Office Expenses
31: Promotional
32: Purchases
33: Rent or Lease
34: Stationery & Printing
35: Supplies
36: Taxes & Licenses
37: Travel
38: Travel Meals
39: Unapplied Cash Bill Payment Expense
40: Uncategorized Expense
41: Utilities
42: Gas and Electric
43: Telephone

Do you know if that's an unexpected result or if perhaps the test should be updated? Thanks in advance.

Queries need an extra space

When I tried to do a query to search the vendors, it wouldn't work unless I added a leading space to my query.

My original code:

    qbo.findVendors("where GivenName = 'Alison'",function(err,vendors){
                console.log(vendors);
                return res.view('quickbooks/unauthorized',{vendors:vendors})
            })

Sent this request:
query=select * from vendorwhere GivenName %3D %27Alison%27

I had to add a space to be beginning of my query to get it to work: " where GivenName = 'Alison'"

Throws "must contain Id and SyncToken fields" even when both are present.

When trying to update a Vendor, I get the message:

Error: vendor must contain Id and SyncToken fields: { Id: 505, SyncToken: 1, sparse: true, TaxIdentifier: '123456789' }

I tracked this down to module.update() in the index.js file.

_.isEmpty(entity.SyncToken) returns true when you pass through a string or an integer of one digit.

According to the lodash docs: "Array-like values such as arguments objects, arrays, buffers, strings, or jQuery-like collections are considered empty if they have a length of 0. Similarly, maps and sets are considered empty if they have a size of 0."
_.isEmpty(1); // โ†’ true

It works fine if I remove the two _.isEmpty tests, and I'd be happy to submit a pull request to remove them, but I'm sure that you have a reason for them, or an alternate way to submit the SyncToken that would work. Your example code uses SyncToken: 1

Queries on Boolean fields don't work

The following does not work:

qbo.findCustomer({ Active : true, limit : 1000})

or

qbo.findCustomer([
   { field : 'Active', value : true, operator : '=' }, 
   { field : 'limit', value : 1000 }])

Both cases result in the following error:

{ Fault:
{ Error:
[ { Message: 'An application error has occurred while processing your request',
Detail: 'System Failure Error: java.lang.String cannot be cast to java.lang.Boolean',
code: '10000' } ],
type: 'SystemFault' },
time: '2016-01-15T11:02:23.728-08:00' }

Examining the generated url it is clear to see that the issue is that true is being quoted.

https://sandbox-quickbooks.api.intuit.com/v3/company/123145670668917/query?query=select * from customer where Active = 'true' startposition 1 maxresults 1000&minorversion=4

Unable to Reuse accessToken.oauth_token & accessToken.oauth_token_secret

Hey there,

So I'm using the example app to capture my oauth_token and oauth_token_secret, however I seem to be unable to save those Strings elsewhere and reuse them reauthenticate.

For instance in the example app:

request.post(postBody, function (e, r, data) {
    var accessToken = qs.parse(data)

    // save the access token somewhere on behalf of the logged in user
    qbo = new QuickBooks(consumerKey,
                         consumerSecret,
                         accessToken.oauth_token,
                         accessToken.oauth_token_secret,
                         postBody.oauth.realmId,
                         true, // use the Sandbox
                         true); // turn debugging on

    qbo.endpoint = 'https://sandbox-quickbooks.api.intuit.com/v3/company/';
    qbo.paymentEndpoint = 'https://sandbox.api.intuit.com/quickbooks/v4/payments';

    console.log('=====================================');
    console.log('Consumer Key: ' +consumerKey+
                '\nConsumer Secret: ' +consumerSecret+
                '\nOauth Token: ' +accessToken.oauth_token+
                '\nOauth Secret: ' +accessToken.oauth_token_secret+
                '\nRealm ID: ' +postBody.oauth.realmId);
    console.log('=====================================');

    console.log(qbo);

The above connects successfully, and prints out the accounts listing as expected. However storing the above logged variables and trying to recreate the Quickbooks object results in status code 401 with error code 3200 being displayed for authentication.

Snippet below:

// Quickbooks Object
var qboa = new QuickbooksAccounting(config.consumerKeys[env],
                         config.consumerSecrets[env],
                         config.oauthTokens[env],
                         config.oauthSecrets[env],
                         config.realmIds[env],
                         true,
                         true);

Is this expected behavior? Am I unable to recreate the Quickbooks object after initially creating it in the example app?

SyncToken 0 error

First, thanks for the great work on this!
In the README provided, SyncToken on an Update is defined as an integer.
However, if the SyncToken should be 0, I'm getting the following error when defining 0 as an Int:

/home/shizy/dev/nhubackend/node_modules/node-quickbooks/index.js:1794
    throw new Error(entityName + ' must contain Id and SyncToken fields: ' +
    ^

Error: customer must contain Id and SyncToken fields: { Id: 5882,
  SyncToken: 0,
  sparse: true,
  PreferredDeliveryMethod: 'Email' }
    at Module.module.update (/home/shizy/dev/nhubackend/node_modules/node-quickbooks/index.js:1794:11)
    at QuickBooks.updateCustomer (/home/shizy/dev/nhubackend/node_modules/node-quickbooks/index.js:869:10)
    at /home/shizy/dev/nhudeposits/index.js:6:12
    at Request._callback (/home/shizy/dev/nhubackend/index.js:44:20)
    at Request.self.callback (/home/shizy/dev/nhubackend/node_modules/request/request.js:198:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/home/shizy/dev/nhubackend/node_modules/request/request.js:1082:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)

When changing the SyncToken to "0" (string), the update is sucessful. I can only guess that 0 (int) is being interpreted as false during a SyncToken check?

getPreferences documentation

In order to request preferences on a given company, you need to submit a blank object ("") instead of the company/realm ID, as the realm ID is already submitted in the API call. It is not obvious per the docs on how to modify the method call appropriately. You might want to update your docs (or add an example):

getPreferences(id, callback)

Retrieves the Preferences from QuickBooks

Arguments
id - The Id of persistent Preferences // Add "" here
callback - Callback function which is called with any error and the persistent Preferences

OAuth 2.0 support

Hi.

Does this node-quickbooks package support OAuth 2.0? I am newly using the QuickBooks API and have only recently set up my QB developer account after the July 17, 2017 cutoff, which means I have no choice but to use OAuth 2.0.

Here's the original information from the QuickBooks API Docs:

If your developer account has created apps before July 17, 2017, any apps created by that account, including future apps and apps under development now, will use OAuth 1.0a. There is no requirement to migrate OAuth 1.0a apps to OAuth 2.0. 

If your developer account has not created any apps until after July 17, 2017, all apps created by that account will use OAuth 2.0. 

Intuit Developer Group are working on providing a path to migrate OAuth 1.0a keys from OAuth 1.0a to OAuth 2.0, and to enable all developer accounts to create new apps that use OAuth 2.0. We will notify the community once this path is ready.

The information below helps you to identify which OAuth stack your apps are using.

Void a SalesReceipt

Is voiding a Sales Receipt currently possible?

In the docs, voiding a sales receipt is achieved by sending an update request, with include=void as part of the query string (weird, seeing as how the request is a POST request with a body, but whatever).

I attempted to pass in include = "void" in the request body, but that isn't allowed.

Example for creating a File Attachable?

Hey devs,

I've successfully created a few invoices with node-quickbooks and now would like to upload some associated PDFs to each invoice. I believe that the createAttachable method is what I need to use, but I'm not quite sure how to include my PDF file into the payload.

It looks like it's definitely possible with the base Intuit API, but I'm not quite sure how to do it with node-quickbooks.

Metta,
J

Using like operator for queries has issues

In order to use like with % such as '%prepaid inventory' I have had to pass it as '%25prepaid inventory' and on line 1925 of index.js I've had to comment out:
url.replace(/%/g, '%25')

this section only changes the first occurrence anyway, so it is ineffective at replacing all characters.

I am using the like operator as follows:

accountsQuery = '%25Prepaid Inventory'
qbo.findAccounts([{field: 'Name', value: accountsQuery, operator: 'LIKE'}], function(err, account)

Not able to authenticate from saved credentials

I am able to access the API just fine during the initial authentication, but after I save the tokens in my database and try to access the API directly without going through the authentication I always get a 401 error code 3200.

Here is my code:

qbo = new QB(
            consumerKey,
            consumerSecret,
            results[0].oauth_token,
            results[0].oauth_token_secret,
            results[0].realmId,
            false,//sandbox
            true);//debugging

        qbo.findVendors(" where GivenName = 'Alison'",function(err,vendors){
            if(err){
            console.log(err);
        }
            console.log(vendors);
            return res.view('quickbooks/manage',{vendors:vendors})
        })

Credit card authorization charge error

HI,
i used below code to receive token
var chargedn = { "card": { "expYear": "2017", "expMonth": "03", "address": { "region": "NJ", "postalCode": "07079", "streetAddress": "350 Mountain View Dr.", "country": "US", "city": "South Orange" }, "name": "Pye's Cakes", "cvc": "123", "number": "4111111111111111" } } qbo.cardToken(chargedn, function(err, cardToken) { token = cardToken.value console.log(token); console.log(err); });

Next step i used below code to authorize the token
qbo.charge({ "amount": "80.00", "currency": "USD", "capture": "false", "token": "Xq83uiLpMtTPjXjDM/XO7jlsYPs=", }, function(err, cardToken) { console.log(cardToken); console.log(err); });
Its throwing 401 error with response body as undefined. I tried by adding and removing authorization on header still i am getting the same 401 error.

Property Name:Can not construct instance of java.m specified is unsupported or invalid

var item = { Name: 'FOO',
  Sku: 10,
  UnitPrice: 1,
  PurchaseCost: 0.5,
  Type: 'Inventory',
  TrackQtyOnHand: true,
  QtyOnHand: 'Sku',
  InvStartDate: '2016-01-30',
  IncomeAccountRef: { name: 'Sales', value: '1' },
  ExpenseAccountRef: { name: 'Supplies', value: '21' },
  AssetAccountRef: { name: 'Uncategorized Asset', value: '53' } };

var deferred = Q.defer();

var qbo = new QuickBooks(global['quickbooks_key'],
                         global['quickbooks_secret'],
                         token,
                         token_secret,
                         realm_id,
                         false, // don't use the sandbox (i.e. for testing)
                         true); // turn debugging on

qbo.createItem(item, function (err, res) {
    if (err) {
        return deferred.reject(new Error(JSON.stringify(err)));
    }

    deferred.resolve(res);
});

return deferred.promise;
{ request:
   { uri: 'https://quickbooks.api.intuit.com/v3/company/redacted/item?minorversion=4',
     method: 'POST',
     headers:
      { 'User-Agent': 'node-quickbooks: version 2.0.3',
        host: 'quickbooks.api.intuit.com',
        accept: 'application/json',
        'content-type': 'application/json',
        'content-length': 306,
        Authorization: 'OAuth oauth_consumer_key="redacted",oauth_nonce="redacted",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1454182385",oauth_token="redacted",oauth_version="1.0",oauth_signature="redacted"' },
     body: '{"Name":"FOO","Sku":10,"UnitPrice":1,"PurchaseCost":0.5,"Type":"Inventory","TrackQtyOnHand":true,"QtyOnHand":"Sku","InvStartDate":"2016-01-30","IncomeAccountRef":{"name":"Sales","value":"1"},"ExpenseAccountRef":{"name":"Supplies","value":"21"},"AssetAccountRef":{"name":"Uncategorized Asset","value":"53"}}' } }

Using "count" in an array or passing in a string doesn't work for me

I'm a junior developer, so forgive me if this is something I'm doing wrong, or not understanding about the api.

I've been trying to create a function that will get me a count of records with a where clause. I've tried to do this via an array with "count" as the first object in the array, and I've tried to pass in a string query. The string query fails on me (maybe I misunderstood the api and I can't pass strings like I've done in my example code below?). The array query works, but it doesn't return a count - instead it does a SELECT * with my WHERE clause and I get back all of the expenses. Here's my code:

function getExpenseCountFor( range, quickBooksObject ) {
            let query = [
                {
                    count : true
                },
                {
                    field    : 'TxnDate', //transaction date
                    value    : range.start_date, //start date
                    operator : '>='
                },
                {
                    field    : 'TxnDate',
                    value    : range.end_date,
                    operator : '<='
                }
            ];
            let queryString = 'SELECT COUNT(*) FROM Purchase WHERE TxnDate > \'2015-10-01\' AND TxnDate <= CURRENT_DATE';

            return new Promise(function( resolve, reject ) {
                quickBooksObject.findPurchases(query, ( error, expenseCount ) => {
                    if ( error ) {
                        reject(error);
                    }
                    resolve(expenseCount);
                });
            });
        }

Any recommendations or guidance if I'm doing something wrong?

A callback is sometimes not called with an Error.

A callback in the form of callback(err, results) should be called with an Error when being rejected.

For example, if a business logic fault occurs, the callback is returned with the error being set to the response body. The response body is not an Error, and has no stack trace. This makes it harder to track down business logic errors than it needs to be.

A possible solution might be to replace the module.request function return code, on line 1985, with

    if (callback) {
      if (err ||
          res.statusCode >= 300 ||
          (_.isObject(body) && body.Fault && body.Fault.Error && body.Fault.Error.length) ||
          (_.isString(body) && !_.isEmpty(body) && body.indexOf('<') === 0)) {
        var reportedError = err || body;
        if (!(reportedError instanceof Error) && body.Fault && body.Fault.Error && body.Fault.Error.length) {
          reportedError = new Error(body.Fault.Error.map(e=>`${e.code} ${e.element?`on ${e.element}: `:''}${e.Message} (${e.Detail})`).join())
          reportedError.name = body.Fault.type;
        }
        callback(reportedError, body)
      } else {
        callback(null, body)
      }

as I've done here. DDR0@d355513

I have not submitted a pull request because I don't feel my addition is up to snuff, code-quality-wise. For instance, template strings are not used anywhere else in the code, nor are arrow functions. However, I do feel the issue warranted a remark.

Thank you.

Filtering Items By Type

I've tried everything I can think of but when I try to query Items by Type node keeps crashing. The filter object is contained in the following snippet:
qbo.findItems([{field:'Active',value : true},{field:'fetchAll',value : true}, {field : 'Type',value:'Service'}],function(_, items) { items.QueryResponse.Item.forEach(function(item) { //console.log(customer.Name) })
The Intuit Docs indicate that Items are filterable by Type and I make other filtered queries (e.g. Account by AccountType) that work fine. My assumption is that this is pilot error but just in case I thought I'd post; if it's NOT me then fine, otherwise perhaps someone can offer an idea of what I'm doing wrong.

Thanks.

Query based on nested properties

How can I query nested properties in an object? For example, I want to find:

          qbo.findItems({
            Name: name,
            ParentRef: {
              value: categoryId
            },
          }, callback);

Re-creating transactions

I was able to delete sales receipts using the method. But I found that I am not able to re-create those sales receipts.

I wasn't able to accomplish that through established Quickbooks integrations either. Both Shopify-to-QB sync and Paypal-to-QB sync apps provided by those respective platforms are not able to re-create deleted sales receipts.

Is this something that is not possible to do?

XML response for authentication Failed.

Hello,

First thanks a lot for a great module. It is working great for most of my use cases.

However I have one issue where when a user token expires and Quickbooks responds with an authorization failed. The module passes back XML error code instead of JSON like the rest of the module.

I am not sure if I have missed a configuration setting or something.

Strange that only the authorization failed returns xml and everything else returns JSON.

Error:



message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401
SignatureBaseString: GET&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F$$$%2Fquery&minorversion%3D4%26oauth_consumer_key%xxx%26oauth_nonce%xxx%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1463420599%26oauth_token%3xxx%26oauth_version%3D1.0%26query%3Dselect%2520%252A%2520from%2520invoice%2520orderby%2520Balance%2520desc%2520startposition%25201%2520maxresults%25203


Querying with single quotes throws error

qbo.findVendors({
    DisplayName: 'Cutlery \'R Us'
}, function (err, res) { ... });
[ { Message: 'Error parsing query',
    Detail: 'QueryParserError: Encountered " <IDENTIFIER> "R "" at line 1, column 52.\nWas expecting one of:\n    <EOF> \n    <AND> ...\n    "iterator" ...\n    "maxresults" ...\n    <OR> ...\n    "order" ...\n    "orderby" ...\n    "startposition" ...\n    ',
    code: '4000' } ]

example is not working because cannot find a module

Hi,

Even with install the request package, the app cannot found it, and I get this error.

module.js:328
    throw err;
    ^

Error: Cannot find module 'request'
    at Function.Module._resolveFilename (module.js:326:15)```

Any idea

Removal of Payments API

Hey there,

Saw in this commit cd8226d3dc59d746ac88383419ebb90d6102c818, that you removed functionality related to the payments flow. Wondering what the reason for that was, as I need this functionality in my app. I can always just amend the Quickbooks prototype locally, but wanted to make sure there wasn't other issues at play that I may be aware of that warranted it's removal.

Great work, and thanks for your help.

Query HTML Encoding does not include backslash

When I make a query request for Customers the value I am checking against has an apostrophe in the DisplayName so I account for that with an escaping backslash. However when the query is executed the url encoding does not account for the escaped backslash so the query will fail to escape the apostrophe in the query. The query as a result will get cut in half and fail to execute because of the remaining text.

quickbooks version - 1.0.9
npm version - 1.4.28
node version - 0.10.36

Code

var value = 'Joe\'s Auto';

quickbooks.findCustomers({limit: 1, DisplayName: value}, function(err, customers) {
   if(err) throw err;
   ...
});

Result

{ request: 
   { uri: 'https://quickbooks.api.intuit.com/v3/company/<ommited>/query?query=select%20*%20from%20customer%20where%20DisplayName%20%3D%20%27James%2F%27%20Auto%27%20maxresults%201',
     method: 'GET',
     headers: 
      { ... }
{ response: 
   { headers: 
      { date: 'Sun, 03 May 2015 20:55:27 GMT',
        via: '1.1 ipp-gateway-ap06',
        'content-type': 'application/json;charset=UTF-8',
        'cache-control': 'max-age=0, no-cache, no-store, must-revalidate, private',
        expires: '0',
        intuit_tid: 'bb7fd1ae-7121-4401-920f-d726b647d65d',
        'qbo-version': '85.317',
        vary: 'Accept-Encoding',
        'keep-alive': 'timeout=5, max=75',
        connection: 'Keep-Alive',
        'transfer-encoding': 'chunked' },
     statusCode: 200,
     body: { Fault: [Object], time: '2015-05-03T13:55:27.862-07:00' } } }
invoking endpoint: https://quickbooks.api.intuit.com/v3/company/<ommited>/query?query=select * from customer where DisplayName %3D %27Joe\%27 Auto%27 maxresults 1

{ Fault: 
   { Error: 
      [ { Message: 'Error parsing query',
          Detail: 'QueryParserError: Encountered " <IDENTIFIER> "Auto "" at line 1, column 53.\nWas expecting one of:\n    <EOF> \n    <AND> ...\n    "iterator" ...\n    "maxresults" ...\n    <OR> ...\n    "order" ...\n    "orderby" ...\n    "startposition" ...\n    ',
          code: '4000' } ],
     type: 'ValidationFault' },
  time: '2015-05-03T13:55:27.862-07:00' }

Necessary change for fix on Line 1813

// **********************  Query Api **********************
module.query = function(context, entity, criteria, callback) {
  var url = '/query?query@@select * from ' + entity
  for (var p in criteria) {
    if (p.toLowerCase() === 'count' && criteria[p]) {
      url = url.replace('select \* from', 'select count(*) from')
      delete criteria[p]
      continue
    }
  }
  if (criteria && typeof criteria !== 'function') {
    url += module.criteriaToString(criteria) || ''
    url = url.replace(/%/, '%25')
            .replace(/'/g, '%27')
            .replace(/=/, '%3D')
            .replace(/</, '%3C')
            .replace(/>/, '%3E')
            .replace(/\&/g, '%26')
            .replace(/\#/g, '%23')
            .replace(/\\/g, '%5C'); // Added check for backslash
  }
  url = url.replace('@@', '=')
  module.request(context, 'get', {url: url}, null, typeof criteria === 'function' ? criteria : callback)
}

reconnect() call failing

I believe the reconnect() call as written will fail each time due to the payload being XML and the check on line 1990:
(_.isString(body) && !_.isEmpty(body) && body.indexOf('<') === 0))

Would you consider adding a dependency like jxon and parsing the XML to JSON so the api for disconnect and reconnect both traffic in JSON like the rest of the calls do? We could then determine the error status by checking the ErrorCode field rather than drekking in the String like I had proposed in my previous PR.

What do you think?

Wildcard Queries with LIKE

When querying using LIKE, I found that any wildcards (%) used need to be escaped to be url encoded correctly. However, if using multiple wildcards, the second wildcard is not converted to %25, even when escaped.

Ex:

{ field: 'Name', value: '\%foobar\%', operator: 'LIKE' }

Result from the request string:

...WHERE%20Name%20LIKE%20%27%25foobar%%27

Instead, of %25 after 'foobar', the second wildcard merely appears as an additional '%'. Perhaps a missing 'global' flag on a regex replace?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.