### Quickbooks OAuth Flow Example Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md An Express.js example demonstrating the initial steps of the OAuth process for Quickbooks. It includes generating a state, creating an authorization URL, and handling the callback to exchange an authorization code for a token. ```javascript const states = {}; // optional, can be anything you want to track states app.get("/requestToken", (req, res) => { const state = Quickbooks.generateState(); // optional states[state] = true; // optional const authUrl = Quickbooks.authorizeUrl(QBAppconfig, state); // state is optional res.redirect(authUrl); }); // QB token callback - This endpoint must match what you put in your quickbooks app and config app.get("/callback", async (req, res) => { let realmID = req.query.realmId; let authCode = req.query.code; let state = req.query.state; // should check state here to prevent CSRF attacks if (!states[state]) { res.sendStatus(401); return; } states[state] = false; // check if realmID and authCode are present if (!realmID || typeof realmID !== "string" || !authCode || typeof authCode !== "string") { res.sendStatus(404) return; } // create token try { var qbo = new Quickbooks(QBAppconfig, realmID); const newToken = await qbo.createToken(authCode); res.send(newToken); // Should not send token out } catch (err) { console.log("Error getting token", err); res.send(err).status(500); } }); ``` -------------------------------- ### Verify QuickBooks Webhook Signature Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Provides an example of how to verify incoming QuickBooks webhook signatures using the `VerifyWebhookWithConfig` or `VerifyWebhook` methods. This is crucial for ensuring the authenticity of webhook events. ```typescript app.post("/qbwebhook", (req, res) => { const webhookPayload = req.body as WebhookPayload const signature = req.get('intuit-signature'); console.log("signature", signature, "webhookPayload", JSON.stringify(webhookPayload, null, 2)) if (!signature) { console.log("no signature"); res.status(401).send('FORBIDDEN'); return; } const signatureCheck = Quickbooks.VerifyWebhookWithConfig(QBAppconfig, webhookPayload, signature); // const signatureCheck = Quickbooks.VerifyWebhook(verifyString, webhookPayload, signature); // const signatureCheck = qbo.VerifyWebhook(webhookPayload, signature); // instance if (!signatureCheck) { console.log("signatureCheck failed"); res.status(401).send('FORBIDDEN'); return } console.log("webhookPayload is verified", webhookPayload); res.status(200).send('SUCCESS'); // Do stuff here with the webhookPayload /* { "eventNotifications": [{ "realmId": "193514507456064", "dataChangeEvent": { "entities": [ { "name": "Customer", "id": "67", "operation": "Create", "lastUpdated": "2023-10-27T19:26:27.000Z" } ] } }] } */ }) ``` -------------------------------- ### QuickBooks: Get User Info Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves user information (OAuth2). This is an instance method of the QuickBooks class. ```JavaScript quickBooks.getUserInfo() ``` -------------------------------- ### QuickBooks: Get Token Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a token. This is an instance method of the QuickBooks class. ```JavaScript quickBooks.getToken() ``` -------------------------------- ### Get Company Info from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the CompanyInfo from QuickBooks. This method does not require any parameters. ```javascript quickBooks.getCompanyInfo() ``` -------------------------------- ### Get QuickBooks Token Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the QuickBooks token from the configured storage. ```JavaScript QuickBooks.getToken() ``` -------------------------------- ### QuickBooks: Get Public Key Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the public key. This instance method of the QuickBooks class requires modulus and exponent as parameters. ```JavaScript quickBooks.getPublicKey(modulus, exponent) ``` -------------------------------- ### QuickBooks Get Company Info Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the company information for the connected QuickBooks account. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getCompanyInfo().then(companyInfo => { // Process company information }); ``` -------------------------------- ### QuickBooks Get Customer by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific customer from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getCustomer('36').then(customer => { // Process the retrieved customer }); ``` -------------------------------- ### QuickBooks Get Deposit by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific deposit from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getDeposit('38').then(deposit => { // Process the retrieved deposit }); ``` -------------------------------- ### QuickBooks Get Class by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific class from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getClass('34').then(classObj => { // Process the retrieved class }); ``` -------------------------------- ### QuickBooks Get Credit Memo by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific credit memo from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getCreditMemo('35').then(creditMemo => { // Process the retrieved credit memo }); ``` -------------------------------- ### QuickBooks Get Account by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific account from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getAccount('30').then(account => { // Process the retrieved account }); ``` -------------------------------- ### Get Attachable from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves an Attachable from QuickBooks by its Id. The Id parameter should be a string identifying the persistent Attachable. ```javascript quickBooks.getAttachable(Id) ``` -------------------------------- ### Get Class from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a Class from QuickBooks using its Id. The Id must be a string representing the persistent Class. ```javascript quickBooks.getClass(Id) ``` -------------------------------- ### Get Account from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific Account from QuickBooks using its Id. The Id must be a string representing the persistent Account. ```javascript quickBooks.getAccount(Id) ``` -------------------------------- ### QuickBooks Constructor Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Initializes a new QuickBooks client instance for accessing the QuickBooks V3 Rest API. Each instance should represent a unique user and company accessing the API. ```JavaScript new QuickBooks(appConfig, realmID) ``` -------------------------------- ### Class Store Method - QBConfig with QBStore Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Configuration for the class store method, instantiating the `QBStore` class and assigning it to `storeStrategy`. Includes necessary Quickbooks API credentials. ```javascript const QBAppconfig = { appKey: QB_APP_KEY, appSecret: QB_APP_SECRET, redirectUrl: QB_REDIRECT_URL, scope: [ Quickbooks.scopes.Accounting, ], storeStrategy: new QBStore(), }; ``` -------------------------------- ### Basic QuickBooks Configuration Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Sets up a basic QuickBooks configuration with auto-refresh disabled and a provided access token. It then uses this configuration to find customers. ```typescript const appConfig: AppConfig = { autoRefresh: false, accessToken: '123' }; const qbo = new Quickbooks(appConfig, realmID); const customers = await qbo.findCustomers({ Id: "1234" }); ``` -------------------------------- ### Find Customer by ID with QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Demonstrates how to initialize the QuickBooks library and find a customer using their ID. It logs the customer's name to the console. ```javascript const QuickBooks = require("quickbooks-node-promise"); const qbo = new QuickBooks(appConfig, realmID); const customers = await qbo.findCustomers({ Id: "1234" }); const customer = customer.QueryResponse.Customer[0]; console.log(`Hi my customer's name is ${customer.Name}`); ``` -------------------------------- ### Class Store Method - QBStore Implementation Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Implementation of the `QBStore` class for the class-based store method. It includes `getQBToken` to retrieve token information and `storeQBToken` to save new token data, both returning promises. ```typescript class QBStore implements QBStoreStrategy { /** * Uses a realmID to lookup the token information. * Must return a promise with the token information */ getQBToken(getTokenData: StoreGetTokenData, appConfig: AppConfig, extra: any) { const realmID = getTokenData.realmID.toString(); // should pull from database or some other storage method Promise.resolve(realmInfo[realmID]); } /** * Used to store the new token information * Will be looked up using the realmID */ storeQBToken(storeData: StoreSaveTokenData, appConfig: AppConfig, extra: any) { const realmID = storeData.realmID.toString(); // should save to database or some other storage method realmInfo[realmID] = storeData Promis.resolve(realmInfo[realmID]) } } ``` -------------------------------- ### QuickBooks Get Estimate by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific estimate from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getEstimate('40').then(estimate => { // Process the retrieved estimate }); ``` -------------------------------- ### Find QuickBooks Customers Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Demonstrates how to find customers in QuickBooks using different query parameters like ID, field-value pairs, or raw SQL queries. It supports filtering by ID, specifying fields and operators, and using complex query structures. ```javascript const customers = await qbo.findCustomers({ Id: "1234", limit: 10, }); ``` ```javascript const customers = await qbo.findCustomers({ field: "Id", value: "1234", operator: "=" // optional, default is "=" }); ``` ```javascript const customers = await qbo.findCustomers({ limit: 10, items: [ { field: "Id", value: "1234" }, ], }); ``` ```javascript const customers = await qbo.findCustomers("SELECT * FROM Customer WHERE Id = '1234'"); ``` -------------------------------- ### QuickBooks Get Employee by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific employee from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getEmployee('39').then(employee => { // Process the retrieved employee }); ``` -------------------------------- ### Create QuickBooks CreditMemo Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a CreditMemo in QuickBooks. This method requires a creditMemo object containing the details of the credit memo to be persisted. ```javascript quickBooks.createCreditMemo(creditMemo) ``` -------------------------------- ### QuickBooks Create Item Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new item (product or service) in QuickBooks. Requires an item object with properties like Name, Type, and potentially IncomeAccountRef. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const item = { Name: 'Web Design Service', Type: 'Service', IncomeAccountRef: { value: '11' } }; qb.createItem(item).then(newItem => { // Item created }); ``` -------------------------------- ### QuickBooks Get Department by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific department from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getDepartment('37').then(department => { // Process the retrieved department }); ``` -------------------------------- ### QuickBooks Create Account Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new account in QuickBooks. Requires an account object with properties like AccountType, Name, and potentially others depending on the account type. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const account = { AccountType: 'Bank', Name: 'Checking Account' }; qb.createAccount(account).then(newAccount => { // New account created }); ``` -------------------------------- ### QuickBooks Get Bill by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific bill from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getBill('32').then(bill => { // Process the retrieved bill }); ``` -------------------------------- ### QuickBooks Create Customer Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new customer in QuickBooks. Requires a customer object with properties like DisplayName or GivenName and FamilyName. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const customer = { DisplayName: 'Acme Corporation', BillAddr: { Line1: '123 Main St', City: 'Anytown', State: 'CA', PostalCode: '90210' } }; qb.createCustomer(customer).then(newCustomer => { // Customer created }); ``` -------------------------------- ### Create QuickBooks Class Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Class in QuickBooks. This method requires a class object containing the details of the class to be persisted. ```javascript quickBooks.createClass(class) ``` -------------------------------- ### Create QuickBooks Customer Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Customer in QuickBooks. This method requires a customer object containing the details of the customer to be persisted. ```javascript quickBooks.createCustomer(customer) ``` -------------------------------- ### Retrieve Trial Balance Report from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md This method retrieves the Trial Balance report from QuickBooks. It accepts an optional options object for customization. ```javascript quickBooks.reportTrialBalance(options) ``` -------------------------------- ### QuickBooks Get Attachable by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific attachable entity from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getAttachable('31').then(attachable => { // Process the retrieved attachable }); ``` -------------------------------- ### Create QuickBooks Purchase Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Purchase in QuickBooks. This method requires a purchase object containing the details of the purchase to be persisted. ```javascript quickBooks.createPurchase(purchase) ``` -------------------------------- ### QuickBooks Create Sales Receipt Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a sales receipt in QuickBooks, documenting a sale for which payment was received immediately. Requires a sales receipt object with customer and item details. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const salesReceipt = { CustomerRef: { value: '22' }, TotalAmt: 120.00, Line: [ { Amount: 120.00, DetailType: 'SalesItemLineDetail', SalesItemLineDetail: { ItemRef: { value: '23' } } } ] }; qb.createSalesReceipt(salesReceipt).then(newSalesReceipt => { // Sales receipt created }); ``` -------------------------------- ### Create Sales Receipt in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a SalesReceipt in QuickBooks. This instance method requires a salesReceipt object to be persisted. ```javascript quickBooks.createSalesReceipt(salesReceipt) ``` -------------------------------- ### QuickBooks Get Bill Payment by ID Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a specific bill payment from QuickBooks using its unique ID. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); qb.getBillPayment('33').then(billPayment => { // Process the retrieved bill payment }); ``` -------------------------------- ### Count QuickBooks Customers Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Shows how to count the number of resources in QuickBooks that match specific query criteria. The count method returns a query response with a `totalCount` property. ```javascript const count = await qbo.countCustomers({ Id: "1234", }); ``` ```javascript const count = await qbo.countCustomers({ field: "Name", value: "hello%world", operator: "like", }); ``` -------------------------------- ### Get Bill Payment from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a BillPayment from QuickBooks by its Id. The Id parameter should be a string identifying the persistent BillPayment. ```javascript quickBooks.getBillPayment(Id) ``` -------------------------------- ### Internal Store Method - Basic Config Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Configuration for the internal store method when managing OAuth process and token information manually. Requires `autoRefresh` set to `false` and an `accessToken`. ```javascript const QBAppconfig = { autoRefresh: false, accessToken: '123', }; ``` -------------------------------- ### Retrieve QuickBooks Preferences Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the general Preferences settings from QuickBooks. This is a no-argument instance method of the QuickBooks class. ```JavaScript quickBooks.getPreferences() ``` -------------------------------- ### Get QuickBooks Token Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the stored token information. This method is used to access previously saved authentication tokens. ```JavaScript quickBooks.getToken() ``` -------------------------------- ### Create Purchase Order in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a PurchaseOrder in QuickBooks. This method requires a purchaseOrder object as input, which will be persisted in QuickBooks. ```javascript quickBooks.createPurchaseOrder(purchaseOrder) ``` -------------------------------- ### Get Bill from QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves a Bill from QuickBooks using its unique Id. The Id must be a string representing the persistent Bill. ```javascript quickBooks.getBill(Id) ``` -------------------------------- ### QuickBooks: Create Account Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new Account in QuickBooks. This instance method of the QuickBooks class takes an unsaved account object as a parameter. ```JavaScript quickBooks.createAccount(account) ``` -------------------------------- ### QuickBooks Create Class Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new class in QuickBooks. Requires a class object with at least a Name property. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const classObj = { Name: 'Marketing' }; qb.createClass(classObj).then(newClass => { // Class created }); ``` -------------------------------- ### QuickBooks Create Purchase Order Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a purchase order in QuickBooks. Requires a purchase order object including vendor details, items ordered, and quantities. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const purchaseOrder = { VendorRef: { value: '18' }, TotalAmt: 300.00, Line: [ { Amount: 300.00, DetailType: 'ItemBasedExpenseLineDetail', ItemBasedExpenseLineDetail: { ItemRef: { value: '19' } } } ] }; qb.createPurchaseOrder(purchaseOrder).then(newPurchaseOrder => { // Purchase order created }); ``` -------------------------------- ### QuickBooks Get Exchange Rate Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves the exchange rate between two currencies for a given date. Requires specifying the source currency, target currency, and date. -------------------------------- ### Create Tax Service in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a TaxService in QuickBooks. This method requires a taxService object to be persisted in the system. ```javascript quickBooks.createTaxService(taxService) ``` -------------------------------- ### QuickBooks Create Purchase Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Records a purchase transaction in QuickBooks. Requires a purchase object detailing the vendor, items purchased, and amounts. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const purchase = { VendorRef: { value: '16' }, TotalAmt: 75.00, Line: [ { Amount: 75.00, DetailType: 'ItemBasedExpenseLineDetail', ItemBasedExpenseLineDetail: { ItemRef: { value: '17' } } } ] }; qb.createPurchase(purchase).then(newPurchase => { // Purchase created }); ``` -------------------------------- ### Delete QuickBooks Invoice Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes an Invoice from QuickBooks. Accepts either the Invoice object or its Id. If an Id is provided, an additional GET request is made to retrieve the Invoice first. ```JavaScript quickBooks.deleteInvoice(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Estimate Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes an Estimate from QuickBooks. Accepts either the Estimate object or its Id. If an Id is provided, an additional GET request is made to retrieve the Estimate first. ```JavaScript quickBooks.deleteEstimate(idOrEntity) ``` -------------------------------- ### Create QuickBooks Item Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates an Item in QuickBooks. This method requires an item object containing the details of the item to be persisted. ```javascript quickBooks.createItem(item) ``` -------------------------------- ### Find QuickBooks Classes Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Finds all Classes in QuickBooks. Supports optional criteria for filtering results. This is an instance method of the QuickBooks class. ```javascript quickBooks.findClasses(criteria) ``` -------------------------------- ### Delete QuickBooks Deposit Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a Deposit from QuickBooks. Accepts either the Deposit object or its Id. If an Id is provided, an additional GET request is made to retrieve the Deposit first. ```JavaScript quickBooks.deleteDeposit(idOrEntity) ``` -------------------------------- ### Create QuickBooks Deposit Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Deposit in QuickBooks. This method requires a deposit object containing the details of the deposit to be persisted. ```javascript quickBooks.createDeposit(deposit) ``` -------------------------------- ### Delete QuickBooks Bill Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a Bill from QuickBooks. Accepts either the Bill object or its Id. If an Id is provided, an additional GET request is made to retrieve the Bill first. ```JavaScript quickBooks.deleteBill(idOrEntity) ``` -------------------------------- ### QuickBooks Create Deposit Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Records a deposit in QuickBooks. Requires a deposit object specifying the bank account and the source of the funds. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const deposit = { DepositToAccountRef: { value: '6' }, Line: [ { Amount: 500.00, Description: 'Customer Payment' } ] }; qb.createDeposit(deposit).then(newDeposit => { // Deposit created }); ``` -------------------------------- ### Delete QuickBooks Attachable Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes an Attachable from QuickBooks. Accepts either the Attachable object or its Id. If an Id is provided, an additional GET request is made to retrieve the Attachable first. ```JavaScript quickBooks.deleteAttachable(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Journal Entry Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Removes a JournalEntry from QuickBooks. This function takes an ID or the JournalEntry entity. If an ID is supplied, a preliminary GET request is performed to retrieve the JournalEntry before its deletion. ```JavaScript quickBooks.deleteJournalEntry(idOrEntity) ``` -------------------------------- ### QuickBooks Create Invoice Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a sales invoice in QuickBooks. Requires an invoice object with customer information, line items, and payment terms. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const invoice = { CustomerRef: { value: '9' }, Line: [ { Amount: 150.00, DetailType: 'SalesItemLineDetail', SalesItemLineDetail: { ItemRef: { value: '10' } } } ] }; qb.createInvoice(invoice).then(newInvoice => { // Invoice created }); ``` -------------------------------- ### QuickBooks Create Credit Memo Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a credit memo in QuickBooks, typically issued to a customer for returned goods or services. Requires a credit memo object with customer reference and line item details. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const creditMemo = { CustomerRef: { value: '4' }, Line: [ { Amount: 75.00, DetailType: 'SalesItemLineDetail', SalesItemLineDetail: { ItemRef: { value: '5' } } } ] }; qb.createCreditMemo(creditMemo).then(newCreditMemo => { // Credit memo created }); ``` -------------------------------- ### Delete QuickBooks Credit Memo Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a CreditMemo from QuickBooks. Accepts either the CreditMemo object or its Id. If an Id is provided, an additional GET request is made to retrieve the CreditMemo first. ```JavaScript quickBooks.deleteCreditMemo(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Bill Payment Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a BillPayment from QuickBooks. Accepts either the BillPayment object or its Id. If an Id is provided, an additional GET request is made to retrieve the BillPayment first. ```JavaScript quickBooks.deleteBillPayment(idOrEntity) ``` -------------------------------- ### Retrieve Vendor Balance Detail Report Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Fetches the Vendor Balance Detail report from QuickBooks. This instance method of the QuickBooks class allows for optional configuration. ```javascript quickBooks.reportVendorBalanceDetail(options) ``` -------------------------------- ### Delete QuickBooks Time Activity Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Removes a TimeActivity from QuickBooks. This function accepts the TimeActivity ID or the TimeActivity entity. A preliminary GET request is performed if an ID is supplied to retrieve the TimeActivity before its deletion. ```JavaScript quickBooks.deleteTimeActivity(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Purchase Order Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Removes a PurchaseOrder from QuickBooks. The function accepts the PurchaseOrder ID or the PurchaseOrder entity. A preceding GET request is issued if an ID is provided to retrieve the entity before deletion. ```JavaScript quickBooks.deletePurchaseOrder(idOrEntity) ``` -------------------------------- ### QuickBooks Create Vendor Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new vendor in QuickBooks. Requires a vendor object with properties like DisplayName or CompanyName. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const vendor = { DisplayName: 'Office Supplies Inc.', PrimaryEmailAddr: { Address: 'info@officesupplies.com' } }; qb.createVendor(vendor).then(newVendor => { // Vendor created }); ``` -------------------------------- ### Create QuickBooks Payment Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Payment in QuickBooks. This method requires a payment object containing the details of the payment to be persisted. ```javascript quickBooks.createPayment(payment) ``` -------------------------------- ### Delete QuickBooks Transfer Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a Transfer from QuickBooks. The method accepts the Transfer ID or the Transfer entity object. An additional GET request is made if only the ID is provided to retrieve the full Transfer details for deletion. ```JavaScript quickBooks.deleteTransfer(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Refund Receipt Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a RefundReceipt from QuickBooks. This method takes the RefundReceipt ID or the RefundReceipt entity object. An additional GET request is made if only the ID is provided to retrieve the full RefundReceipt for deletion. ```JavaScript quickBooks.deleteRefundReceipt(idOrEntity) ``` -------------------------------- ### Find Tax Rates in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md This method finds all Tax Rates in QuickBooks. It accepts an optional criteria object to filter the search results. The criteria are converted into a 'where' clause for the query. ```javascript quickBooks.findTaxRates(criteria) ``` -------------------------------- ### Delete QuickBooks Purchase Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a Purchase from QuickBooks. This method requires either the Purchase ID or the Purchase entity object. If an ID is used, an extra GET request is performed to fetch the Purchase details before deletion. ```JavaScript quickBooks.deletePurchase(idOrEntity) ``` -------------------------------- ### Internal Store Method - Advanced Config Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Advanced configuration for the internal store method, including `refreshToken` for token refreshing and `autoRefresh` enabled. Requires `appKey`, `appSecret`, `redirectUrl`, and `scope`. ```javascript const QBAppconfig = { appKey: QB_APP_KEY, appSecret: QB_APP_SECRET, redirectUrl: QB_REDIRECT_URL, scope: [ Quickbooks.scopes.Accounting, ], accessToken: '123', refreshToken: '123', }; ``` -------------------------------- ### Delete QuickBooks Vendor Credit Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a VendorCredit from QuickBooks. This method requires either the VendorCredit ID or the VendorCredit entity object. If an ID is used, an extra GET request is performed to fetch the VendorCredit details before deletion. ```JavaScript quickBooks.deleteVendorCredit(idOrEntity) ``` -------------------------------- ### Generate QuickBooks Authorization URL Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Generates the redirect link to the QuickBooks Authorization Page. This is a static method of the QuickBooks class that requires application configuration. ```javascript QuickBooks.authorizeUrl(appConfig) ``` -------------------------------- ### Delete QuickBooks Sales Receipt Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a SalesReceipt from QuickBooks. The method accepts either the SalesReceipt ID or the SalesReceipt entity object. If an ID is provided, an extra GET request is made to retrieve the full SalesReceipt before deletion. ```JavaScript quickBooks.deleteSalesReceipt(idOrEntity) ``` -------------------------------- ### QuickBooks Create Payment Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Records a payment received from a customer in QuickBooks. Requires a payment object including the customer reference, payment amount, and the account the payment was deposited into. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const payment = { CustomerRef: { value: '14' }, TotalAmt: 250.00, DepositToAccountRef: { value: '15' } }; qb.createPayment(payment).then(newPayment => { // Payment created }); ``` -------------------------------- ### Delete QuickBooks Payment Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a Payment record from QuickBooks. The method accepts the Payment ID or the Payment entity object. An additional GET request is made if only the ID is provided to retrieve the full Payment details for deletion. ```JavaScript quickBooks.deletePayment(idOrEntity) ``` -------------------------------- ### QuickBooks Create Vendor Credit Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Records a vendor credit in QuickBooks, typically for returns or overpayments to a vendor. Requires a vendor credit object with vendor and item details. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const vendorCredit = { VendorRef: { value: '28' }, TotalAmt: 50.00, Line: [ { Amount: 50.00, DetailType: 'ItemBasedExpenseLineDetail', ItemBasedExpenseLineDetail: { ItemRef: { value: '29' } } } ] }; qb.createVendorCredit(vendorCredit).then(newVendorCredit => { // Vendor credit created }); ``` -------------------------------- ### Find Preferences in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Retrieves all Preferenceses from QuickBooks. An optional criteria object can be provided to filter the results. ```javascript quickBooks.findPreferenceses(criteria) ``` -------------------------------- ### Delete QuickBooks Invoice Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes an Invoice from QuickBooks. This method can accept either the Invoice ID or the Invoice entity object. If an ID is provided, an additional GET request is made to retrieve the full Invoice entity before deletion. ```JavaScript quickBooks.deleteInvoice(idOrEntity) ``` -------------------------------- ### Delete QuickBooks Journal Code Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Deletes a JournalCode from QuickBooks. The method accepts either the JournalCode ID or the JournalCode entity object. Providing an ID triggers an extra GET request to fetch the JournalCode details prior to deletion. ```JavaScript quickBooks.deleteJournalCode(idOrEntity) ``` -------------------------------- ### Create QuickBooks Department Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Department in QuickBooks. This method requires a department object containing the details of the department to be persisted. ```javascript quickBooks.createDepartment(department) ``` -------------------------------- ### QuickBooks Create Time Activity Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Records a time activity in QuickBooks, typically for tracking employee work hours. Requires a time activity object with employee reference, date, and duration. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const timeActivity = { EmployeeRef: { value: '24' }, TxnDate: '2023-10-27', Hours: 8, ItemRef: { value: '25' } }; qb.createTimeActivity(timeActivity).then(newTimeActivity => { // Time activity created }); ``` -------------------------------- ### Create QuickBooks PaymentMethod Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a PaymentMethod in QuickBooks. This method requires a paymentMethod object containing the details of the payment method to be persisted. ```javascript quickBooks.createPaymentMethod(paymentMethod) ``` -------------------------------- ### Create Time Activity in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a TimeActivity in QuickBooks. This method requires a timeActivity object to be persisted. ```javascript quickBooks.createTimeActivity(timeActivity) ``` -------------------------------- ### Retrieve Class Sales Report Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Fetches the Class Sales report from QuickBooks. This instance method of the QuickBooks class accepts optional configuration options. ```javascript quickBooks.reportClassSales(options) ``` -------------------------------- ### QuickBooks Create Attachable Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates an attachable entity in QuickBooks, typically used for attaching files to other transactions or entities. Requires an attachable object with details like FileName and a reference to the parent entity. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const attachable = { FileName: 'document.txt', // Other attachable properties... }; qb.createAttachable(attachable).then(newAttachable => { // Attachable created }); ``` -------------------------------- ### Find QuickBooks Budgets Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Finds all Budgets in QuickBooks. Supports optional criteria for filtering results. This is an instance method of the QuickBooks class. ```javascript quickBooks.findBudgets(criteria) ``` -------------------------------- ### Advanced QuickBooks Configuration with Function Store Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md An advanced QuickBooks configuration using a function store for token management. It includes `getToken` and `saveToken` functions that interact with a `realms` object, enabling automatic token refresh. ```javascript const realms = {}; // QB config const QBAppconfig = { appKey: QB_APP_KEY, appSecret: QB_APP_SECRET, redirectUrl: QB_REDIRECT_URL, scope: [ Quickbooks.scopes.Accounting, Quickbooks.scopes.OpenId, Quickbooks.scopes.Profile, Quickbooks.scopes.Email, Quickbooks.scopes.Phone, Quickbooks.scopes.Address, ], getToken(realmId, appConfig) { return Promise.resolve(realms[realmId]); }, saveToken(realmId, tokenData, appConfig, extra) { realms[realmId] = saveTokenData; return Promise.resolve(saveTokenData); }, }; ``` -------------------------------- ### Create QuickBooks PurchaseOrder Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a PurchaseOrder in QuickBooks. This method requires a purchaseOrder object containing the details of the purchase order to be persisted. ```javascript quickBooks.createPurchaseOrder(purchaseOrder) ``` -------------------------------- ### QuickBooks Create Employee Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new employee in QuickBooks. Requires an employee object with details like Name and potentially other employment-related information. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const employee = { GivenName: 'Jane', FamilyName: 'Doe', PrimaryEmailAddr: { Address: 'jane.doe@example.com' } }; qb.createEmployee(employee).then(newEmployee => { // Employee created }); ``` -------------------------------- ### Generate Authorization URL Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Generates the redirect URI for the QuickBooks authorization page. This is the first step in the OAuth 2.0 authentication flow. ```JavaScript quickBooks.authorizeUrl() ``` -------------------------------- ### Functions Store Method - getToken and saveToken Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Configuration for the functions store method, providing `getToken` and `saveToken` functions to manage token persistence. Both functions return promises for asynchronous operations. ```javascript const QBAppconfig = { appKey: QB_APP_KEY, appSecret: QB_APP_SECRET, redirectUrl: QB_REDIRECT_URL, scope: [ Quickbooks.scopes.Accounting, ], getToken(realmId: number | string, appConfig: AppConfig, extra: any) { // should pull from database or some other storage method return Promise.resolve(realms[realmId]); }, saveToken(realmId: number | string, tokenData: StoreTokenData, appConfig: AppConfig, extra: any) { // should save to database or some other storage method realms[realmId] = saveTokenData; return Promise.resolve(saveTokenData); }, }; ``` -------------------------------- ### Create QuickBooks JournalEntry Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a JournalEntry in QuickBooks. This method requires a journalEntry object containing the details of the journal entry to be persisted. ```javascript quickBooks.createJournalEntry(journalEntry) ``` -------------------------------- ### QuickBooks Create Journal Entry Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a journal entry in QuickBooks, used for recording financial transactions that don't fit other transaction types. Requires a journal entry object with multiple lines representing debits and credits. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const journalEntry = { JournalEntryLine: [ { AccountRef: { value: '12' }, Description: 'Debit entry', Amount: 100.00, DebitOrCredit: 'Debit' }, { AccountRef: { value: '13' }, Description: 'Credit entry', Amount: 100.00, DebitOrCredit: 'Credit' } ] }; qb.createJournalEntry(journalEntry).then(newJournalEntry => { // Journal entry created }); ``` -------------------------------- ### Create QuickBooks Estimate Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates an Estimate in QuickBooks. This method requires an estimate object containing the details of the estimate to be persisted. ```javascript quickBooks.createEstimate(estimate) ``` -------------------------------- ### QuickBooks Create Tax Service Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new tax service in QuickBooks. Requires a tax service object with a Name property. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const taxService = { Name: 'Sales Tax' }; qb.createTaxService(taxService).then(newTaxService => { // Tax service created }); ``` -------------------------------- ### Create Vendor in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a Vendor in QuickBooks. This method requires a vendor object to be persisted. ```javascript quickBooks.createVendor(vendor) ``` -------------------------------- ### Create QuickBooks Employee Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates an Employee in QuickBooks. This method requires an employee object containing the details of the employee to be persisted. ```javascript quickBooks.createEmployee(employee) ``` -------------------------------- ### Find QuickBooks Company Infos Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Finds all Company Infos in QuickBooks. Supports optional criteria for filtering results. This is an instance method of the QuickBooks class. ```javascript quickBooks.findCompanyInfos(criteria) ``` -------------------------------- ### QuickBooks: Upload File Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Uploads a file as an Attachable in QuickBooks, optionally linking it to a specific entity. This instance method requires filename, contentType, stream, and optionally entityType and entityId. ```JavaScript quickBooks.upload(filename, contentType, stream, entityType, entityId) ``` -------------------------------- ### Find QuickBooks Customers Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Finds all Customers in QuickBooks. Supports optional criteria for filtering results. This is an instance method of the QuickBooks class. ```javascript quickBooks.findCustomers(criteria) ``` -------------------------------- ### Find QuickBooks Attachables Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Finds all Attachables in QuickBooks. Supports optional criteria for filtering results. This is an instance method of the QuickBooks class. ```javascript quickBooks.findAttachables(criteria) ``` -------------------------------- ### Retrieve Aged Payable Detail Report Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Fetches the Aged Payable Detail report from QuickBooks. As an instance method of the QuickBooks class, it supports optional configuration options. ```javascript quickBooks.reportAgedPayableDetail(options) ``` -------------------------------- ### Find Time Activities in QuickBooks Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md This method finds all Time Activities in QuickBooks. It accepts an optional criteria object to filter the search results. The criteria are converted into a 'where' clause for the query. ```javascript quickBooks.findTimeActivities(criteria) ``` -------------------------------- ### Create QuickBooks Token Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new token for a given realm ID using an authorization code. It requires application configuration, the authorization code, and the realm ID. The method returns a new token with expiration dates. ```JavaScript QuickBooks.createToken(appConfig, authCode, realmID) ``` -------------------------------- ### Create QuickBooks Invoice Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates an Invoice in QuickBooks. This method requires an invoice object containing the details of the invoice to be persisted. ```javascript quickBooks.createInvoice(invoice) ``` -------------------------------- ### QuickBooks Create Department Source: https://github.com/pbrink231/quickbooks-node-promise/blob/main/readme.md Creates a new department in QuickBooks. Requires a department object with a Name property. ```JavaScript const QuickBooks = require('quickbooks'); const qb = new QuickBooks(appConfig, realmID); const department = { Name: 'Sales' }; qb.createDepartment(department).then(newDepartment => { // Department created }); ```