Getting started with Nodejs and QuickBooks Online Part 4

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

Let's create a Sales Receipt!

In Part 4, I'll show how you can use the node-quickbooks's tests to create a SalesReceipt transaction against your developer sandbox. Specifically, I will be answering this question from the Intuit Developer forums.

Make a new branch.

$ git branch salesreceipt

Turn on debugging in config.js.

- debug: false,+ debug: true,

Open up test/index.js.

Go down to the test starting with describe('SalesReceipt', ...

Let's put this test that creates a sales receipt into its own test file test/salesreceipt.js.

Ok, so we modified the test/salesreceipt.js test with the JSON request from the forums question. But one glaring problem is the ItemRef: "61" is not going to work because there is no Item with an Id of 61 in the sandbox. The Item Id 61 is coming from the users QBO.

Therefore, we need to find an adequate replacement from the developer sandbox but the sandbox UI doesn't show Ids for Items. The API does show ids so let's create a temporary "test" that will display sandbox items and their Ids.

Notice, the it.only syntax. These tests use the mocha framework, which allows using only so only this one test will run and all others will be skipped. Perfect for what we need here, which is simple request so we can plug in a valid ItemRef Id to the other test.