GithubHelp home page GithubHelp logo

node-quickbooks's People

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

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 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)

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?

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?

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': '='
    }]

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


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'"

TaxService

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

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

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

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.

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)
}

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);

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.

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.

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?

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})
        })

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 : ))

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.

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?

"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.

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.

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.

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 ?

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.

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' } ]

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.

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!

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

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?

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 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

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!

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?

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

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

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

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.