node-quickbooks
node-quickbooks copied to clipboard
Can't include invoiceLink when querying an invoice
I'm having a very similar issue to the link posted below. When querying an invoice, I am unable to use the "include=invoiceLink" parameter. Any help would be appreciated!
https://help.developer.intuit.com/s/question/0D54R00006tj1K5/how-to-use-the-invoicelink-in-the-query-to-get-invoicelink-valueim-using-the-following-query-and-minor-version-is-36select-from-invoice-where-includeinvoicelinkim-not-getting-any-results-on-my-above-request
I forked with a dumb hack. Unfortunately I can't verify if it fully works until I have production access in Intuit. At the very least, it doesn't break any of these APIs: findCustomers
, createCustomer
, findInvoices
, createInvoice
. I need to wait an hour to verify that it doesn't break refreshTokenAccess
.
https://github.com/NomadHouse/node-quickbooks
(I suppose I'm necro'ing an old thread :/ but if it helps someone then :shrug:.)
The code is structured in such a way that you can't directly modify options
(or more specifically options.qs
) that are passed into the request()
call. This is a bummer. There are a couple of instances where query parameters are added already:
if (entity && entity.allowDuplicateDocNum) {
delete entity.allowDuplicateDocNum;
opts.qs.include = 'allowduplicatedocnum';
}
if (entity && entity.requestId) {
opts.qs.requestid = entity.requestId;
delete entity.requestId;
}
It would be nice to be able to hook into this. I was going to add an addtl options
argument to the getInvoice
method, but callback
really needs to be the last parameter and I don't want to change the order and break anything. So, I just added a new method that doesn't interfere with the existing logic:
/**
* Retrieves the payment link for an Invoice.
*
* @param {string} id - The invoice ID.
* @param {function} callback - Callback function which is called with any error and the invoice.
*/
QuickBooks.prototype.getInvoiceLink = function(id, callback) {
const options = {
url: `/invoice/${id}`
qs: { include: 'invoiceLink' }
}
module.request(this, 'get', options, null, module.unwrap(callback, 'Invoice'))
}
Here's my fork: https://github.com/charlie-s/node-quickbooks
You can install this via npm i git+https://github.com/charlie-s/node-quickbooks.git
Make sure you use the minimum version number of 36 to get access to the invoice link! e.g.:
const qbo = new QuickBooksAPI(qbAppId, qbAppSecret, accessToken, false, realmId, true, false, 36, '2.0', refreshToken)