From 59a40fe2d6b63686447c4d5e4adb59a78396ad69 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 18 Nov 2024 15:50:32 -0500 Subject: [PATCH 01/19] refactoring --- .../actions/create-bill/create-bill.mjs | 2 +- .../create-customer/create-customer.mjs | 2 +- .../actions/create-invoice/create-invoice.mjs | 2 +- .../actions/create-payment/create-payment.mjs | 2 +- .../create-purchase/create-purchase.mjs | 2 +- .../delete-purchase/delete-purchase.mjs | 2 +- .../quickbooks/actions/get-bill/get-bill.mjs | 2 +- .../actions/get-customer/get-customer.mjs | 2 +- .../actions/get-invoice/get-invoice.mjs | 2 +- .../actions/get-my-company/get-my-company.mjs | 2 +- .../get-purchase-order/get-purchase-order.mjs | 2 +- .../actions/get-purchase/get-purchase.mjs | 2 +- .../get-sales-receipt/get-sales-receipt.mjs | 2 +- .../get-time-activity/get-time-activity.mjs | 2 +- .../sandbox-search-invoices.mjs | 2 +- .../search-accounts/search-accounts.mjs | 2 +- .../search-customers/search-customers.mjs | 2 +- .../actions/search-items/search-items.mjs | 2 +- .../search-products/search-products.mjs | 2 +- .../actions/search-query/search-query.mjs | 2 +- .../search-time-activities.mjs | 2 +- .../actions/search-vendors/search-vendors.mjs | 2 +- .../sparse-update-invoice.mjs | 2 +- .../update-customer/update-customer.mjs | 2 +- components/quickbooks/package.json | 2 +- components/quickbooks/quickbooks.app.mjs | 247 +++++++++--------- components/quickbooks/sources/common/base.mjs | 12 + .../new-customer-created.mjs | 5 +- .../new-customer-updated.mjs | 2 +- .../new-invoice-created.mjs | 3 - .../new-item-created/new-item-created.mjs | 3 - 31 files changed, 161 insertions(+), 161 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index bb2bb2fed3ae2..3be36a36fd4d7 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-create-bill", name: "Create Bill", - description: "Creates a bill. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#create-a-bill)", + description: "Creates a bill. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#create-a-bill)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/create-customer/create-customer.mjs b/components/quickbooks/actions/create-customer/create-customer.mjs index a5d419c22de74..0f6c4ff8d4e94 100644 --- a/components/quickbooks/actions/create-customer/create-customer.mjs +++ b/components/quickbooks/actions/create-customer/create-customer.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-create-customer", name: "Create Customer", - description: "Creates a customer. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer)", + description: "Creates a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 408be0eeacc87..72dd5aed7c3e4 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-create-invoice", name: "Create Invoice", - description: "Creates an invoice. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice)", + description: "Creates an invoice. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/create-payment/create-payment.mjs b/components/quickbooks/actions/create-payment/create-payment.mjs index 01758a39a6827..2321f5fc1430e 100644 --- a/components/quickbooks/actions/create-payment/create-payment.mjs +++ b/components/quickbooks/actions/create-payment/create-payment.mjs @@ -3,7 +3,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-create-payment", name: "Create Payment", - description: "Creates a payment. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#create-a-payment)", + description: "Creates a payment. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#create-a-payment)", version: "0.0.5", type: "action", props: { diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index fcf186c2cd465..950ccdec8cc10 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-create-purchase", name: "Create Purchase", - description: "Creates a new purchase. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#create-a-purchase)", + description: "Creates a new purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#create-a-purchase)", version: "0.0.4", type: "action", props: { diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index 707d945323344..74bc04d2d29aa 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -3,7 +3,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-delete-purchase", name: "Delete Purchase", - description: "Delete a specific purchase. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#delete-a-purchase)", + description: "Delete a specific purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#delete-a-purchase)", version: "0.0.4", type: "action", props: { diff --git a/components/quickbooks/actions/get-bill/get-bill.mjs b/components/quickbooks/actions/get-bill/get-bill.mjs index afb7b60c592bd..08b5dc5d770d3 100644 --- a/components/quickbooks/actions/get-bill/get-bill.mjs +++ b/components/quickbooks/actions/get-bill/get-bill.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-bill", name: "Get Bill", - description: "Returns info about a bill. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#read-a-bill)", + description: "Returns info about a bill. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#read-a-bill)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-customer/get-customer.mjs b/components/quickbooks/actions/get-customer/get-customer.mjs index 6ea17e0340607..3c95809cf39a5 100644 --- a/components/quickbooks/actions/get-customer/get-customer.mjs +++ b/components/quickbooks/actions/get-customer/get-customer.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-customer", name: "Get Customer", - description: "Returns info about a customer. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer#read-a-customer)", + description: "Returns info about a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer#read-a-customer)", version: "0.3.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-invoice/get-invoice.mjs b/components/quickbooks/actions/get-invoice/get-invoice.mjs index 898ee0495e57a..f6e5c2b4185cd 100644 --- a/components/quickbooks/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks/actions/get-invoice/get-invoice.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-invoice", name: "Get Invoice", - description: "Returns info about an invoice. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#read-an-invoice)", + description: "Returns info about an invoice. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#read-an-invoice)", version: "0.2.7", type: "action", props: { diff --git a/components/quickbooks/actions/get-my-company/get-my-company.mjs b/components/quickbooks/actions/get-my-company/get-my-company.mjs index 334150777e38a..9292f7c821ba8 100644 --- a/components/quickbooks/actions/get-my-company/get-my-company.mjs +++ b/components/quickbooks/actions/get-my-company/get-my-company.mjs @@ -3,7 +3,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-my-company", name: "Get My Company", - description: "Gets info about a company. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo)", + description: "Gets info about a company. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs index 5bdfc45477ac4..170f748db7d0f 100644 --- a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs +++ b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-purchase-order", name: "Get Purchase Order", - description: "Returns details about a purchase order. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchaseorder#read-a-purchase-order)", + description: "Returns details about a purchase order. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchaseorder#read-a-purchase-order)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-purchase/get-purchase.mjs b/components/quickbooks/actions/get-purchase/get-purchase.mjs index d10339ef55fba..de50f8bd32a3e 100644 --- a/components/quickbooks/actions/get-purchase/get-purchase.mjs +++ b/components/quickbooks/actions/get-purchase/get-purchase.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-purchase", name: "Get Purchase", - description: "Returns info about a purchase. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#read-a-purchase)", + description: "Returns info about a purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#read-a-purchase)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs index c630ea1e62c6e..2c3dbbca67a90 100644 --- a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs +++ b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-sales-receipt", name: "Get Sales Receipt", - description: "Returns details about a sales receipt. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt#read-a-salesreceipt)", + description: "Returns details about a sales receipt. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt#read-a-salesreceipt)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs index 6b6ad07ffb380..756c4add8a764 100644 --- a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs +++ b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-get-time-activity", name: "Get Time Activity", - description: "Returns info about an activity. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#read-a-timeactivity-object)", + description: "Returns info about an activity. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#read-a-timeactivity-object)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs b/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs index 164006f4750d8..b58503cfed862 100644 --- a/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs +++ b/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-sandbox-search-invoices", name: "Search Invoices", - description: "Searches for invoices. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice)", + description: "Searches for invoices. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index ebee75f17be3b..d5c23a9ca2c4f 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-accounts", name: "Search Accounts", - description: "Search for accounts. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#query-an-account)", + description: "Search for accounts. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#query-an-account)", version: "0.2.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 2ec5f2752b675..3863f0a2792b8 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-customers", name: "Search Customers", - description: "Searches for customers. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#query-a-customer)", + description: "Searches for customers. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#query-a-customer)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index 1913190a94d4d..009489c4d628e 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-items", name: "Search Items", - description: "Searches for items. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", + description: "Searches for items. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index 6abe33fefa886..cbe25d9e6f3a7 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-products", name: "Search Products", - description: "Search for products. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", + description: "Search for products. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-query/search-query.mjs b/components/quickbooks/actions/search-query/search-query.mjs index 5515f8038650b..d54c48680cc60 100644 --- a/components/quickbooks/actions/search-query/search-query.mjs +++ b/components/quickbooks/actions/search-query/search-query.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-query", name: "Search Query", - description: "Performs a search query against a Quickbooks entity. [See docs here](https://developer.intuit.com/app/develophttps://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", + description: "Performs a search query against a Quickbooks entity. [See the documentation](https://developer.intuit.com/app/develophttps://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index 4f52319d3c300..0aa56d8c7e987 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-time-activities", name: "Search Time Activities", - description: "Searches for time activities. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#query-a-timeactivity-object)", + description: "Searches for time activities. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#query-a-timeactivity-object)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index 20e4752e1d35c..4d1edf2acc9f5 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-vendors", name: "Search Vendors", - description: "Searches for vendors. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendor#query-a-vendor)", + description: "Searches for vendors. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendor#query-a-vendor)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index 9495fc93a8d89..695e4eb636073 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -5,7 +5,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-sparse-update-invoice", name: "Sparse Update Invoice", - description: "Sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched. The ID of the object to update is specified in the request body.​ [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#sparse-update-an-invoice)", + description: "Sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched. The ID of the object to update is specified in the request body.​ [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#sparse-update-an-invoice)", version: "0.1.4", type: "action", props: { diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index ab971febe78df..76e03b2209653 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -4,7 +4,7 @@ import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-update-customer", name: "Update Customer", - description: "Updates a customer. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#full-update-a-customer)", + description: "Updates a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#full-update-a-customer)", version: "0.1.6", type: "action", props: { diff --git a/components/quickbooks/package.json b/components/quickbooks/package.json index b53bc5fa84355..8da0524464043 100644 --- a/components/quickbooks/package.json +++ b/components/quickbooks/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/quickbooks", - "version": "0.3.0", + "version": "0.3.1", "description": "Pipedream Quickbooks Components", "main": "quickbooks.app.mjs", "keywords": [ diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index 9f5c38b071291..c7618238da5cb 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -354,7 +354,11 @@ export default { _apiUrl() { return "https://quickbooks.api.intuit.com/v3"; }, - async _makeRequest(path, options = {}, $ = this) { + async _makeRequest({ + $ = this, + path, + ...opts + }) { const requestFn = async () => { return await axios($, { url: `${this._apiUrl()}/${path}`, @@ -362,159 +366,152 @@ export default { Authorization: `Bearer ${this._accessToken()}`, accept: "application/json", }, - ...options, + ...opts, }); }; return await retryWithExponentialBackoff(requestFn); }, - async createPayment({ - $, data, - }) { - return this._makeRequest(`company/${this._companyId()}/payment`, { + createPayment(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/payment`, method: "post", - data, - }, $); + ...opts, + }); }, - async createBill({ - $, data, params, - }) { - return this._makeRequest(`company/${this._companyId()}/bill`, { + createBill(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/bill`, method: "post", - data, - params, - }, $); + ...opts, + }); }, - async createCustomer({ - $, data, params, - }) { - return this._makeRequest(`company/${this._companyId()}/customer`, { + createCustomer(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/customer`, method: "post", - data, - params, - }, $); - }, - createPurchase({ - $, ...args - }) { - return this._makeRequest(`company/${this._companyId()}/purchase`, { - method: "POST", - ...args, - }, $); + ...opts, + }); }, - async createInvoice({ - $, data, params, - }) { - return this._makeRequest(`company/${this._companyId()}/invoice`, { + createPurchase(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/purchase`, method: "post", - data, - params, - }, $); - }, - async deletePurchase({ - $, ...args - }) { - return this._makeRequest(`company/${this._companyId()}/purchase`, { - method: "POST", - ...args, - }, $); + ...opts, + }); }, - async sparseUpdateInvoice({ - $, data, params, - }) { - return this._makeRequest(`company/${this._companyId()}/invoice`, { + createInvoice(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/invoice`, method: "post", - data, - params, - }, $); + ...opts, + }); }, - async getBill({ - $, billId, params, - }) { - return this._makeRequest(`company/${this._companyId()}/bill/${billId}`, { - params, - }, $); + deletePurchase(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/purchase`, + method: "post", + ...opts, + }); }, - async getCustomer({ - $, customerId, params, - }) { - return this._makeRequest(`company/${this._companyId()}/customer/${customerId}`, { - params, - }, $); + sparseUpdateInvoice(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/invoice`, + method: "post", + ...opts, + }); }, - async getInvoice({ - $, invoiceId, params, + getBill({ + billId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/invoice/${invoiceId}`, { - params, - }, $); + return this._makeRequest({ + path: `company/${this._companyId()}/bill/${billId}`, + ...opts, + }); }, - async getInvoices({ - $, params, + getCustomer({ + customerId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/query`, { - params, - }, $); + return this._makeRequest({ + path: `company/${this._companyId()}/customer/${customerId}`, + ...opts, + }); }, - async getMyCompany({ $ } = {}) { - return this._makeRequest(`company/${this._companyId()}/companyinfo/${this._companyId()}`, {}, $); - }, - async getPurchase({ - $, purchaseId, params, + getInvoice({ + invoiceId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/purchase/${purchaseId}`, { - params, - }, $); - }, - async getPurchaseOrder({ - $, purchaseOrderId, params, + return this._makeRequest({ + path: `company/${this._companyId()}/invoice/${invoiceId}`, + ...opts, + }); + }, + getInvoices(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/query`, + ...opts, + }); + }, + getMyCompany(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/companyinfo/${this._companyId()}`, + ...opts, + }); + }, + getPurchase({ + purchaseId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/purchaseorder/${purchaseOrderId}`, { - params, - }, $); + return this._makeRequest({ + path: `company/${this._companyId()}/purchase/${purchaseId}`, + ...opts, + }); }, - async getSalesReceipt({ - $, salesReceiptId, params, + getPurchaseOrder({ + purchaseOrderId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/salesreceipt/${salesReceiptId}`, { - params, - }, $); + return this._makeRequest({ + path: `company/${this._companyId()}/purchaseorder/${purchaseOrderId}`, + ...opts, + }); }, - async getTimeActivity({ - $, timeActivityId, params, + getSalesReceipt({ + salesReceiptId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/timeactivity/${timeActivityId}`, { - params, - }, $); + return this._makeRequest({ + path: `company/${this._companyId()}/salesreceipt/${salesReceiptId}`, + ...opts, + }); }, - async query({ - $, params, + getTimeActivity({ + timeActivityId, ...opts }) { - return this._makeRequest(`company/${this._companyId()}/query`, { - params, - }, $); - }, - async updateCustomer({ - $, data, params, - }) { - return this._makeRequest(`company/${this._companyId()}/customer`, { + return this._makeRequest({ + path: `company/${this._companyId()}/timeactivity/${timeActivityId}`, + ...opts, + }); + }, + query(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/query`, + ...opts, + }); + }, + updateCustomer(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/customer`, method: "post", - data, - params, - }, $); - }, - getApAgingReport({ - $, params, - }) { - return this._makeRequest(`company/${this._companyId()}/reports/AgedPayableDetail`, { - params, - }, $); - }, - getProfitLossReport({ - $, params, - }) { - return this._makeRequest(`company/${this._companyId()}/reports/ProfitAndLoss`, { - params, - }, $); + ...opts, + }); + }, + getApAgingReport(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/reports/AgedPayableDetail`, + ...opts, + }); + }, + getProfitLossReport(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/reports/ProfitAndLoss`, + ...opts, + }); }, async *paginate({ fn, params = {}, fieldList, query, maxResults = null, ...opts diff --git a/components/quickbooks/sources/common/base.mjs b/components/quickbooks/sources/common/base.mjs index 394ec76386496..4e1eec220dfbe 100644 --- a/components/quickbooks/sources/common/base.mjs +++ b/components/quickbooks/sources/common/base.mjs @@ -47,6 +47,18 @@ export default { }); } }, + getFieldDate() { + return "CreateTime"; + }, + getQuery() { + throw new Error("getQuery is not implemented"); + }, + getFieldList() { + throw new Error("getFieldList is not implemented"); + }, + getSummary() { + throw new Error("getSummary is not implemented"); + }, }, hooks: { async deploy() { diff --git a/components/quickbooks/sources/new-customer-created/new-customer-created.mjs b/components/quickbooks/sources/new-customer-created/new-customer-created.mjs index 1e4d533c14d38..9a8bb766a1aa3 100644 --- a/components/quickbooks/sources/new-customer-created/new-customer-created.mjs +++ b/components/quickbooks/sources/new-customer-created/new-customer-created.mjs @@ -17,11 +17,8 @@ export default { getFieldList() { return "Customer"; }, - getFieldDate() { - return "CreateTime"; - }, getSummary(item) { - return `New Customer: ${item.Id}`; + return `New Customer: ${item.DisplayName}`; }, }, sampleEmit, diff --git a/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs b/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs index 9525dbdd22ca2..84c4817515440 100644 --- a/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs +++ b/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs @@ -21,7 +21,7 @@ export default { return "LastUpdatedTime"; }, getSummary(item) { - return `New Customer Updated: ${item.Id}`; + return `New Customer Updated: ${item.DisplayName}`; }, }, sampleEmit, diff --git a/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs b/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs index b59049a23143b..d234c78995cc1 100644 --- a/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs +++ b/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs @@ -17,9 +17,6 @@ export default { getFieldList() { return "Invoice"; }, - getFieldDate() { - return "CreateTime"; - }, getSummary(item) { return `New Invoice: ${item.Id}`; }, diff --git a/components/quickbooks/sources/new-item-created/new-item-created.mjs b/components/quickbooks/sources/new-item-created/new-item-created.mjs index e0f890385281e..adcdf4db7d249 100644 --- a/components/quickbooks/sources/new-item-created/new-item-created.mjs +++ b/components/quickbooks/sources/new-item-created/new-item-created.mjs @@ -17,9 +17,6 @@ export default { getFieldList() { return "Item"; }, - getFieldDate() { - return "CreateTime"; - }, getSummary(item) { return `New Item: ${item.Id}`; }, From f7f3a1d2fe586aa457317ccb868a68a6cb6e0048 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 14:57:16 -0500 Subject: [PATCH 02/19] quickbooks_sandbox components --- .../search-invoices.mjs} | 2 +- .../search-services/search-services.mjs | 86 +++++ .../actions/update-item/update-item.mjs | 321 +++++++++++++++++ .../create-ap-aging-report.mjs | 22 ++ .../actions/create-bill/create-bill.mjs | 22 ++ .../create-customer/create-customer.mjs | 89 +---- .../actions/create-invoice/create-invoice.mjs | 85 +---- .../actions/create-payment/create-payment.mjs | 131 +------ .../create-pl-report/create-pl-report.mjs | 22 ++ .../create-purchase/create-purchase.mjs | 95 +---- .../create-sales-receipt.mjs | 22 ++ .../delete-purchase/delete-purchase.mjs | 22 ++ .../actions/get-bill/get-bill.mjs | 22 ++ .../actions/get-customer/get-customer.mjs | 53 +-- .../actions/get-invoice/get-invoice.mjs | 54 +-- .../actions/get-my-company/get-my-company.mjs | 22 ++ .../actions/get-payment/get-payment.mjs | 53 +-- .../get-purchase-order/get-purchase-order.mjs | 22 ++ .../actions/get-purchase/get-purchase.mjs | 22 ++ .../get-sales-receipt/get-sales-receipt.mjs | 22 ++ .../get-time-activity/get-time-activity.mjs | 22 ++ .../actions/search-account/search-account.mjs | 84 ----- .../search-accounts/search-accounts.mjs | 22 ++ .../search-customers/search-customers.mjs | 94 +---- .../search-invoices/search-invoices.mjs | 94 +---- .../actions/search-items/search-items.mjs | 22 ++ .../search-products/search-products.mjs | 22 ++ .../search-purchases/search-purchases.mjs | 22 ++ .../actions/search-query/search-query.mjs | 22 ++ .../search-services/search-services.mjs | 94 +---- .../search-time-activities.mjs | 22 ++ .../actions/search-vendors/search-vendors.mjs | 22 ++ .../sparse-update-invoice.mjs | 22 ++ .../update-customer/update-customer.mjs | 22 ++ .../actions/update-item/update-item.mjs | 329 +----------------- .../quickbooks_sandbox/common/utils.mjs | 40 +++ components/quickbooks_sandbox/package.json | 15 + .../quickbooks_sandbox.app.mjs | 10 +- .../new-customer-created.mjs | 22 ++ .../new-customer-updated.mjs | 22 ++ .../new-invoice-created.mjs | 22 ++ .../new-invoice-updated.mjs | 22 ++ .../new-item-created/new-item-created.mjs | 22 ++ .../new-item-updated/new-item-updated.mjs | 22 ++ 44 files changed, 1217 insertions(+), 1084 deletions(-) rename components/quickbooks/actions/{sandbox-search-invoices/sandbox-search-invoices.mjs => search-invoices/search-invoices.mjs} (98%) create mode 100644 components/quickbooks/actions/search-services/search-services.mjs create mode 100644 components/quickbooks/actions/update-item/update-item.mjs create mode 100644 components/quickbooks_sandbox/actions/create-ap-aging-report/create-ap-aging-report.mjs create mode 100644 components/quickbooks_sandbox/actions/create-bill/create-bill.mjs create mode 100644 components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs create mode 100644 components/quickbooks_sandbox/actions/create-sales-receipt/create-sales-receipt.mjs create mode 100644 components/quickbooks_sandbox/actions/delete-purchase/delete-purchase.mjs create mode 100644 components/quickbooks_sandbox/actions/get-bill/get-bill.mjs create mode 100644 components/quickbooks_sandbox/actions/get-my-company/get-my-company.mjs create mode 100644 components/quickbooks_sandbox/actions/get-purchase-order/get-purchase-order.mjs create mode 100644 components/quickbooks_sandbox/actions/get-purchase/get-purchase.mjs create mode 100644 components/quickbooks_sandbox/actions/get-sales-receipt/get-sales-receipt.mjs create mode 100644 components/quickbooks_sandbox/actions/get-time-activity/get-time-activity.mjs delete mode 100644 components/quickbooks_sandbox/actions/search-account/search-account.mjs create mode 100644 components/quickbooks_sandbox/actions/search-accounts/search-accounts.mjs create mode 100644 components/quickbooks_sandbox/actions/search-items/search-items.mjs create mode 100644 components/quickbooks_sandbox/actions/search-products/search-products.mjs create mode 100644 components/quickbooks_sandbox/actions/search-purchases/search-purchases.mjs create mode 100644 components/quickbooks_sandbox/actions/search-query/search-query.mjs create mode 100644 components/quickbooks_sandbox/actions/search-time-activities/search-time-activities.mjs create mode 100644 components/quickbooks_sandbox/actions/search-vendors/search-vendors.mjs create mode 100644 components/quickbooks_sandbox/actions/sparse-update-invoice/sparse-update-invoice.mjs create mode 100644 components/quickbooks_sandbox/actions/update-customer/update-customer.mjs create mode 100644 components/quickbooks_sandbox/common/utils.mjs create mode 100644 components/quickbooks_sandbox/package.json create mode 100644 components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs create mode 100644 components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs create mode 100644 components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs create mode 100644 components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs create mode 100644 components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs create mode 100644 components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs diff --git a/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs similarity index 98% rename from components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs rename to components/quickbooks/actions/search-invoices/search-invoices.mjs index b58503cfed862..850f55bbbfed7 100644 --- a/components/quickbooks/actions/sandbox-search-invoices/sandbox-search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -2,7 +2,7 @@ import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; export default { - key: "quickbooks-sandbox-search-invoices", + key: "quickbooks-search-invoices", name: "Search Invoices", description: "Searches for invoices. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice)", version: "0.1.6", diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs new file mode 100644 index 0000000000000..1d1360621a25f --- /dev/null +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -0,0 +1,86 @@ +import quickbooks from "../../quickbooks.app.mjs"; + +export default { + key: "quickbooks-search-services", + name: "Search Services", + description: "Search for services. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", + version: "0.0.1", + type: "action", + props: { + quickbooks, + includeClause: { + propDefinition: [ + quickbooks, + "includeClause", + ], + optional: false, + }, + whereClause: { + propDefinition: [ + quickbooks, + "whereClause", + ], + optional: false, + }, + orderClause: { + propDefinition: [ + quickbooks, + "orderClause", + ], + }, + startPosition: { + description: "The starting count of the response for pagination.", + label: "Start Position", + optional: true, + type: "string", + }, + maxResults: { + propDefinition: [ + quickbooks, + "maxResults", + ], + }, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], + }, + }, + async run({ $ }) { + if (!this.include_clause || !this.where_clause) { + throw new Error("Must provide include_clause, where_clause parameters."); + } + + var orderClause = ""; + if (this.order_clause) { + orderClause = ` ORDERBY ${this.order_clause}`; + } + + var startPosition = ""; + if (this.start_position) { + startPosition = ` STARTPOSITION ${this.start_position}`; + } + + var maxResults = ""; + if (this.max_results) { + maxResults = ` MAXRESULTS ${this.max_results}` || ""; + } + + const query = `select ${this.include_clause} from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; + + const response = await this.quickbooks.query({ + $, + params: { + minorversion: this.minorVersion, + query, + }, + }); + + if (response) { + $.export("summary", "Successfully retrieved services"); + } + + return response; + }, +}; diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs new file mode 100644 index 0000000000000..d21b0a0cd6ae1 --- /dev/null +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -0,0 +1,321 @@ +import quickbooks from "../../quickbooks.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "quickbooks_sandbox-update-item", + name: "Update Item", + description: "Updates an item.", + version: "0.0.1", + type: "action", + props: { + quickbooks, + item_id: { + type: "string", + description: "Id of the item to update.", + }, + name: { + type: "string", + description: "Name of the item. This value must be unique.", + }, + sync_token: { + type: "string", + description: "Version number of the entity. Required for the update operation.", + }, + track_qty_on_hand: { + type: "boolean", + description: "True if there is quantity on hand to be tracked. Once this value is true, it cannot be updated to false. Applicable for items of type `Inventory`. Not applicable for `Service` or `NonInventory` item types.", + }, + sparse_update: { + type: "string", + description: "When set to `true`, sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched.", + }, + qty_on_hand: { + type: "string", + description: "Current quantity of the `Inventory` items available for sale. Not used for `Service` or `NonInventory` type items. Required for `Inventory` type items.", + optional: true, + }, + income_account_ref_value: { + type: "string", + description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `IncomeAccountRef.value`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", + optional: true, + }, + income_account_ref_name: { + type: "string", + description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `IncomeAccountRef.name`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", + optional: true, + }, + type: { + type: "string", + description: "Classification that specifies the use of this item. See the description at the top of the [Item entity page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item) for details about supported item types. See specifications for the type parameter in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", + optional: true, + options: [ + "Inventory", + "Group", + "Service", + "NonInventory", + ], + }, + asset_account_ref_value: { + type: "string", + description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `AssetAccountRef.value`.", + optional: true, + }, + asset_account_ref_name: { + type: "string", + description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `AssetAccountRef.name`.", + optional: true, + }, + inv_start_date: { + type: "string", + description: "Date of opening balance for the inventory transaction. Required when creating an `Item.Type=Inventory`. Required for `Inventory` item types.", + optional: true, + }, + expense_account_ref_value: { + type: "string", + description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `ExpenseAccountRef.value`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", + optional: true, + }, + expense_account_ref_name: { + type: "string", + description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `ExpenseAccountRef.name`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", + optional: true, + }, + Sku: { + type: "string", + description: "The stock keeping unit (SKU) for this Item. This is a company-defined identifier for an item or product used in tracking inventory.", + optional: true, + }, + sales_tax_included: { + type: "string", + description: "True if the sales tax is included in the item amount, and therefore is not calculated for the transaction.", + optional: true, + }, + sales_tax_code_ref_value: { + type: "string", + description: "Id of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `SalesTaxCodeRef.value`.", + optional: true, + }, + sales_tax_code_ref_name: { + type: "string", + description: "Name of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `SalesTaxCodeRef.name`.", + optional: true, + }, + class_ref_value: { + type: "string", + description: "Id of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", + optional: true, + }, + class_ref_name: { + type: "string", + description: "Name of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Name` from that object for `ClassRef.name`.", + optional: true, + }, + purchase_tax_tncluded: { + type: "boolean", + description: "True if the purchase tax is included in the item amount, and therefore is not calculated for the transaction.", + optional: true, + }, + description: { + type: "string", + description: "Description of the item.", + optional: true, + }, + abatement_rate: { + type: "string", + description: "Sales tax abatement rate for India locales.", + optional: true, + }, + reverse_charge_rate: { + type: "string", + description: "Sales tax reverse charge rate for India locales.", + optional: true, + }, + sub_item: { + type: "boolean", + description: "If true, this is a sub item. If false or null, this is a top-level item. Creating inventory hierarchies with traditional inventory items is being phased out in lieu of using categories and sub categories.", + optional: true, + }, + taxable: { + type: "boolean", + description: "If true, transactions for this item are taxable. Applicable to US companies, only.", + optional: true, + }, + UQC_display_text: { + type: "string", + description: "Text to be displayed on customer's invoice to denote the Unit of Measure (instead of the standard code).", + optional: true, + }, + reorder_point: { + type: "string", + description: "The minimum quantity of a particular inventory item that you need to restock at any given time. The ReorderPoint value cannot be set to null for sparse updates(sparse=true). It can be set to null only for full updates.", + optional: true, + }, + purchase_desc: { + type: "string", + description: "Purchase description for the item.", + optional: true, + }, + pref_vendor_ref_value: { + type: "string", + optional: true, + }, + pref_vendor_ref_name: { + type: "string", + optional: true, + }, + active: { + type: "boolean", + description: "If true, the object is currently enabled for use by QuickBooks.", + optional: true, + }, + UQC_id: { + type: "string", + description: "Id of Standard Unit of Measure (UQC:Unique Quantity Code) of the item according to GST rule.", + optional: true, + }, + purchase_tax_code_ref_value: { + type: "string", + description: "The ID for the referenced purchase tax code object as found in the Id field of the object payload. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `PurchaseTaxCodeRef.value`.", + optional: true, + }, + purchase_tax_code_ref_name: { + type: "string", + description: "An identifying name for the purchase tax code object being referenced by value and is derived from the field that holds the common name of that object. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `PurchaseTaxCodeRef.name`.", + optional: true, + }, + service_type: { + type: "string", + description: "Sales tax service type for India locales.", + optional: true, + }, + purchase_cost: { + type: "string", + description: "Amount paid when buying or ordering the item, as expressed in the home currency.", + optional: true, + }, + unit_price: { + type: "string", + description: "Corresponds to the Price/Rate column on the QuickBooks Online UI to specify either unit price, a discount, or a tax rate for item. If used for unit price, the monetary value of the service or product, as expressed in the home currency. If used for a discount or tax rate, express the percentage as a fraction. For example, specify `0.4` for 40% tax", + optional: true, + }, + tax_classification_ref_value: { + type: "string", + description: "The ID for the referenced Tax classification object as found in the Id field of the object payload.\n\nTax classification segregates different items into different classifications and the tax classification is one of the key parameters to determine appropriate tax on transactions involving items. Tax classifications are sourced by either tax governing authorities as in India/Malaysia or externally like Exactor. 'Fuel', 'Garments' and 'Soft drinks' are a few examples of tax classification in layman terms. User can choose a specific tax classification for an item while creating it. A level 1 tax classification cannot be associated to an Item", + optional: true, + }, + tax_classification_ref_name: { + type: "string", + description: "An identifying name for the Tax classification object being referenced by value and is derived from the field that holds the common name of that object.", + optional: true, + }, + parent_ref_name: { + type: "string", + description: "An identifying name for the parent item object being referenced by `value` and is derived from the field that holds the common name of that object.\n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", + optional: true, + }, + parent_ref_value: { + type: "string", + description: "The ID for the referenced parent item object as found in the Id field of the object payload. \n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", + optional: true, + }, + minorversion: { + type: "string", + description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", + optional: true, + }, + }, + async run({ $ }) { + //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#full-update-an-item + + if (!this.item_id + || !this.name + || !this.sync_token + || this.track_qty_on_hand === undefined + || this.sparse_update === undefined + ) { + throw new Error("Must provide item_id, name, sync_token, and track_qty_on_hand parameters."); + } + + //Prepares the request body + var data = { + sparse: this.sparse_update, + Id: this.item_id, + Name: this.name, + QtyOnHand: this.qty_on_hand, + SyncToken: this.sync_token, + IncomeAccountRef: { + value: this.income_account_ref_value, + name: this.income_account_ref_name, + }, + Type: this.type, + AssetAccountRef: { + value: this.asset_account_ref_value, + name: this.asset_account_ref_name, + }, + InvStartDate: this.inv_start_date, + ExpenseAccountRef: { + value: this.expense_account_ref_value, + name: this.expense_account_ref_name, + }, + Sku: this.Sku, + SalesTaxIncluded: this.sales_tax_included, + TrackQtyOnHand: this.track_qty_on_hand, + SalesTaxCodeRef: { + value: this.sales_tax_code_ref_value, + name: this.sales_tax_code_ref_name, + }, + ClassRef: { + value: this.class_ref_value, + name: this.class_ref_name, + }, + PurchaseTaxIncluded: this.purchase_tax_tncluded, + Description: this.description, + AbatementRate: this.abatement_rate, + ReverseChargeRate: this.reverse_charge_rate, + SubItem: this.sub_item, + Taxable: this.taxable, + UQCDisplayText: this.UQC_display_text, + ReorderPoint: this.reorder_point, + PurchaseDesc: this.purchase_desc, + PrefVendorRef: { + value: this.pref_vendor_ref_value, + name: this.pref_vendor_ref_name, + }, + Active: this.active, + UQCId: this.UQC_id, + PurchaseTaxCodeRef: { + value: this.purchase_tax_code_ref_value, + name: this.purchase_tax_code_ref_name, + }, + ServiceType: this.service_type, + PurchaseCost: this.purchase_cost, + UnitPrice: this.unit_price, + TaxClassificationRef: { + value: this.tax_classification_ref_value, + name: this.tax_classification_ref_name, + }, + }; + + if (this.pref_vendor_ref_value || this.parent_ref_name) { + data["ParentRef"] = { + value: this.parent_ref_value, + name: this.parent_ref_name, + }; + } + + //Sends the request against Quickbooks Sandbox API + return await axios($, { + method: "post", + url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/item`, + headers: { + "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, + "accept": "application/json", + "content-type": "application/json", + }, + data, + params: { + minorversion: this.minorversion, + }, + }); + }, +}; diff --git a/components/quickbooks_sandbox/actions/create-ap-aging-report/create-ap-aging-report.mjs b/components/quickbooks_sandbox/actions/create-ap-aging-report/create-ap-aging-report.mjs new file mode 100644 index 0000000000000..6f5de002f4a93 --- /dev/null +++ b/components/quickbooks_sandbox/actions/create-ap-aging-report/create-ap-aging-report.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-ap-aging-report/create-ap-aging-report.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-create-ap-aging-report", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/create-bill/create-bill.mjs b/components/quickbooks_sandbox/actions/create-bill/create-bill.mjs new file mode 100644 index 0000000000000..278dc219fd4b3 --- /dev/null +++ b/components/quickbooks_sandbox/actions/create-bill/create-bill.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-bill/create-bill.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-create-bill", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/create-customer/create-customer.mjs b/components/quickbooks_sandbox/actions/create-customer/create-customer.mjs index 4779837b795b2..2b7db24c57ba2 100644 --- a/components/quickbooks_sandbox/actions/create-customer/create-customer.mjs +++ b/components/quickbooks_sandbox/actions/create-customer/create-customer.mjs @@ -1,79 +1,22 @@ -// legacy_hash_id: a_EVi7zr -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-customer/create-customer.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-create-customer", - name: "Create Customer", - description: "Creates a customer.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - display_name: { - type: "string", - description: "The name of the person or organization as displayed. Must be unique across all Customer, Vendor, and Employee objects. Cannot be removed with sparse update. If not supplied, the system generates DisplayName by concatenating customer name components supplied in the request from the following list: `Title`, `GivenName`, `MiddleName`, `FamilyName`, and `Suffix`.", - optional: true, - }, - title: { - type: "string", - description: "Title of the person. This tag supports i18n, all locales. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, `Suffix`, or `FullyQualifiedName` attributes are required during create.", - optional: true, - }, - given_name: { - type: "string", - description: "Given name or first name of a person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - middle_name: { - type: "string", - description: "Middle name of the person. The person can have zero or more middle names. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - family_name: { - type: "string", - description: "Family name or the last name of the person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - suffix: { - type: "string", - description: "Suffix of the name. For example, `Jr`. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer - - if (!this.display_name && (!this.title && !this.given_name && !this.middle_name && !this.family_name && !this.suffix)) { - throw new Error("Must provide display_name or at least one of title, given_name, middle_name, family_name, or suffix parameters."); - } - - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/customer`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - data: { - DisplayName: this.display_name, - Suffix: this.suffix, - Title: this.title, - MiddleName: this.middle_name, - FamilyName: this.family_name, - GivenName: this.given_name, - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/create-invoice/create-invoice.mjs b/components/quickbooks_sandbox/actions/create-invoice/create-invoice.mjs index 8cb1799149c6c..dc3bf7e98cb1a 100644 --- a/components/quickbooks_sandbox/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks_sandbox/actions/create-invoice/create-invoice.mjs @@ -1,75 +1,22 @@ -// legacy_hash_id: a_gniWe7 -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-invoice/create-invoice.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-create-invoice", - name: "Create Invoice", - description: "Creates an invoice.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - line_items: { - type: "any", - description: "The minimum line item required for the request is one of the following: \n* `SalesItemLine` type\n* `GroupLine` type\nand Inline subtotal using `DescriptionOnlyLine`", - }, - customer_ref_value: { - type: "string", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.Id` from that object for `CustomerRef.value`.", - }, - customer_ref_name: { - type: "string", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.DisplayName ` from that object for `CustomerRef.name`.", - optional: true, - }, - currency_ref_value: { - type: "string", - description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", - optional: true, - }, - currency_ref_name: { - type: "object", - description: "The full name of the currency.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - // See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice - - if (!this.line_items || !this.customer_ref_value) { - throw new Error("Must provide line_items, and customer_ref_value parameters."); - } - - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/invoice`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - data: { - Line: this.line_items, - CustomerRef: { - value: this.customer_ref_value, - name: this.customer_ref_name, - }, - CurrencyRef: { - value: this.currency_ref_value, - name: this.currency_ref_name, - }, - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/create-payment/create-payment.mjs b/components/quickbooks_sandbox/actions/create-payment/create-payment.mjs index 0f646fd99888c..9c3438cbe3f7d 100644 --- a/components/quickbooks_sandbox/actions/create-payment/create-payment.mjs +++ b/components/quickbooks_sandbox/actions/create-payment/create-payment.mjs @@ -1,121 +1,22 @@ -// legacy_hash_id: a_l0i8d0 -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-payment/create-payment.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-create-payment", - name: "Create Bill Payment", - description: "Creates a bill payment.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - total_amt: { - type: "string", - description: "Indicates the total amount of the associated with this payment. This includes the total of all the payments from the BillPayment Details.", - }, - vendor_ref_value: { - type: "string", - description: "The id of the vendor reference for this transaction.", - }, - line: { - type: "any", - description: "Individual line items representing zero or more `Bill`, `VendorCredit`, and `JournalEntry` objects linked to this BillPayment object.. Valid Line type for create: `LinkedTxnLine`.", - }, - pay_type: { - type: "string", - description: "The payment type. Valid values include: `Check`, `CreditCard`", - options: [ - "Check", - "CreditCard", - ], - }, - vendor_ref_name: { - type: "string", - description: "The name of the vendor reference for this transaction.", - optional: true, - }, - currency_ref_value: { - type: "string", - description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", - optional: true, - }, - currency_ref_name: { - type: "object", - description: "The full name of the currency.", - optional: true, - }, - cc_account_ref_value: { - type: "string", - description: "The id of the credit card account reference. Required when `PayType` is `CreditCard`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `CCAccountRef.value`. The specified account must have `Account.AccountType` set to `Credit Card` and `Account.AccountSubType` set to `CreditCard`. Inject with data only if the payment was transacted through Intuit Payments API.", - optional: true, - }, - cc_account_ref_name: { - type: "string", - description: "The name of the credit card account reference. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `CCAccountRef.name`. The specified account must have `Account.AccountType` set to `Credit Card` and `Account.AccountSubType` set to `CreditCard`. Inject with data only if the payment was transacted through Intuit Payments API.", - optional: true, - }, - bank_account_ref_value: { - type: "string", - description: "The id of the bank account reference. Required when `PayType` is `Check`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `APAccountRef.value`. The specified account must have `Account.AccountType` set to `Bank` and `Account.AccountSubType` set to `Checking`.", - optional: true, - }, - bank_account_ref_name: { - type: "string", - description: "The name of the bank account reference. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `APAccountRef.name`. The specified account must have `Account.AccountType` set to `Bank` and `Account.AccountSubType` set to `Checking`.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - // See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/billpayment#create-a-billpayment - - if (!this.total_amt || !this.vendor_ref_value || !this.line || !this.pay_type) { - throw new Error("Must provide total_amt, and vendor_ref_value, line, and pay_type parameters."); - } - - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/billpayment`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - data: { - TotalAmt: this.total_amt, - VendorRef: { - value: this.vendor_ref_value, - name: this.vendor_ref_name, - }, - Line: this.line, - PayType: this.pay_type, - CurrencyRef: { - value: this.currency_ref_value, - name: this.currency_ref_name, - }, - CreditCardPayment: { - CCAccountRef: { - value: this.cc_account_ref_value, - name: this.cc_account_ref_name, - }, - }, - CheckPayment: { - BankAccountRef: { - value: this.bank_account_ref_value, - name: this.bank_account_ref_name, - }, - }, - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs b/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs new file mode 100644 index 0000000000000..b9c67c97dcdfd --- /dev/null +++ b/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-plreport/create-pl-report.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-create-pl-report", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/create-purchase/create-purchase.mjs b/components/quickbooks_sandbox/actions/create-purchase/create-purchase.mjs index 4f13c5ace47bb..ca97c9733ddb1 100644 --- a/components/quickbooks_sandbox/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks_sandbox/actions/create-purchase/create-purchase.mjs @@ -1,85 +1,22 @@ -// legacy_hash_id: a_G1iL4w -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-purchase/create-purchase.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-create-purchase", - name: "Create Purchase", - description: "Creates a purchase.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - line_items: { - type: "any", - description: "Individual line items of a transaction. Valid `Line` type for create: `AccountBasedExpenseLine`", - }, - account_ref_value: { - type: "string", - description: "Specifies the id of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", - }, - payment_type: { - type: "string", - description: "Payment Type can be: `Cash`, `Check`, or `CreditCard`.", - options: [ - "Cash", - "Check", - "CreditCard", - ], - }, - account_ref_name: { - type: "string", - description: "Specifies the name of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", - optional: true, - }, - currency_ref_value: { - type: "string", - description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", - optional: true, - }, - currency_ref_name: { - type: "object", - description: "The full name of the currency.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - // See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice - - if (!this.line_items || !this.account_ref_value) { - throw new Error("Must provide line_items, and account_ref_value parameters."); - } - - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/purchase`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - data: { - PaymentType: this.payment_type, - AccountRef: { - value: this.account_ref_value, - name: this.account_ref_name, - }, - Line: this.line_items, - CurrencyRef: { - value: this.currency_ref_value, - name: this.currency_ref_name, - }, - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/create-sales-receipt/create-sales-receipt.mjs b/components/quickbooks_sandbox/actions/create-sales-receipt/create-sales-receipt.mjs new file mode 100644 index 0000000000000..8ecbf839fc88d --- /dev/null +++ b/components/quickbooks_sandbox/actions/create-sales-receipt/create-sales-receipt.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-create-sales-receipt", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks_sandbox/actions/delete-purchase/delete-purchase.mjs new file mode 100644 index 0000000000000..19889ba472539 --- /dev/null +++ b/components/quickbooks_sandbox/actions/delete-purchase/delete-purchase.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/delete-purchase/delete-purchase.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-delete-purchase", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-bill/get-bill.mjs b/components/quickbooks_sandbox/actions/get-bill/get-bill.mjs new file mode 100644 index 0000000000000..1912d8f4a7be7 --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-bill/get-bill.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-bill/get-bill.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-bill", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-customer/get-customer.mjs b/components/quickbooks_sandbox/actions/get-customer/get-customer.mjs index 2ddb78c66ed88..d8a04334d786d 100644 --- a/components/quickbooks_sandbox/actions/get-customer/get-customer.mjs +++ b/components/quickbooks_sandbox/actions/get-customer/get-customer.mjs @@ -1,43 +1,22 @@ -// legacy_hash_id: a_vgidgN -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-customer/get-customer.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-get-customer", - name: "Get Customer", - description: "Returns info about a customer.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - customer_id: { - type: "string", - description: "Id of the customer to get details of.", - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - // See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer#read-a-customer - - if (!this.customer_id) { - throw new Error("Must provide customer_id parameter."); - } - - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/customer/${this.customer_id}`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "content-type": "application/json", - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/get-invoice/get-invoice.mjs b/components/quickbooks_sandbox/actions/get-invoice/get-invoice.mjs index 8cfca67a443da..f33101f947369 100644 --- a/components/quickbooks_sandbox/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks_sandbox/actions/get-invoice/get-invoice.mjs @@ -1,44 +1,22 @@ -// legacy_hash_id: a_Q3ix1Q -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-invoice/get-invoice.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-get-invoice", - name: "Get Invoice", - description: "Returns info about an invoice.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - invoice_id: { - type: "string", - description: "Id of the invoice to get details of.", - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - // See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#read-an-invoice - - if (!this.invoice_id) { - throw new Error("Must provide invoice_id parameter."); - } - - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/invoice/${this.invoice_id}`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/get-my-company/get-my-company.mjs b/components/quickbooks_sandbox/actions/get-my-company/get-my-company.mjs new file mode 100644 index 0000000000000..b3c8b48513066 --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-my-company/get-my-company.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-my-company/get-my-company.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-my-company", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-payment/get-payment.mjs b/components/quickbooks_sandbox/actions/get-payment/get-payment.mjs index a57162263dff3..c64c8cd24a3ad 100644 --- a/components/quickbooks_sandbox/actions/get-payment/get-payment.mjs +++ b/components/quickbooks_sandbox/actions/get-payment/get-payment.mjs @@ -1,43 +1,22 @@ -// legacy_hash_id: a_0Mi7LY -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-payment/get-payment.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-get-payment", - name: "Get Payment", - description: "Returns info about a payment.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - payment_id: { - type: "string", - description: "Id of the item to get details of.", - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#read-a-payment - - if (!this.payment_id) { - throw new Error("Must provide payment_id parameter."); - } - - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/payment/${this.payment_id}`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "content-type": "application/json", - }, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks_sandbox/actions/get-purchase-order/get-purchase-order.mjs new file mode 100644 index 0000000000000..0473c476e2149 --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-purchase-order/get-purchase-order.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-purchase-order/get-purchase-order.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-purchase-order", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-purchase/get-purchase.mjs b/components/quickbooks_sandbox/actions/get-purchase/get-purchase.mjs new file mode 100644 index 0000000000000..9af7bfe745148 --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-purchase/get-purchase.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-purchase/get-purchase.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-purchase", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks_sandbox/actions/get-sales-receipt/get-sales-receipt.mjs new file mode 100644 index 0000000000000..adeb14ae7714a --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-sales-receipt/get-sales-receipt.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-sales-receipt", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks_sandbox/actions/get-time-activity/get-time-activity.mjs new file mode 100644 index 0000000000000..5235e9ded1dbf --- /dev/null +++ b/components/quickbooks_sandbox/actions/get-time-activity/get-time-activity.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/get-time-activity/get-time-activity.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-get-time-activity", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-account/search-account.mjs b/components/quickbooks_sandbox/actions/search-account/search-account.mjs deleted file mode 100644 index fcad08115820f..0000000000000 --- a/components/quickbooks_sandbox/actions/search-account/search-account.mjs +++ /dev/null @@ -1,84 +0,0 @@ -// legacy_hash_id: a_vgid15 -import { axios } from "@pipedream/platform"; - -export default { - key: "quickbooks_sandbox-search-account", - name: "Search Account", - description: "Searches for accounts.", - version: "0.1.1", - type: "action", - props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - include_clause: { - type: "string", - description: "Fields to use in the include clause of the Account data query. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - }, - where_clause: { - type: "string", - description: "Filters to use in the where clause of the Account data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", - }, - order_clause: { - type: "string", - description: "The `order_clause` is for sorting the result. Include the Account property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", - optional: true, - }, - start_position: { - type: "string", - description: "The starting count of the response for pagination.", - optional: true, - }, - max_results: { - type: "string", - description: "The number of Account entity elements in the response.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#query-an-account - - if (!this.include_clause || !this.where_clause) { - throw new Error("Must provide include_clause, where_clause parameters."); - } - - //Prepares OrderBy clause,start position, max results parameters to be used in the request's query parameter. - var orderClause = ""; - if (this.order_clause) { - orderClause = ` ORDERBY ${this.order_clause}`; - } - - var startPosition = ""; - if (this.start_position) { - startPosition = ` STARTPOSITION ${this.start_position}`; - } - - var maxResults = ""; - if (this.max_results) { - maxResults = ` MAXRESULTS ${this.max_results}` || ""; - } - - //Prepares the request's query parameter - const query = `select ${this.include_clause} from Account where ${this.where_clause}${orderClause}${startPosition}${maxResults}`; - - //Sends the request against Quickbooks API - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/query`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/octet-stream", - }, - params: { - minorversion: this.minorversion, - query, - }, - }); - }, -}; diff --git a/components/quickbooks_sandbox/actions/search-accounts/search-accounts.mjs b/components/quickbooks_sandbox/actions/search-accounts/search-accounts.mjs new file mode 100644 index 0000000000000..35ce9c2e8f18e --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-accounts/search-accounts.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-accounts/search-accounts.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-accounts", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-customers/search-customers.mjs b/components/quickbooks_sandbox/actions/search-customers/search-customers.mjs index b4d284cbbe780..b733d1dd9cceb 100644 --- a/components/quickbooks_sandbox/actions/search-customers/search-customers.mjs +++ b/components/quickbooks_sandbox/actions/search-customers/search-customers.mjs @@ -1,84 +1,22 @@ -// legacy_hash_id: a_Xzi4P0 -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-customers/search-customers.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-search-customers", - name: "Search Customers", - description: "Searches for customers.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - include_clause: { - type: "string", - description: "Fields to use in the select clause of the Customer data query. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - }, - where_clause: { - type: "string", - description: "Filters to use in the where clause of the Customer data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", - }, - order_clause: { - type: "string", - description: "The `order_clause` is for sorting the result. Include the Customer property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", - optional: true, - }, - start_position: { - type: "string", - description: "The starting count of the response for pagination.", - optional: true, - }, - max_results: { - type: "string", - description: "The number of Customer entity elements in the response.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#query-a-customer - - if (!this.include_clause || !this.where_clause) { - throw new Error("Must provide include_clause, where_clause parameters."); - } - - //Prepares OrderBy clause,start position, max results parameters to be used in the request's query parameter. - var orderClause = ""; - if (this.order_clause) { - orderClause = ` ORDERBY ${this.order_clause}`; - } - - var startPosition = ""; - if (this.start_position) { - startPosition = ` STARTPOSITION ${this.start_position}`; - } - - var maxResults = ""; - if (this.max_results) { - maxResults = ` MAXRESULTS ${this.max_results}` || ""; - } - - //Prepares the request's query parameter - const query = `select ${this.include_clause} from Customer where ${this.where_clause}${orderClause}${startPosition}${maxResults}`; - - //Sends the request against Quickbooks API - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/query`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/octet-stream", - }, - params: { - minorversion: this.minorversion, - query, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/search-invoices/search-invoices.mjs b/components/quickbooks_sandbox/actions/search-invoices/search-invoices.mjs index 80e92dc14c889..183f735d93880 100644 --- a/components/quickbooks_sandbox/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks_sandbox/actions/search-invoices/search-invoices.mjs @@ -1,84 +1,22 @@ -// legacy_hash_id: a_1Wi7KO -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-invoices/search-invoices.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-search-invoices", - name: "Search Invoices", - description: "Searches for invoices.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - include_clause: { - type: "string", - description: "Fields to use in the select clause of the Invoice data query. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - }, - where_clause: { - type: "string", - description: "Filters to use in the where clause of the Invoice data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", - }, - order_clause: { - type: "string", - description: "The `order_clause` is for sorting the result. Include the Invoice property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", - optional: true, - }, - start_position: { - type: "string", - description: "The starting count of the response for pagination.", - optional: true, - }, - max_results: { - type: "string", - description: "The number of Invoice entity elements in the response.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice - - if (!this.include_clause || !this.where_clause) { - throw new Error("Must provide include_clause, where_clause parameters."); - } - - //Prepares OrderBy clause,start position, max results parameters to be used in the request's query parameter. - var orderClause = ""; - if (this.order_clause) { - orderClause = ` ORDERBY ${this.order_clause}`; - } - - var startPosition = ""; - if (this.start_position) { - startPosition = ` STARTPOSITION ${this.start_position}`; - } - - var maxResults = ""; - if (this.max_results) { - maxResults = ` MAXRESULTS ${this.max_results}` || ""; - } - - //Prepares the request's query parameter - const query = `select ${this.include_clause} from Invoice where ${this.where_clause}${orderClause}${startPosition}${maxResults}`; - - //Sends the request against Quickbooks API - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/query`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/octet-stream", - }, - params: { - minorversion: this.minorversion, - query, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/search-items/search-items.mjs b/components/quickbooks_sandbox/actions/search-items/search-items.mjs new file mode 100644 index 0000000000000..7d7954938e36f --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-items/search-items.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-items/search-items.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-items", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-products/search-products.mjs b/components/quickbooks_sandbox/actions/search-products/search-products.mjs new file mode 100644 index 0000000000000..2ac05d85ff936 --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-products/search-products.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-products/search-products.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-products", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-purchases/search-purchases.mjs b/components/quickbooks_sandbox/actions/search-purchases/search-purchases.mjs new file mode 100644 index 0000000000000..134da0ebf300d --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-purchases/search-purchases.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-purchases/search-purchases.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-purchases", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-query/search-query.mjs b/components/quickbooks_sandbox/actions/search-query/search-query.mjs new file mode 100644 index 0000000000000..bfaab5e46f91c --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-query/search-query.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-query/search-query.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-query", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-services/search-services.mjs b/components/quickbooks_sandbox/actions/search-services/search-services.mjs index e5d765df8f20e..a1a78dbca5d1f 100644 --- a/components/quickbooks_sandbox/actions/search-services/search-services.mjs +++ b/components/quickbooks_sandbox/actions/search-services/search-services.mjs @@ -1,84 +1,22 @@ -// legacy_hash_id: a_B0i8lr -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-services/search-services.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-search-services", - name: "Search Services", - description: "Search for services.", - version: "0.1.1", - type: "action", + version: "0.1.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - include_clause: { - type: "string", - description: "Fields to use in the select clause of the Item data query. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - }, - where_clause: { - type: "string", - description: "Filters to use in the where clause of the Item data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", - }, - order_clause: { - type: "string", - description: "The `order_clause` is for sorting the result. Include the Item property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", - optional: true, - }, - start_position: { - type: "string", - description: "The starting count of the response for pagination.", - optional: true, - }, - max_results: { - type: "string", - description: "The number of Item entity elements in the response.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item - - if (!this.include_clause || !this.where_clause) { - throw new Error("Must provide include_clause, where_clause parameters."); - } - - //Prepares OrderBy clause,start position, max results parameters to be used in the request's query parameter. - var orderClause = ""; - if (this.order_clause) { - orderClause = ` ORDERBY ${this.order_clause}`; - } - - var startPosition = ""; - if (this.start_position) { - startPosition = ` STARTPOSITION ${this.start_position}`; - } - - var maxResults = ""; - if (this.max_results) { - maxResults = ` MAXRESULTS ${this.max_results}` || ""; - } - - //Prepares the request's query parameter - const query = `select ${this.include_clause} from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; - - //Sends the request against Quickbooks API - return await axios($, { - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/query`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/octet-stream", - }, - params: { - minorversion: this.minorversion, - query, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks_sandbox/actions/search-time-activities/search-time-activities.mjs new file mode 100644 index 0000000000000..6ce38b1dfc640 --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-time-activities/search-time-activities.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-time-activities/search-time-activities.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-time-activities", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/search-vendors/search-vendors.mjs b/components/quickbooks_sandbox/actions/search-vendors/search-vendors.mjs new file mode 100644 index 0000000000000..08c22b3f82236 --- /dev/null +++ b/components/quickbooks_sandbox/actions/search-vendors/search-vendors.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/search-vendors/search-vendors.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-search-vendors", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks_sandbox/actions/sparse-update-invoice/sparse-update-invoice.mjs new file mode 100644 index 0000000000000..e35de29d7e9ab --- /dev/null +++ b/components/quickbooks_sandbox/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-sparse-update-invoice", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/update-customer/update-customer.mjs b/components/quickbooks_sandbox/actions/update-customer/update-customer.mjs new file mode 100644 index 0000000000000..03bb9b39bc6e1 --- /dev/null +++ b/components/quickbooks_sandbox/actions/update-customer/update-customer.mjs @@ -0,0 +1,22 @@ +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/update-customer/update-customer.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-update-customer", + version: "0.0.1", + name, + description, + type, + props: { + quickbooks: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/actions/update-item/update-item.mjs b/components/quickbooks_sandbox/actions/update-item/update-item.mjs index 20ed4528da3aa..1837b6a17c70c 100644 --- a/components/quickbooks_sandbox/actions/update-item/update-item.mjs +++ b/components/quickbooks_sandbox/actions/update-item/update-item.mjs @@ -1,319 +1,22 @@ -// legacy_hash_id: a_bKil4n -import { axios } from "@pipedream/platform"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/actions/update-item/update-item.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); export default { + ...others, key: "quickbooks_sandbox-update-item", - name: "Update Item", - description: "Updates an item.", - version: "0.2.1", - type: "action", + version: "0.2.2", + name, + description, + type, props: { - quickbooks_sandbox: { - type: "app", - app: "quickbooks_sandbox", - }, - item_id: { - type: "string", - description: "Id of the item to update.", - }, - name: { - type: "string", - description: "Name of the item. This value must be unique.", - }, - sync_token: { - type: "string", - description: "Version number of the entity. Required for the update operation.", - }, - track_qty_on_hand: { - type: "boolean", - description: "True if there is quantity on hand to be tracked. Once this value is true, it cannot be updated to false. Applicable for items of type `Inventory`. Not applicable for `Service` or `NonInventory` item types.", - }, - sparse_update: { - type: "string", - description: "When set to `true`, sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched.", - }, - qty_on_hand: { - type: "string", - description: "Current quantity of the `Inventory` items available for sale. Not used for `Service` or `NonInventory` type items. Required for `Inventory` type items.", - optional: true, - }, - income_account_ref_value: { - type: "string", - description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `IncomeAccountRef.value`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - income_account_ref_name: { - type: "string", - description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `IncomeAccountRef.name`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - type: { - type: "string", - description: "Classification that specifies the use of this item. See the description at the top of the [Item entity page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item) for details about supported item types. See specifications for the type parameter in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - options: [ - "Inventory", - "Group", - "Service", - "NonInventory", - ], - }, - asset_account_ref_value: { - type: "string", - description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `AssetAccountRef.value`.", - optional: true, - }, - asset_account_ref_name: { - type: "string", - description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `AssetAccountRef.name`.", - optional: true, - }, - inv_start_date: { - type: "string", - description: "Date of opening balance for the inventory transaction. Required when creating an `Item.Type=Inventory`. Required for `Inventory` item types.", - optional: true, - }, - expense_account_ref_value: { - type: "string", - description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `ExpenseAccountRef.value`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - expense_account_ref_name: { - type: "string", - description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `ExpenseAccountRef.name`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - Sku: { - type: "string", - description: "The stock keeping unit (SKU) for this Item. This is a company-defined identifier for an item or product used in tracking inventory.", - optional: true, - }, - sales_tax_included: { - type: "string", - description: "True if the sales tax is included in the item amount, and therefore is not calculated for the transaction.", - optional: true, - }, - sales_tax_code_ref_value: { - type: "string", - description: "Id of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `SalesTaxCodeRef.value`.", - optional: true, - }, - sales_tax_code_ref_name: { - type: "string", - description: "Name of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `SalesTaxCodeRef.name`.", - optional: true, - }, - class_ref_value: { - type: "string", - description: "Id of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", - optional: true, - }, - class_ref_name: { - type: "string", - description: "Name of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Name` from that object for `ClassRef.name`.", - optional: true, - }, - purchase_tax_tncluded: { - type: "boolean", - description: "True if the purchase tax is included in the item amount, and therefore is not calculated for the transaction.", - optional: true, - }, - description: { - type: "string", - description: "Description of the item.", - optional: true, - }, - abatement_rate: { - type: "string", - description: "Sales tax abatement rate for India locales.", - optional: true, - }, - reverse_charge_rate: { - type: "string", - description: "Sales tax reverse charge rate for India locales.", - optional: true, - }, - sub_item: { - type: "boolean", - description: "If true, this is a sub item. If false or null, this is a top-level item. Creating inventory hierarchies with traditional inventory items is being phased out in lieu of using categories and sub categories.", - optional: true, - }, - taxable: { - type: "boolean", - description: "If true, transactions for this item are taxable. Applicable to US companies, only.", - optional: true, - }, - UQC_display_text: { - type: "string", - description: "Text to be displayed on customer's invoice to denote the Unit of Measure (instead of the standard code).", - optional: true, - }, - reorder_point: { - type: "string", - description: "The minimum quantity of a particular inventory item that you need to restock at any given time. The ReorderPoint value cannot be set to null for sparse updates(sparse=true). It can be set to null only for full updates.", - optional: true, - }, - purchase_desc: { - type: "string", - description: "Purchase description for the item.", - optional: true, - }, - pref_vendor_ref_value: { - type: "string", - optional: true, - }, - pref_vendor_ref_name: { - type: "string", - optional: true, - }, - active: { - type: "boolean", - description: "If true, the object is currently enabled for use by QuickBooks.", - optional: true, - }, - UQC_id: { - type: "string", - description: "Id of Standard Unit of Measure (UQC:Unique Quantity Code) of the item according to GST rule.", - optional: true, - }, - purchase_tax_code_ref_value: { - type: "string", - description: "The ID for the referenced purchase tax code object as found in the Id field of the object payload. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `PurchaseTaxCodeRef.value`.", - optional: true, - }, - purchase_tax_code_ref_name: { - type: "string", - description: "An identifying name for the purchase tax code object being referenced by value and is derived from the field that holds the common name of that object. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `PurchaseTaxCodeRef.name`.", - optional: true, - }, - service_type: { - type: "string", - description: "Sales tax service type for India locales.", - optional: true, - }, - purchase_cost: { - type: "string", - description: "Amount paid when buying or ordering the item, as expressed in the home currency.", - optional: true, - }, - unit_price: { - type: "string", - description: "Corresponds to the Price/Rate column on the QuickBooks Online UI to specify either unit price, a discount, or a tax rate for item. If used for unit price, the monetary value of the service or product, as expressed in the home currency. If used for a discount or tax rate, express the percentage as a fraction. For example, specify `0.4` for 40% tax", - optional: true, - }, - tax_classification_ref_value: { - type: "string", - description: "The ID for the referenced Tax classification object as found in the Id field of the object payload.\n\nTax classification segregates different items into different classifications and the tax classification is one of the key parameters to determine appropriate tax on transactions involving items. Tax classifications are sourced by either tax governing authorities as in India/Malaysia or externally like Exactor. 'Fuel', 'Garments' and 'Soft drinks' are a few examples of tax classification in layman terms. User can choose a specific tax classification for an item while creating it. A level 1 tax classification cannot be associated to an Item", - optional: true, - }, - tax_classification_ref_name: { - type: "string", - description: "An identifying name for the Tax classification object being referenced by value and is derived from the field that holds the common name of that object.", - optional: true, - }, - parent_ref_name: { - type: "string", - description: "An identifying name for the parent item object being referenced by `value` and is derived from the field that holds the common name of that object.\n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", - optional: true, - }, - parent_ref_value: { - type: "string", - description: "The ID for the referenced parent item object as found in the Id field of the object payload. \n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", - optional: true, - }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, - }, - async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#full-update-an-item - - if (!this.item_id || !this.name || !this.sync_token || this.track_qty_on_hand === undefined || this.sparse_update === undefined) { - throw new Error("Must provide item_id, name, sync_token, and track_qty_on_hand parameters."); - } - - //Prepares the request body - var data = { - sparse: this.sparse_update, - Id: this.item_id, - Name: this.name, - QtyOnHand: this.qty_on_hand, - SyncToken: this.sync_token, - IncomeAccountRef: { - value: this.income_account_ref_value, - name: this.income_account_ref_name, - }, - Type: this.type, - AssetAccountRef: { - value: this.asset_account_ref_value, - name: this.asset_account_ref_name, - }, - InvStartDate: this.inv_start_date, - ExpenseAccountRef: { - value: this.expense_account_ref_value, - name: this.expense_account_ref_name, - }, - Sku: this.Sku, - SalesTaxIncluded: this.sales_tax_included, - TrackQtyOnHand: this.track_qty_on_hand, - SalesTaxCodeRef: { - value: this.sales_tax_code_ref_value, - name: this.sales_tax_code_ref_name, - }, - ClassRef: { - value: this.class_ref_value, - name: this.class_ref_name, - }, - PurchaseTaxIncluded: this.purchase_tax_tncluded, - Description: this.description, - AbatementRate: this.abatement_rate, - ReverseChargeRate: this.reverse_charge_rate, - SubItem: this.sub_item, - Taxable: this.taxable, - UQCDisplayText: this.UQC_display_text, - ReorderPoint: this.reorder_point, - PurchaseDesc: this.purchase_desc, - PrefVendorRef: { - value: this.pref_vendor_ref_value, - name: this.pref_vendor_ref_name, - }, - Active: this.active, - UQCId: this.UQC_id, - PurchaseTaxCodeRef: { - value: this.purchase_tax_code_ref_value, - name: this.purchase_tax_code_ref_name, - }, - ServiceType: this.service_type, - PurchaseCost: this.purchase_cost, - UnitPrice: this.unit_price, - TaxClassificationRef: { - value: this.tax_classification_ref_value, - name: this.tax_classification_ref_name, - }, - }; - - if (this.pref_vendor_ref_value || this.parent_ref_name) { - data["ParentRef"] = { - value: this.parent_ref_value, - name: this.parent_ref_name, - }; - } - - //Sends the request against Quickbooks Sandbox API - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/item`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, - data, - params: { - minorversion: this.minorversion, - }, - }); + quickbooks: app, + ...props, }, }; diff --git a/components/quickbooks_sandbox/common/utils.mjs b/components/quickbooks_sandbox/common/utils.mjs new file mode 100644 index 0000000000000..d42df055ddeb0 --- /dev/null +++ b/components/quickbooks_sandbox/common/utils.mjs @@ -0,0 +1,40 @@ +export function adjustPropDefinitions(props, app) { + return Object.fromEntries( + Object.entries(props).map(([ + key, + prop, + ]) => { + if (typeof prop === "string") return [ + key, + prop, + ]; + const { + propDefinition, ...otherValues + } = prop; + if (propDefinition) { + const [ + , ...otherDefs + ] = propDefinition; + return [ + key, + { + propDefinition: [ + app, + ...otherDefs, + ], + ...otherValues, + }, + ]; + } + return [ + key, + otherValues.type === "app" + ? null + : otherValues, + ]; + }) + .filter(([ + , value, + ]) => value), + ); +} diff --git a/components/quickbooks_sandbox/package.json b/components/quickbooks_sandbox/package.json new file mode 100644 index 0000000000000..3d9196f26d78c --- /dev/null +++ b/components/quickbooks_sandbox/package.json @@ -0,0 +1,15 @@ +{ + "name": "@pipedream/quickbooks_sandbox", + "version": "0.0.1", + "description": "Pipedream Quickbooks Sandbox Components", + "main": "quickbooks_sandbox.app.mjs", + "keywords": [ + "pipedream", + "quickbooks_sandbox" + ], + "homepage": "https://pipedream.com/apps/quickbooks_sandbox", + "author": "Pipedream (https://pipedream.com/)", + "publishConfig": { + "access": "public" + } +} diff --git a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs index 8fc6bc9dc64db..80cf5c066d291 100644 --- a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs +++ b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs @@ -1,11 +1,13 @@ +import common from "../quickbooks/quickbooks.app.mjs"; + export default { + ...common, type: "app", app: "quickbooks_sandbox", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + ...common.mehtods, + _apiUrl() { + return "https://quickbooks.api.intuit.com/v3"; }, }, }; diff --git a/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs b/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs new file mode 100644 index 0000000000000..b3b6adadb9404 --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-customer-created/new-customer-created.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-customer-created", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs b/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs new file mode 100644 index 0000000000000..b6d8ce2dc3a14 --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-customer-updated/new-customer-updated.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-customer-updated", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs b/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs new file mode 100644 index 0000000000000..755104c6d78cf --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-invoice-created/new-invoice-created.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-invoice-created", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs b/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs new file mode 100644 index 0000000000000..db858e8a82fbd --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-invoice-updated/new-invoice-updated.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-invoice-updated", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs b/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs new file mode 100644 index 0000000000000..0f7fd105304ee --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-item-created/new-item-created.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-item-created", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; diff --git a/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs b/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs new file mode 100644 index 0000000000000..bcf3aacf648eb --- /dev/null +++ b/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs @@ -0,0 +1,22 @@ +import app from "../../monday_oauth.app.mjs"; +import common from "../../../monday/sources/new-item-updated/new-item-updated.mjs"; + +import { adjustPropDefinitions } from "../../common/utils.mjs"; + +const { + name, description, type, ...others +} = common; +const props = adjustPropDefinitions(others.props, app); + +export default { + ...others, + key: "quickbooks_sandbox-new-item-updated", + version: "0.0.1", + name, + description, + type, + props: { + monday: app, + ...props, + }, +}; From dbaed7e91d936685e3abd70a7169ff500d693e21 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 15:28:17 -0500 Subject: [PATCH 03/19] update update-item --- .../actions/update-item/update-item.mjs | 244 ++++++++++-------- components/quickbooks/quickbooks.app.mjs | 28 ++ 2 files changed, 171 insertions(+), 101 deletions(-) diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs index d21b0a0cd6ae1..db51fbe3f73a8 100644 --- a/components/quickbooks/actions/update-item/update-item.mjs +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -1,51 +1,61 @@ import quickbooks from "../../quickbooks.app.mjs"; -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks_sandbox-update-item", name: "Update Item", - description: "Updates an item.", + description: "Updates an item. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#full-update-an-item)", version: "0.0.1", type: "action", props: { quickbooks, - item_id: { - type: "string", - description: "Id of the item to update.", + itemId: { + propDefinition: [ + quickbooks, + "itemId", + ], }, name: { type: "string", + label: "Name", description: "Name of the item. This value must be unique.", }, - sync_token: { + syncToken: { type: "string", + label: "Sync Token", description: "Version number of the entity. Required for the update operation.", }, - track_qty_on_hand: { + trackQtyOnHand: { type: "boolean", + label: "Track Quantity on Hand", description: "True if there is quantity on hand to be tracked. Once this value is true, it cannot be updated to false. Applicable for items of type `Inventory`. Not applicable for `Service` or `NonInventory` item types.", }, - sparse_update: { + sparseUpdate: { type: "string", + label: "Sparse Update", description: "When set to `true`, sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched.", }, - qty_on_hand: { + qtyOnHand: { type: "string", + label: "Quantity on Hand", description: "Current quantity of the `Inventory` items available for sale. Not used for `Service` or `NonInventory` type items. Required for `Inventory` type items.", optional: true, }, - income_account_ref_value: { + incomeAccountRefValue: { type: "string", + label: "Income Account Ref Value", description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `IncomeAccountRef.value`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", optional: true, }, - income_account_ref_name: { + incomeAccountRefName: { type: "string", + label: "Income Account Ref Name", description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `IncomeAccountRef.name`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", optional: true, }, type: { type: "string", + label: "Type", description: "Classification that specifies the use of this item. See the description at the top of the [Item entity page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item) for details about supported item types. See specifications for the type parameter in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", optional: true, options: [ @@ -55,267 +65,299 @@ export default { "NonInventory", ], }, - asset_account_ref_value: { + assetAccountRefValue: { type: "string", + label: "Asset Account Ref Value", description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `AssetAccountRef.value`.", optional: true, }, - asset_account_ref_name: { + assetAccountRefName: { type: "string", + label: "Asset Account Ref Name", description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `AssetAccountRef.name`.", optional: true, }, - inv_start_date: { + invStartDate: { type: "string", + label: "Inventory Start Date", description: "Date of opening balance for the inventory transaction. Required when creating an `Item.Type=Inventory`. Required for `Inventory` item types.", optional: true, }, - expense_account_ref_value: { + expenseAccountRefValue: { type: "string", + label: "Expense Account Ref Value", description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `ExpenseAccountRef.value`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", optional: true, }, - expense_account_ref_name: { + expenseAccountRefName: { type: "string", + label: "Expense Account Ref Name", description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `ExpenseAccountRef.name`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", optional: true, }, - Sku: { + sku: { type: "string", + label: "Sku", description: "The stock keeping unit (SKU) for this Item. This is a company-defined identifier for an item or product used in tracking inventory.", optional: true, }, - sales_tax_included: { + salesTaxIncluded: { type: "string", + label: "Sales Tax Included", description: "True if the sales tax is included in the item amount, and therefore is not calculated for the transaction.", optional: true, }, - sales_tax_code_ref_value: { + salesTaxCodeRefValue: { type: "string", + label: "Sales Tax Code Ref Value", description: "Id of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `SalesTaxCodeRef.value`.", optional: true, }, - sales_tax_code_ref_name: { + salesTaxCodeRefName: { type: "string", + label: "Sales Tax Code Ref Name", description: "Name of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `SalesTaxCodeRef.name`.", optional: true, }, - class_ref_value: { + classRefValue: { type: "string", + label: "Class Ref Value", description: "Id of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", optional: true, }, - class_ref_name: { + classRefName: { type: "string", + label: "Class Ref Name", description: "Name of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Name` from that object for `ClassRef.name`.", optional: true, }, - purchase_tax_tncluded: { + purchaseTaxIncluded: { type: "boolean", + label: "Purchase Tax Included", description: "True if the purchase tax is included in the item amount, and therefore is not calculated for the transaction.", optional: true, }, description: { type: "string", + label: "Description", description: "Description of the item.", optional: true, }, - abatement_rate: { + abatementRate: { type: "string", + label: "Abatement Rate", description: "Sales tax abatement rate for India locales.", optional: true, }, - reverse_charge_rate: { + reverseChargeRate: { type: "string", + label: "Reverse Charge Rate", description: "Sales tax reverse charge rate for India locales.", optional: true, }, - sub_item: { + subItem: { type: "boolean", + label: "Sub Item", description: "If true, this is a sub item. If false or null, this is a top-level item. Creating inventory hierarchies with traditional inventory items is being phased out in lieu of using categories and sub categories.", optional: true, }, taxable: { type: "boolean", + label: "Taxable", description: "If true, transactions for this item are taxable. Applicable to US companies, only.", optional: true, }, - UQC_display_text: { + UqcDisplayText: { type: "string", + label: "UQC Display Text", description: "Text to be displayed on customer's invoice to denote the Unit of Measure (instead of the standard code).", optional: true, }, - reorder_point: { + reorderPoint: { type: "string", + label: "Reorder Point", description: "The minimum quantity of a particular inventory item that you need to restock at any given time. The ReorderPoint value cannot be set to null for sparse updates(sparse=true). It can be set to null only for full updates.", optional: true, }, - purchase_desc: { + purchaseDesc: { type: "string", + label: "Purchase Description", description: "Purchase description for the item.", optional: true, }, - pref_vendor_ref_value: { + prefVendorRefValue: { type: "string", + label: "Pref Vendor Ref Value", + description: "Pref vendor ref value", optional: true, }, - pref_vendor_ref_name: { + prefVendorRefName: { type: "string", + label: "Pref Vendor Ref Name", + description: "Pref vendor ref name", optional: true, }, active: { type: "boolean", + label: "Active", description: "If true, the object is currently enabled for use by QuickBooks.", optional: true, }, - UQC_id: { + UqcId: { type: "string", + label: "UQC ID", description: "Id of Standard Unit of Measure (UQC:Unique Quantity Code) of the item according to GST rule.", optional: true, }, - purchase_tax_code_ref_value: { + purchaseTaxCodeRefValue: { type: "string", + label: "Purchase Tax Code Ref Value", description: "The ID for the referenced purchase tax code object as found in the Id field of the object payload. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `PurchaseTaxCodeRef.value`.", optional: true, }, - purchase_tax_code_ref_name: { + purchaseTaxCodeRefName: { type: "string", + label: "Purchase Tax Code Ref Name", description: "An identifying name for the purchase tax code object being referenced by value and is derived from the field that holds the common name of that object. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `PurchaseTaxCodeRef.name`.", optional: true, }, - service_type: { + serviceType: { type: "string", + label: "Service Type", description: "Sales tax service type for India locales.", optional: true, }, - purchase_cost: { + purchaseCost: { type: "string", + label: "Purchase Cost", description: "Amount paid when buying or ordering the item, as expressed in the home currency.", optional: true, }, - unit_price: { + unitPrice: { type: "string", + label: "Unit Price", description: "Corresponds to the Price/Rate column on the QuickBooks Online UI to specify either unit price, a discount, or a tax rate for item. If used for unit price, the monetary value of the service or product, as expressed in the home currency. If used for a discount or tax rate, express the percentage as a fraction. For example, specify `0.4` for 40% tax", optional: true, }, - tax_classification_ref_value: { + taxClassificationRefValue: { type: "string", + label: "Tax Classification Ref Value", description: "The ID for the referenced Tax classification object as found in the Id field of the object payload.\n\nTax classification segregates different items into different classifications and the tax classification is one of the key parameters to determine appropriate tax on transactions involving items. Tax classifications are sourced by either tax governing authorities as in India/Malaysia or externally like Exactor. 'Fuel', 'Garments' and 'Soft drinks' are a few examples of tax classification in layman terms. User can choose a specific tax classification for an item while creating it. A level 1 tax classification cannot be associated to an Item", optional: true, }, - tax_classification_ref_name: { + taxClassificationRefName: { type: "string", + label: "Tax Classification Ref Name", description: "An identifying name for the Tax classification object being referenced by value and is derived from the field that holds the common name of that object.", optional: true, }, - parent_ref_name: { + parentRefName: { type: "string", + label: "Parent Ref Name", description: "An identifying name for the parent item object being referenced by `value` and is derived from the field that holds the common name of that object.\n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", optional: true, }, - parent_ref_value: { + parentRefValue: { type: "string", + label: "Parent Ref Value", description: "The ID for the referenced parent item object as found in the Id field of the object payload. \n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", optional: true, }, - minorversion: { - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], }, }, async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#full-update-an-item - - if (!this.item_id + if (!this.itemId || !this.name - || !this.sync_token - || this.track_qty_on_hand === undefined - || this.sparse_update === undefined + || !this.syncToken + || this.trackQtyOnHand === undefined + || this.sparseUpdate === undefined ) { - throw new Error("Must provide item_id, name, sync_token, and track_qty_on_hand parameters."); + throw new ConfigurationError("Must provide itemId, name, syncToken, and trackQtyOnHand parameters."); } - //Prepares the request body - var data = { - sparse: this.sparse_update, - Id: this.item_id, + const data = { + sparse: this.sparseUpdate, + Id: this.itemId, Name: this.name, - QtyOnHand: this.qty_on_hand, - SyncToken: this.sync_token, + QtyOnHand: this.qtyOnHand, + SyncToken: this.syncToken, IncomeAccountRef: { - value: this.income_account_ref_value, - name: this.income_account_ref_name, + value: this.incomeAccountRefValue, + name: this.incomeAccountRefName, }, Type: this.type, AssetAccountRef: { - value: this.asset_account_ref_value, - name: this.asset_account_ref_name, + value: this.assetAccountRefValue, + name: this.assetAccountRefName, }, - InvStartDate: this.inv_start_date, + InvStartDate: this.invStartDate, ExpenseAccountRef: { - value: this.expense_account_ref_value, - name: this.expense_account_ref_name, + value: this.expenseAccountRefValue, + name: this.expenseAccountRefName, }, - Sku: this.Sku, - SalesTaxIncluded: this.sales_tax_included, - TrackQtyOnHand: this.track_qty_on_hand, + Sku: this.sku, + SalesTaxIncluded: this.salesTaxIncluded, + TrackQtyOnHand: this.trackQtyOnHand, SalesTaxCodeRef: { - value: this.sales_tax_code_ref_value, - name: this.sales_tax_code_ref_name, + value: this.salesTaxCodeRefValue, + name: this.salesTaxCodeRefName, }, ClassRef: { - value: this.class_ref_value, - name: this.class_ref_name, + value: this.classRefValue, + name: this.classRefName, }, - PurchaseTaxIncluded: this.purchase_tax_tncluded, + PurchaseTaxIncluded: this.purchaseTaxIncluded, Description: this.description, - AbatementRate: this.abatement_rate, - ReverseChargeRate: this.reverse_charge_rate, - SubItem: this.sub_item, + AbatementRate: this.abatementRate, + ReverseChargeRate: this.reverseChargeRate, + SubItem: this.subItem, Taxable: this.taxable, - UQCDisplayText: this.UQC_display_text, - ReorderPoint: this.reorder_point, - PurchaseDesc: this.purchase_desc, + UQCDisplayText: this.UqcDisplayText, + ReorderPoint: this.reorderPoint, + PurchaseDesc: this.purchaseDesc, PrefVendorRef: { - value: this.pref_vendor_ref_value, - name: this.pref_vendor_ref_name, + value: this.prefVendorRefValue, + name: this.prefVendorRefName, }, Active: this.active, - UQCId: this.UQC_id, + UQCId: this.UqcId, PurchaseTaxCodeRef: { - value: this.purchase_tax_code_ref_value, - name: this.purchase_tax_code_ref_name, + value: this.purchaseTaxCodeRefValue, + name: this.purchaseTaxCodeRefName, }, - ServiceType: this.service_type, - PurchaseCost: this.purchase_cost, - UnitPrice: this.unit_price, + ServiceType: this.serviceType, + PurchaseCost: this.purchaseCost, + UnitPrice: this.unitPrice, TaxClassificationRef: { - value: this.tax_classification_ref_value, - name: this.tax_classification_ref_name, + value: this.taxClassificationRefValue, + name: this.taxClassificationRefName, }, }; - if (this.pref_vendor_ref_value || this.parent_ref_name) { + if (this.prefVendorRefValue || this.parentRefName) { data["ParentRef"] = { - value: this.parent_ref_value, - name: this.parent_ref_name, + value: this.parentRefValue, + name: this.parentRefName, }; } - //Sends the request against Quickbooks Sandbox API - return await axios($, { - method: "post", - url: `https://sandbox-quickbooks.api.intuit.com/v3/company/${this.quickbooks_sandbox.$auth.company_id}/item`, - headers: { - "Authorization": `Bearer ${this.quickbooks_sandbox.$auth.oauth_access_token}`, - "accept": "application/json", - "content-type": "application/json", - }, + const response = await this.quickbooks.updateItem({ + $, data, params: { minorversion: this.minorversion, }, }); + + if (response) { + $.export("summary", `Successfully updated item with id ${this.itemId}`); + } + + return response; }, }; diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index c7618238da5cb..eee151752eec1 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -343,6 +343,27 @@ export default { })) || []; }, }, + itemId: { + type: "string", + label: "Item Id", + description: "The identifier of an item", + async options({ page }) { + const position = 1 + (page * 10); + const { QueryResponse: { Item: items } } = await this.query({ + params: { + query: `select * from item maxresults 10 ${page + ? `startposition ${position}` + : ""} `, + }, + }); + return items?.map(({ + Id: value, Name: label, + }) => ({ + value, + label, + })) || []; + }, + }, }, methods: { _companyId() { @@ -501,6 +522,13 @@ export default { ...opts, }); }, + updateItem(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/item`, + method: "post", + ...opts, + }); + }, getApAgingReport(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/reports/AgedPayableDetail`, From e1586a6efb6725a657b4b1477e7f5745c8a90718 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 15:35:42 -0500 Subject: [PATCH 04/19] minor updates --- .../actions/create-purchase/create-purchase.mjs | 1 - .../quickbooks/actions/get-my-company/get-my-company.mjs | 1 - .../actions/search-accounts/search-accounts.mjs | 7 +++---- .../actions/search-customers/search-customers.mjs | 7 +++---- .../actions/search-invoices/search-invoices.mjs | 7 +++---- .../quickbooks/actions/search-items/search-items.mjs | 7 +++---- .../actions/search-products/search-products.mjs | 7 +++---- .../actions/search-purchases/search-purchases.mjs | 6 +++--- .../actions/search-services/search-services.mjs | 9 +++++---- .../search-time-activities/search-time-activities.mjs | 7 +++---- .../quickbooks/actions/search-vendors/search-vendors.mjs | 7 +++---- 11 files changed, 29 insertions(+), 37 deletions(-) diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index 950ccdec8cc10..8400451ef725d 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -56,7 +56,6 @@ export default { }, }, async run({ $ }) { - let parsedLineItems = parseOne(this.lineItems); const response = await this.quickbooks.createPurchase({ diff --git a/components/quickbooks/actions/get-my-company/get-my-company.mjs b/components/quickbooks/actions/get-my-company/get-my-company.mjs index 9292f7c821ba8..cbd19efdbe294 100644 --- a/components/quickbooks/actions/get-my-company/get-my-company.mjs +++ b/components/quickbooks/actions/get-my-company/get-my-company.mjs @@ -10,7 +10,6 @@ export default { quickbooks, }, async run({ $ }) { - const response = await this.quickbooks.getMyCompany({ $, }); diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index d5c23a9ca2c4f..263ac46b154ee 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Account where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 3863f0a2792b8..4cf5bf956bcfd 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Customer where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index 850f55bbbfed7..82ea42a052a4e 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -55,22 +55,21 @@ export default { //Prepares OrderBy clause,start position, max results // parameters to be used in the request's query parameter. - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Invoice where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index 009489c4d628e..8ae7528c9dcca 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Item where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index cbe25d9e6f3a7..9bf85d66592ee 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Item where Type = 'Inventory' and ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-purchases/search-purchases.mjs b/components/quickbooks/actions/search-purchases/search-purchases.mjs index ac08e79571e04..be7afa20a25d7 100644 --- a/components/quickbooks/actions/search-purchases/search-purchases.mjs +++ b/components/quickbooks/actions/search-purchases/search-purchases.mjs @@ -46,17 +46,17 @@ export default { whereClause = ` WHERE ${this.whereClause}`; } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index 1d1360621a25f..369c1b4855465 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -1,4 +1,5 @@ import quickbooks from "../../quickbooks.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks-search-services", @@ -49,20 +50,20 @@ export default { }, async run({ $ }) { if (!this.include_clause || !this.where_clause) { - throw new Error("Must provide include_clause, where_clause parameters."); + throw new ConfigurationError("Must provide include_clause, where_clause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.order_clause) { orderClause = ` ORDERBY ${this.order_clause}`; } - var startPosition = ""; + let startPosition = ""; if (this.start_position) { startPosition = ` STARTPOSITION ${this.start_position}`; } - var maxResults = ""; + let maxResults = ""; if (this.max_results) { maxResults = ` MAXRESULTS ${this.max_results}` || ""; } diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index 0aa56d8c7e987..2cd6c66f30268 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from TimeActivity where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index 4d1edf2acc9f5..f4115c13229f7 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -53,22 +53,21 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - var orderClause = ""; + let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } - var startPosition = ""; + let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } - var maxResults = ""; + let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - //Prepares the request's query parameter const query = `select ${this.includeClause} from Vendor where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ From 4b0016bf6c013dcb281e123a275a7a3c87b5e6c8 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 16:14:30 -0500 Subject: [PATCH 05/19] add async options --- .../actions/create-bill/create-bill.mjs | 6 +- .../actions/create-invoice/create-invoice.mjs | 7 +- .../actions/create-payment/create-payment.mjs | 7 +- .../create-purchase/create-purchase.mjs | 32 ++++---- .../delete-purchase/delete-purchase.mjs | 10 +-- .../quickbooks/actions/get-bill/get-bill.mjs | 7 +- .../actions/get-customer/get-customer.mjs | 7 +- .../actions/get-invoice/get-invoice.mjs | 8 +- .../get-purchase-order/get-purchase-order.mjs | 7 +- .../actions/get-purchase/get-purchase.mjs | 9 ++- .../get-sales-receipt/get-sales-receipt.mjs | 7 +- .../get-time-activity/get-time-activity.mjs | 7 +- .../search-invoices/search-invoices.mjs | 23 +++--- .../actions/search-items/search-items.mjs | 21 +++-- .../search-products/search-products.mjs | 21 +++-- .../search-purchases/search-purchases.mjs | 30 +++---- .../search-services/search-services.mjs | 21 +++-- .../search-time-activities.mjs | 21 +++-- .../actions/search-vendors/search-vendors.mjs | 21 +++-- .../update-customer/update-customer.mjs | 11 +-- components/quickbooks/quickbooks.app.mjs | 79 +++++++++++++++++++ 21 files changed, 217 insertions(+), 145 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index 3be36a36fd4d7..d9fe37f9f3970 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -10,8 +10,12 @@ export default { props: { quickbooks, vendorRefValue: { - label: "Vendor Ref Value", + propDefinition: [ + quickbooks, + "vendorIds", + ], type: "string", + label: "Vendor Ref Value", description: "Reference to the vendor for this transaction. Query the Vendor name list resource to determine the appropriate Vendor object for this reference. Use `Vendor.Id` from that object for `VendorRef.value`.", }, lineItems: { diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 72dd5aed7c3e4..3cf0cce381fd9 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -16,9 +16,10 @@ export default { ], }, customerRefValue: { - label: "Customer Reference Value", - type: "string", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.Id` from that object for `CustomerRef.value`.", + propDefinition: [ + quickbooks, + "customer", + ], }, customerRefName: { propDefinition: [ diff --git a/components/quickbooks/actions/create-payment/create-payment.mjs b/components/quickbooks/actions/create-payment/create-payment.mjs index 2321f5fc1430e..4404ff82dc8bd 100644 --- a/components/quickbooks/actions/create-payment/create-payment.mjs +++ b/components/quickbooks/actions/create-payment/create-payment.mjs @@ -14,9 +14,10 @@ export default { type: "string", }, customerRefValue: { - label: "Customer Reference Value", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.Id` from that object for `CustomerRef.value`.", - type: "string", + propDefinition: [ + quickbooks, + "customer", + ], }, customerRefName: { propDefinition: [ diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index 8400451ef725d..ffb0db0e4d701 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -10,8 +10,12 @@ export default { props: { quickbooks, accountRefValue: { - label: "Account Reference Value", + propDefinition: [ + quickbooks, + "accountIds", + ], type: "string", + label: "Account Reference Value", description: "Specifies the id of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", }, paymentType: { @@ -37,22 +41,22 @@ export default { optional: true, }, currencyRefValue: { - label: "Currency Reference Value", - type: "string", - description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", - optional: true, + propDefinition: [ + quickbooks, + "currencyRefValue", + ], }, currencyRefName: { - label: "Currency Reference Name", - type: "object", - description: "The full name of the currency.", - optional: true, + propDefinition: [ + quickbooks, + "currencyRefName", + ], }, - minorversion: { - label: "Minor Version", - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], }, }, async run({ $ }) { diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index 74bc04d2d29aa..afa3c5a275171 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -14,11 +14,11 @@ export default { "purchaseId", ], }, - minorversion: { - label: "Minor Version", - type: "string", - description: "Use the minorversion query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], }, }, async run({ $ }) { diff --git a/components/quickbooks/actions/get-bill/get-bill.mjs b/components/quickbooks/actions/get-bill/get-bill.mjs index 08b5dc5d770d3..b6c0259ddf81f 100644 --- a/components/quickbooks/actions/get-bill/get-bill.mjs +++ b/components/quickbooks/actions/get-bill/get-bill.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, billId: { - label: "Bill ID", - type: "string", - description: "Id of the bill to get details of.", + propDefinition: [ + quickbooks, + "billId", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/get-customer/get-customer.mjs b/components/quickbooks/actions/get-customer/get-customer.mjs index 3c95809cf39a5..92b0af02ea0bd 100644 --- a/components/quickbooks/actions/get-customer/get-customer.mjs +++ b/components/quickbooks/actions/get-customer/get-customer.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, customerId: { - label: "Customer ID", - type: "string", - description: "Id of the account to get details of.", + propDefinition: [ + quickbooks, + "customer", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/get-invoice/get-invoice.mjs b/components/quickbooks/actions/get-invoice/get-invoice.mjs index f6e5c2b4185cd..353771d5b2c3c 100644 --- a/components/quickbooks/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks/actions/get-invoice/get-invoice.mjs @@ -10,10 +10,10 @@ export default { props: { quickbooks, invoiceId: { - label: "Invoice ID", - type: "string", - description: "Id of the invoice to get details of.", - optional: true, + propDefinition: [ + quickbooks, + "invoiceId", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs index 170f748db7d0f..e152daea54558 100644 --- a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs +++ b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, purchaseOrderId: { - label: "Purchase Order ID", - type: "string", - description: "Id of the purchase order to get details of.", + propDefinition: [ + quickbooks, + "purchaseOrderId", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/get-purchase/get-purchase.mjs b/components/quickbooks/actions/get-purchase/get-purchase.mjs index de50f8bd32a3e..899a94fcc975d 100644 --- a/components/quickbooks/actions/get-purchase/get-purchase.mjs +++ b/components/quickbooks/actions/get-purchase/get-purchase.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, purchaseId: { - label: "Purchase ID", - type: "string", - description: "Id of the purchase to get details of.", + propDefinition: [ + quickbooks, + "purchaseId", + ], }, minorVersion: { propDefinition: [ @@ -28,7 +29,7 @@ export default { const response = await this.quickbooks.getPurchase({ $, - purchaseId: this.purchaseId, + purchaseId: this.purchaseId?.value ?? this.purchaseId, params: { minorversion: this.minorVersion, }, diff --git a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs index 2c3dbbca67a90..ec71a3156e0cb 100644 --- a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs +++ b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, salesReceiptId: { - label: "sales Receipt ID", - type: "string", - description: "Id of the sales receipt to get details of.", + propDefinition: [ + quickbooks, + "salesReceiptId", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs index 756c4add8a764..b19cabf0772a6 100644 --- a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs +++ b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs @@ -10,9 +10,10 @@ export default { props: { quickbooks, timeActivityId: { - label: "Time Activity ID", - type: "string", - description: "Id of the time activity object to get details of.", + propDefinition: [ + quickbooks, + "timeActivityId", + ], }, minorVersion: { propDefinition: [ diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index 82ea42a052a4e..fbc54cdd957f2 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -53,22 +53,17 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - //Prepares OrderBy clause,start position, max results - // parameters to be used in the request's query parameter. - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.includeClause} from Invoice where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index 8ae7528c9dcca..a9cc83fa7c9a8 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -53,20 +53,17 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.includeClause} from Item where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index 9bf85d66592ee..4db7a0472e3e3 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -53,20 +53,17 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.includeClause} from Item where Type = 'Inventory' and ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-purchases/search-purchases.mjs b/components/quickbooks/actions/search-purchases/search-purchases.mjs index be7afa20a25d7..b66c7694d63d8 100644 --- a/components/quickbooks/actions/search-purchases/search-purchases.mjs +++ b/components/quickbooks/actions/search-purchases/search-purchases.mjs @@ -41,26 +41,22 @@ export default { }, }, async run({ $ }) { - let whereClause = ""; - if (this.whereClause) { - whereClause = ` WHERE ${this.whereClause}`; - } + const whereClause = this.whereClause + ? ` WHERE ${this.whereClause}` + : ""; - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; + + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } - //Prepares the request's query parameter const query = `select * from Purchase ${whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index 369c1b4855465..e1b61476b2f08 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -53,20 +53,17 @@ export default { throw new ConfigurationError("Must provide include_clause, where_clause parameters."); } - let orderClause = ""; - if (this.order_clause) { - orderClause = ` ORDERBY ${this.order_clause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.start_position) { - startPosition = ` STARTPOSITION ${this.start_position}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.max_results) { - maxResults = ` MAXRESULTS ${this.max_results}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.include_clause} from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index 2cd6c66f30268..c02bcd127c026 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -53,20 +53,17 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.includeClause} from TimeActivity where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index f4115c13229f7..c79a12bc2c83f 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -53,20 +53,17 @@ export default { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } - let orderClause = ""; - if (this.orderClause) { - orderClause = ` ORDERBY ${this.orderClause}`; - } + const orderClause = this.orderClause + ? ` ORDERBY ${this.orderClause}` + : ""; - let startPosition = ""; - if (this.startPosition) { - startPosition = ` STARTPOSITION ${this.startPosition}`; - } + const startPosition = this.startPosition + ? ` STARTPOSITION ${this.startPosition}` + : ""; - let maxResults = ""; - if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; - } + const maxResults = this.maxResults + ? ` MAXRESULTS ${this.maxResults}` + : ""; const query = `select ${this.includeClause} from Vendor where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index 76e03b2209653..22de4309589f9 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -9,6 +9,12 @@ export default { type: "action", props: { quickbooks, + customerId: { + propDefinition: [ + quickbooks, + "customer", + ], + }, displayName: { propDefinition: [ quickbooks, @@ -183,11 +189,6 @@ export default { optional: true, type: "string", }, - customerId: { - description: "Unique identifier for the customer object to be updated.", - label: "Customer Id", - type: "string", - }, customerTypeRefValue: { description: "Id referencing to the customer type assigned to a customer. This field is only returned if the customer is assigned a customer type.", label: "Customer Type Ref Value", diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index eee151752eec1..f178f3776a637 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -364,6 +364,85 @@ export default { })) || []; }, }, + billId: { + type: "string", + label: "Bill Id", + description: "The identifier of a bill", + async options({ page }) { + const position = 1 + (page * 10); + const { QueryResponse: { Bill: bills } } = await this.query({ + params: { + query: `select * from bill maxresults 10 ${page + ? `startposition ${position}` + : ""} `, + }, + }); + return bills?.map(({ Id: id }) => id ) || []; + }, + }, + purchaseOrderId: { + type: "string", + label: "Item Id", + description: "The identifier of a purchase order", + async options({ page }) { + const position = 1 + (page * 10); + const { QueryResponse: { PurchaseOrder: purchaseOrders } } = await this.query({ + params: { + query: `select * from purchaseorder maxresults 10 ${page + ? `startposition ${position}` + : ""} `, + }, + }); + return purchaseOrders?.map(({ + Id: value, DocNumber, + }) => ({ + value, + label: DocNumber ?? value, + })) || []; + }, + }, + salesReceiptId: { + type: "string", + label: "Sales Receipt Id", + description: "The identifier of a sales receipt", + async options({ page }) { + const position = 1 + (page * 10); + const { QueryResponse: { SalesReceipt: salesReceipts } } = await this.query({ + params: { + query: `select * from salesreceipt maxresults 10 ${page + ? `startposition ${position}` + : ""} `, + }, + }); + return salesReceipts?.map(({ + Id: value, DocNumber, + }) => ({ + value, + label: DocNumber ?? value, + })) || []; + }, + }, + timeActivityId: { + type: "string", + label: "Time Activity Id", + description: "The identifier of a time activity", + async options({ page }) { + const position = 1 + (page * 10); + const { QueryResponse: { TimeActivity: timeActivities } } = await this.query({ + params: { + query: `select * from timeactivity maxresults 10 ${page + ? `startposition ${position}` + : ""} `, + }, + }); + return timeActivities?.map(({ + Id: value, NameOf: nameOf, Description: description, + }) => ({ + value, + label: `${nameOf} ${description}`, + })) || []; + }, + }, }, methods: { _companyId() { From 1fec87f47a54f9af6b41ee08113a2d2ae2c5652a Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 16:55:17 -0500 Subject: [PATCH 06/19] refactor props --- components/quickbooks/quickbooks.app.mjs | 345 ++++++++++------------- 1 file changed, 146 insertions(+), 199 deletions(-) diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index f178f3776a637..d86b9fe8b05ae 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -11,21 +11,16 @@ export default { type: "string", description: "Id of the invoice to get details of.", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Invoice: records } } = await this.query({ - params: { - query: `select * from invoice maxresults 10${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Invoice", + mapper: ({ + Id: value, DocNumber: docNumber, CustomerRef: customerRef, + }) => ({ + label: `(${docNumber}) ${customerRef.name}`, + value, + }), }); - - return records?.map(({ - Id: value, DocNumber: docNumber, CustomerRef: customerRef, - }) => ({ - label: `(${docNumber}) ${customerRef.name}`, - value, - })) || []; }, }, minorVersion: { @@ -44,24 +39,16 @@ export default { type: "string", description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference.", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Customer: records } } = await this.query({ - params: { - query: `select * from Customer maxresults 10${page - ? `startposition ${position}` - : ""} `, - }, - }); - - return records?.map(({ - Id: id, DisplayName: label, - }) => ({ - label, - value: JSON.stringify({ + return this.getPropOptions({ + page, + resource: "Customer", + mapper: ({ + Id: id, DisplayName: label, + }) => ({ + label, value: id, - name: label, }), - })) || []; + }); }, }, customerRefName: { @@ -76,24 +63,19 @@ export default { description: "This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { CompanyCurrency: records } } = await this.query({ - params: { - query: `select * from companycurrency maxresults 10${page - ? `startposition ${position}` - : ""} `, - }, - }); - - return records?.map(({ - Code: code, Name: name, - }) => ({ - label: `${code} - ${name}`, - value: JSON.stringify({ - value: code, - name: name, + return this.getPropOptions({ + page, + resource: "CompanyCurrency", + mapper: ({ + Code: code, Name: name, + }) => ({ + label: `${code} - ${name}`, + value: JSON.stringify({ + value: code, + name: name, + }), }), - })) || []; + }); }, }, currencyRefValue: { @@ -172,21 +154,16 @@ export default { description: "Id of the purchase.", withLabel: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Purchase: records } } = await this.query({ - params: { - query: `select * from Purchase maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Purchase", + mapper: ({ + Id, PaymentType, SyncToken, + }) => ({ + label: `${Id} - ${PaymentType}`, + value: `${Id}|${SyncToken}`, + }), }); - - return records?.map(({ - Id, PaymentType, SyncToken, - }) => ({ - label: `${Id} - ${PaymentType}`, - value: `${Id}|${SyncToken}`, - })) || []; }, }, suffix: { @@ -217,20 +194,16 @@ export default { description: "Filters report contents based on term or terms supplied", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Term: terms } } = await this.query({ - params: { - query: `select * from term maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Term", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), }); - return terms?.map(({ - Id: value, Name: label, - }) => ({ - value, - label, - })) || []; }, }, vendorIds: { @@ -239,20 +212,16 @@ export default { description: "Filters report contents to include information for specified vendors", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Vendor: vendors } } = await this.query({ - params: { - query: `select * from vendor maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Vendor", + mapper: ({ + Id: value, DisplayName: label, + }) => ({ + value, + label, + }), }); - return vendors?.map(({ - Id: value, DisplayName: label, - }) => ({ - value, - label, - })) || []; }, }, accountIds: { @@ -261,20 +230,16 @@ export default { description: "Filters report contents to include information for specified accounts", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Account: accounts } } = await this.query({ - params: { - query: `select * from account maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Account", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), }); - return accounts?.map(({ - Id: value, Name: label, - }) => ({ - value, - label, - })) || []; }, }, classIds: { @@ -283,20 +248,16 @@ export default { description: "Filters report contents to include information for specified classes if so configured in the company file", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Class: classes } } = await this.query({ - params: { - query: `select * from class maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Class", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), }); - return classes?.map(({ - Id: value, Name: label, - }) => ({ - value, - label, - })) || []; }, }, employeeIds: { @@ -305,20 +266,16 @@ export default { description: "Filters report contents to include information for specified employees", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Employee: employees } } = await this.query({ - params: { - query: `select * from employee maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Employee", + mapper: ({ + Id: value, DisplayName: label, + }) => ({ + value, + label, + }), }); - return employees?.map(({ - Id: value, DisplayName: label, - }) => ({ - value, - label, - })) || []; }, }, departmentIds: { @@ -327,20 +284,16 @@ export default { description: "Filters report contents to include information for specified departments if so configured in the company file", optional: true, async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Department: departments } } = await this.query({ - params: { - query: `select * from department maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Department", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), }); - return departments?.map(({ - Id: value, Name: label, - }) => ({ - value, - label, - })) || []; }, }, itemId: { @@ -348,20 +301,16 @@ export default { label: "Item Id", description: "The identifier of an item", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Item: items } } = await this.query({ - params: { - query: `select * from item maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Item", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), }); - return items?.map(({ - Id: value, Name: label, - }) => ({ - value, - label, - })) || []; }, }, billId: { @@ -369,15 +318,11 @@ export default { label: "Bill Id", description: "The identifier of a bill", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { Bill: bills } } = await this.query({ - params: { - query: `select * from bill maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "Bill", + mapper: ({ Id: id }) => id, }); - return bills?.map(({ Id: id }) => id ) || []; }, }, purchaseOrderId: { @@ -385,20 +330,16 @@ export default { label: "Item Id", description: "The identifier of a purchase order", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { PurchaseOrder: purchaseOrders } } = await this.query({ - params: { - query: `select * from purchaseorder maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "PurchaseOrder", + mapper: ({ + Id: value, DocNumber, + }) => ({ + value, + label: DocNumber ?? value, + }), }); - return purchaseOrders?.map(({ - Id: value, DocNumber, - }) => ({ - value, - label: DocNumber ?? value, - })) || []; }, }, salesReceiptId: { @@ -406,20 +347,16 @@ export default { label: "Sales Receipt Id", description: "The identifier of a sales receipt", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { SalesReceipt: salesReceipts } } = await this.query({ - params: { - query: `select * from salesreceipt maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "SalesReceipt", + mapper: ({ + Id: value, DocNumber, + }) => ({ + value, + label: DocNumber ?? value, + }), }); - return salesReceipts?.map(({ - Id: value, DocNumber, - }) => ({ - value, - label: DocNumber ?? value, - })) || []; }, }, timeActivityId: { @@ -427,20 +364,16 @@ export default { label: "Time Activity Id", description: "The identifier of a time activity", async options({ page }) { - const position = 1 + (page * 10); - const { QueryResponse: { TimeActivity: timeActivities } } = await this.query({ - params: { - query: `select * from timeactivity maxresults 10 ${page - ? `startposition ${position}` - : ""} `, - }, + return this.getPropOptions({ + page, + resource: "TimeActivity", + mapper: ({ + Id: value, NameOf: nameOf, Description: description, + }) => ({ + value, + label: `${nameOf} ${description}`, + }), }); - return timeActivities?.map(({ - Id: value, NameOf: nameOf, Description: description, - }) => ({ - value, - label: `${nameOf} ${description}`, - })) || []; }, }, }, @@ -471,6 +404,20 @@ export default { }; return await retryWithExponentialBackoff(requestFn); }, + async getPropOptions({ + page, resource, mapper, + }) { + const position = 1 + (page * 10); + const { QueryResponse: queryResponse } = await this.query({ + params: { + query: `select * from ${resource} maxresults 10${page + ? `startposition ${position}` + : ""} `, + }, + }); + const items = queryResponse[resource]; + return items?.map(mapper) || []; + }, createPayment(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/payment`, From 3917f8dd7f7bcc2f93cca5e44d832169339f87d7 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 16:58:18 -0500 Subject: [PATCH 07/19] pnpm-lock.yaml --- pnpm-lock.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ff4c581e1cac3..ace1a7ddaaa69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8161,6 +8161,9 @@ importers: dependencies: '@pipedream/platform': 3.0.0 + components/quickbooks_sandbox: + specifiers: {} + components/quickemailverification: specifiers: '@pipedream/platform': ^1.1.0 From 27272a3750f4e15977e198e7a120b47afed91914 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 17:10:02 -0500 Subject: [PATCH 08/19] update versions --- .../actions/create-ap-aging-report/create-ap-aging-report.mjs | 2 +- components/quickbooks/actions/create-bill/create-bill.mjs | 2 +- .../quickbooks/actions/create-customer/create-customer.mjs | 2 +- components/quickbooks/actions/create-invoice/create-invoice.mjs | 2 +- components/quickbooks/actions/create-payment/create-payment.mjs | 2 +- .../quickbooks/actions/create-pl-report/create-pl-report.mjs | 2 +- .../quickbooks/actions/create-purchase/create-purchase.mjs | 2 +- .../actions/create-sales-receipt/create-sales-receipt.mjs | 2 +- .../quickbooks/actions/delete-purchase/delete-purchase.mjs | 2 +- components/quickbooks/actions/get-bill/get-bill.mjs | 2 +- components/quickbooks/actions/get-customer/get-customer.mjs | 2 +- components/quickbooks/actions/get-invoice/get-invoice.mjs | 2 +- components/quickbooks/actions/get-my-company/get-my-company.mjs | 2 +- .../actions/get-purchase-order/get-purchase-order.mjs | 2 +- components/quickbooks/actions/get-purchase/get-purchase.mjs | 2 +- .../quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs | 2 +- .../quickbooks/actions/get-time-activity/get-time-activity.mjs | 2 +- .../quickbooks/actions/search-accounts/search-accounts.mjs | 2 +- .../quickbooks/actions/search-customers/search-customers.mjs | 2 +- .../quickbooks/actions/search-invoices/search-invoices.mjs | 2 +- components/quickbooks/actions/search-items/search-items.mjs | 2 +- .../quickbooks/actions/search-products/search-products.mjs | 2 +- .../quickbooks/actions/search-purchases/search-purchases.mjs | 2 +- components/quickbooks/actions/search-query/search-query.mjs | 2 +- .../actions/search-time-activities/search-time-activities.mjs | 2 +- components/quickbooks/actions/search-vendors/search-vendors.mjs | 2 +- .../actions/sparse-update-invoice/sparse-update-invoice.mjs | 2 +- .../quickbooks/actions/update-customer/update-customer.mjs | 2 +- .../sources/new-customer-created/new-customer-created.mjs | 2 +- .../sources/new-customer-updated/new-customer-updated.mjs | 2 +- .../sources/new-invoice-created/new-invoice-created.mjs | 2 +- .../sources/new-invoice-updated/new-invoice-updated.mjs | 2 +- .../quickbooks/sources/new-item-created/new-item-created.mjs | 2 +- .../quickbooks/sources/new-item-updated/new-item-updated.mjs | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/components/quickbooks/actions/create-ap-aging-report/create-ap-aging-report.mjs b/components/quickbooks/actions/create-ap-aging-report/create-ap-aging-report.mjs index a93338dc8b751..4a884cf0d3329 100644 --- a/components/quickbooks/actions/create-ap-aging-report/create-ap-aging-report.mjs +++ b/components/quickbooks/actions/create-ap-aging-report/create-ap-aging-report.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-ap-aging-report", name: "Create AP Aging Detail Report", description: "Creates an AP aging report in Quickbooks Online. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/apagingdetail#query-a-report)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index d9fe37f9f3970..5e2160540f274 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-bill", name: "Create Bill", description: "Creates a bill. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#create-a-bill)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-customer/create-customer.mjs b/components/quickbooks/actions/create-customer/create-customer.mjs index 0f6c4ff8d4e94..5f84441dc41a0 100644 --- a/components/quickbooks/actions/create-customer/create-customer.mjs +++ b/components/quickbooks/actions/create-customer/create-customer.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-customer", name: "Create Customer", description: "Creates a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 3cf0cce381fd9..36a0c5d1d0650 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-invoice", name: "Create Invoice", description: "Creates an invoice. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-payment/create-payment.mjs b/components/quickbooks/actions/create-payment/create-payment.mjs index 4404ff82dc8bd..ba0c30b1c9169 100644 --- a/components/quickbooks/actions/create-payment/create-payment.mjs +++ b/components/quickbooks/actions/create-payment/create-payment.mjs @@ -4,7 +4,7 @@ export default { key: "quickbooks-create-payment", name: "Create Payment", description: "Creates a payment. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#create-a-payment)", - version: "0.0.5", + version: "0.0.6", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-pl-report/create-pl-report.mjs b/components/quickbooks/actions/create-pl-report/create-pl-report.mjs index 54cf14deec88d..a5d6319aea029 100644 --- a/components/quickbooks/actions/create-pl-report/create-pl-report.mjs +++ b/components/quickbooks/actions/create-pl-report/create-pl-report.mjs @@ -7,7 +7,7 @@ export default { key: "quickbooks-create-pl-report", name: "Create Profit and Loss Detail Report", description: "Creates a profit and loss report in Quickbooks Online. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/profitandloss#query-a-report)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index ffb0db0e4d701..4c585b6b3b0e5 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-purchase", name: "Create Purchase", description: "Creates a new purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#create-a-purchase)", - version: "0.0.4", + version: "0.0.5", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs index 02d9f84627e96..a2e4b30492da5 100644 --- a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs +++ b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-create-sales-receipt", name: "Create Sales Receipt", description: "Creates a sales receipt. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt#create-a-salesreceipt)", - version: "0.0.5", + version: "0.0.6", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index afa3c5a275171..ba6b7c71cb54a 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -4,7 +4,7 @@ export default { key: "quickbooks-delete-purchase", name: "Delete Purchase", description: "Delete a specific purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#delete-a-purchase)", - version: "0.0.4", + version: "0.0.5", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-bill/get-bill.mjs b/components/quickbooks/actions/get-bill/get-bill.mjs index b6c0259ddf81f..0fce44cd4fe53 100644 --- a/components/quickbooks/actions/get-bill/get-bill.mjs +++ b/components/quickbooks/actions/get-bill/get-bill.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-bill", name: "Get Bill", description: "Returns info about a bill. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill#read-a-bill)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-customer/get-customer.mjs b/components/quickbooks/actions/get-customer/get-customer.mjs index 92b0af02ea0bd..190046788266b 100644 --- a/components/quickbooks/actions/get-customer/get-customer.mjs +++ b/components/quickbooks/actions/get-customer/get-customer.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-customer", name: "Get Customer", description: "Returns info about a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer#read-a-customer)", - version: "0.3.6", + version: "0.3.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-invoice/get-invoice.mjs b/components/quickbooks/actions/get-invoice/get-invoice.mjs index 353771d5b2c3c..26f8145d70ab4 100644 --- a/components/quickbooks/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks/actions/get-invoice/get-invoice.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-invoice", name: "Get Invoice", description: "Returns info about an invoice. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#read-an-invoice)", - version: "0.2.7", + version: "0.2.8", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-my-company/get-my-company.mjs b/components/quickbooks/actions/get-my-company/get-my-company.mjs index cbd19efdbe294..7a2a44887c548 100644 --- a/components/quickbooks/actions/get-my-company/get-my-company.mjs +++ b/components/quickbooks/actions/get-my-company/get-my-company.mjs @@ -4,7 +4,7 @@ export default { key: "quickbooks-get-my-company", name: "Get My Company", description: "Gets info about a company. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs index e152daea54558..90d7ca3c57ccf 100644 --- a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs +++ b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-purchase-order", name: "Get Purchase Order", description: "Returns details about a purchase order. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchaseorder#read-a-purchase-order)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-purchase/get-purchase.mjs b/components/quickbooks/actions/get-purchase/get-purchase.mjs index 899a94fcc975d..3cf88468da4b8 100644 --- a/components/quickbooks/actions/get-purchase/get-purchase.mjs +++ b/components/quickbooks/actions/get-purchase/get-purchase.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-purchase", name: "Get Purchase", description: "Returns info about a purchase. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#read-a-purchase)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs index ec71a3156e0cb..11ae01381ca61 100644 --- a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs +++ b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-sales-receipt", name: "Get Sales Receipt", description: "Returns details about a sales receipt. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt#read-a-salesreceipt)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs index b19cabf0772a6..27170910b05c5 100644 --- a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs +++ b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-get-time-activity", name: "Get Time Activity", description: "Returns info about an activity. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#read-a-timeactivity-object)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index 263ac46b154ee..015084b87f94c 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-accounts", name: "Search Accounts", description: "Search for accounts. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#query-an-account)", - version: "0.2.6", + version: "0.2.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 4cf5bf956bcfd..6836ae8741486 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-customers", name: "Search Customers", description: "Searches for customers. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#query-a-customer)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index fbc54cdd957f2..2882011ac4685 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-invoices", name: "Search Invoices", description: "Searches for invoices. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index a9cc83fa7c9a8..90413e3aaccdf 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-items", name: "Search Items", description: "Searches for items. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index 4db7a0472e3e3..8c3b34fee1d9d 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-products", name: "Search Products", description: "Search for products. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#query-an-item)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-purchases/search-purchases.mjs b/components/quickbooks/actions/search-purchases/search-purchases.mjs index b66c7694d63d8..08ab964c572af 100644 --- a/components/quickbooks/actions/search-purchases/search-purchases.mjs +++ b/components/quickbooks/actions/search-purchases/search-purchases.mjs @@ -4,7 +4,7 @@ export default { key: "quickbooks-search-purchases", name: "Search Purchases", description: "Searches for purchases. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase#query-a-purchase)", - version: "0.0.4", + version: "0.0.5", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-query/search-query.mjs b/components/quickbooks/actions/search-query/search-query.mjs index d54c48680cc60..3b405f6cbf2d0 100644 --- a/components/quickbooks/actions/search-query/search-query.mjs +++ b/components/quickbooks/actions/search-query/search-query.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-query", name: "Search Query", description: "Performs a search query against a Quickbooks entity. [See the documentation](https://developer.intuit.com/app/develophttps://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index c02bcd127c026..2fd889604188e 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-time-activities", name: "Search Time Activities", description: "Searches for time activities. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/timeactivity#query-a-timeactivity-object)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index c79a12bc2c83f..0fd23852b224d 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-vendors", name: "Search Vendors", description: "Searches for vendors. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendor#query-a-vendor)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index 695e4eb636073..be716b6c7d334 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-sparse-update-invoice", name: "Sparse Update Invoice", description: "Sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched. The ID of the object to update is specified in the request body.​ [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#sparse-update-an-invoice)", - version: "0.1.4", + version: "0.1.5", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index 22de4309589f9..512dcac4e5205 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-update-customer", name: "Update Customer", description: "Updates a customer. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#full-update-a-customer)", - version: "0.1.6", + version: "0.1.7", type: "action", props: { quickbooks, diff --git a/components/quickbooks/sources/new-customer-created/new-customer-created.mjs b/components/quickbooks/sources/new-customer-created/new-customer-created.mjs index 9a8bb766a1aa3..3a7fbc0afbc8c 100644 --- a/components/quickbooks/sources/new-customer-created/new-customer-created.mjs +++ b/components/quickbooks/sources/new-customer-created/new-customer-created.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-customer-created", name: "New Customer Created", description: "Emit new event when a new customer is created.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs b/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs index 84c4817515440..48c8ccb2455f1 100644 --- a/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs +++ b/components/quickbooks/sources/new-customer-updated/new-customer-updated.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-customer-updated", name: "New Customer Updated", description: "Emit new event when a customer is updated.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs b/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs index d234c78995cc1..10f85fcfd6882 100644 --- a/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs +++ b/components/quickbooks/sources/new-invoice-created/new-invoice-created.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-invoice-created", name: "New Invoice Created", description: "Emit new event when a new invoice is created.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-invoice-updated/new-invoice-updated.mjs b/components/quickbooks/sources/new-invoice-updated/new-invoice-updated.mjs index f9d2f68c20417..a72b770e9c70a 100644 --- a/components/quickbooks/sources/new-invoice-updated/new-invoice-updated.mjs +++ b/components/quickbooks/sources/new-invoice-updated/new-invoice-updated.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-invoice-updated", name: "New Invoice Updated", description: "Emit new event when an invoice is updated.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-item-created/new-item-created.mjs b/components/quickbooks/sources/new-item-created/new-item-created.mjs index adcdf4db7d249..eb78a15a6d7b5 100644 --- a/components/quickbooks/sources/new-item-created/new-item-created.mjs +++ b/components/quickbooks/sources/new-item-created/new-item-created.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-item-created", name: "New Item Created", description: "Emit new event when a new item is created.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-item-updated/new-item-updated.mjs b/components/quickbooks/sources/new-item-updated/new-item-updated.mjs index 02a64206cb400..6aa670c1e1efe 100644 --- a/components/quickbooks/sources/new-item-updated/new-item-updated.mjs +++ b/components/quickbooks/sources/new-item-updated/new-item-updated.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-item-updated", name: "New Item Updated", description: "Emit new event when an item is updated.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", methods: { From 52adecd16664a5820158eaf3e857479bbf4c0cfe Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 17:29:26 -0500 Subject: [PATCH 09/19] fixes --- .../actions/delete-purchase/delete-purchase.mjs | 4 ++-- components/quickbooks/actions/update-item/update-item.mjs | 8 ++++---- components/quickbooks/quickbooks.app.mjs | 2 +- components/quickbooks_sandbox/quickbooks_sandbox.app.mjs | 2 +- .../sources/new-customer-created/new-customer-created.mjs | 6 +++--- .../sources/new-customer-updated/new-customer-updated.mjs | 6 +++--- .../sources/new-invoice-created/new-invoice-created.mjs | 6 +++--- .../sources/new-invoice-updated/new-invoice-updated.mjs | 6 +++--- .../sources/new-item-created/new-item-created.mjs | 6 +++--- .../sources/new-item-updated/new-item-updated.mjs | 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index ba6b7c71cb54a..0be20dcff973e 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -25,7 +25,7 @@ export default { const { quickbooks, purchaseId, - minorversion, + minorVersion, } = this; const [ @@ -40,7 +40,7 @@ export default { SyncToken, }, params: { - minorversion, + minorversion: minorVersion, operation: "delete", }, }); diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs index db51fbe3f73a8..6a75896b094f7 100644 --- a/components/quickbooks/actions/update-item/update-item.mjs +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -2,7 +2,7 @@ import quickbooks from "../../quickbooks.app.mjs"; import { ConfigurationError } from "@pipedream/platform"; export default { - key: "quickbooks_sandbox-update-item", + key: "quickbooks-update-item", name: "Update Item", description: "Updates an item. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#full-update-an-item)", version: "0.0.1", @@ -102,7 +102,7 @@ export default { optional: true, }, salesTaxIncluded: { - type: "string", + type: "boolean", label: "Sales Tax Included", description: "True if the sales tax is included in the item amount, and therefore is not calculated for the transaction.", optional: true, @@ -339,7 +339,7 @@ export default { }, }; - if (this.prefVendorRefValue || this.parentRefName) { + if (this.parentRefValue || this.parentRefName) { data["ParentRef"] = { value: this.parentRefValue, name: this.parentRefName, @@ -350,7 +350,7 @@ export default { $, data, params: { - minorversion: this.minorversion, + minorversion: this.minorVersion, }, }); diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index d86b9fe8b05ae..55d74558f571e 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -327,7 +327,7 @@ export default { }, purchaseOrderId: { type: "string", - label: "Item Id", + label: "Purchase Order Id", description: "The identifier of a purchase order", async options({ page }) { return this.getPropOptions({ diff --git a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs index 80cf5c066d291..c1ee8dd8f6498 100644 --- a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs +++ b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs @@ -5,7 +5,7 @@ export default { type: "app", app: "quickbooks_sandbox", methods: { - ...common.mehtods, + ...common.methods, _apiUrl() { return "https://quickbooks.api.intuit.com/v3"; }, diff --git a/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs b/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs index b3b6adadb9404..5e49436884362 100644 --- a/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs +++ b/components/quickbooks_sandbox/sources/new-customer-created/new-customer-created.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-customer-created/new-customer-created.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-customer-created/new-customer-created.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; diff --git a/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs b/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs index b6d8ce2dc3a14..1a29d984d3675 100644 --- a/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs +++ b/components/quickbooks_sandbox/sources/new-customer-updated/new-customer-updated.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-customer-updated/new-customer-updated.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-customer-updated/new-customer-updated.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; diff --git a/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs b/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs index 755104c6d78cf..e569f8efce424 100644 --- a/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs +++ b/components/quickbooks_sandbox/sources/new-invoice-created/new-invoice-created.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-invoice-created/new-invoice-created.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-invoice-created/new-invoice-created.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; diff --git a/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs b/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs index db858e8a82fbd..11082efbf92a5 100644 --- a/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs +++ b/components/quickbooks_sandbox/sources/new-invoice-updated/new-invoice-updated.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-invoice-updated/new-invoice-updated.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-invoice-updated/new-invoice-updated.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; diff --git a/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs b/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs index 0f7fd105304ee..a255e518526cf 100644 --- a/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs +++ b/components/quickbooks_sandbox/sources/new-item-created/new-item-created.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-item-created/new-item-created.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-item-created/new-item-created.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; diff --git a/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs b/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs index bcf3aacf648eb..9551cc13c1181 100644 --- a/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs +++ b/components/quickbooks_sandbox/sources/new-item-updated/new-item-updated.mjs @@ -1,5 +1,5 @@ -import app from "../../monday_oauth.app.mjs"; -import common from "../../../monday/sources/new-item-updated/new-item-updated.mjs"; +import app from "../../quickbooks_sandbox.app.mjs"; +import common from "../../../quickbooks/sources/new-item-updated/new-item-updated.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; @@ -16,7 +16,7 @@ export default { description, type, props: { - monday: app, + quickbooks: app, ...props, }, }; From 92a5c92f348eb6ed17ed7c15c425e70cbcb2f11f Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 21 Nov 2024 17:42:22 -0500 Subject: [PATCH 10/19] fix path --- .../actions/create-pl-report/create-pl-report.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs b/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs index b9c67c97dcdfd..5c1102af61302 100644 --- a/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs +++ b/components/quickbooks_sandbox/actions/create-pl-report/create-pl-report.mjs @@ -1,5 +1,5 @@ import app from "../../quickbooks_sandbox.app.mjs"; -import common from "../../../quickbooks/actions/create-plreport/create-pl-report.mjs"; +import common from "../../../quickbooks/actions/create-pl-report/create-pl-report.mjs"; import { adjustPropDefinitions } from "../../common/utils.mjs"; From 01761c2870d7b5c3bbdbb5149cbd856a14f13f90 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 22 Nov 2024 15:29:18 -0500 Subject: [PATCH 11/19] add get-payment --- .../actions/get-payment/get-payment.mjs | 44 +++++++++++++++++++ components/quickbooks/quickbooks.app.mjs | 27 +++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 components/quickbooks/actions/get-payment/get-payment.mjs diff --git a/components/quickbooks/actions/get-payment/get-payment.mjs b/components/quickbooks/actions/get-payment/get-payment.mjs new file mode 100644 index 0000000000000..bbfec932cf87a --- /dev/null +++ b/components/quickbooks/actions/get-payment/get-payment.mjs @@ -0,0 +1,44 @@ +import { ConfigurationError } from "@pipedream/platform"; +import quickbooks from "../../quickbooks.app.mjs"; + +export default { + key: "quickbooks-get-payment", + name: "Get Payment", + description: "Returns info about a payment. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#read-a-payment)", + version: "0.0.1", + type: "action", + props: { + quickbooks, + paymentId: { + propDefinition: [ + quickbooks, + "paymentId", + ], + }, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], + }, + }, + async run({ $ }) { + if (!this.paymentId) { + throw new ConfigurationError("Must provide paymentId parameter."); + } + + const response = await this.quickbooks.getPayment({ + $, + paymentId: this.paymentId, + params: { + minorversion: this.minorVersion, + }, + }); + + if (response) { + $.export("summary", `Successfully retrieved payment with id ${response.Payment.Id}`); + } + + return response; + }, +}; diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index 55d74558f571e..42461d42fa4eb 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -149,7 +149,7 @@ export default { optional: true, }, purchaseId: { - label: "purchase Id", + label: "Purchase Id", type: "string", description: "Id of the purchase.", withLabel: true, @@ -376,6 +376,23 @@ export default { }); }, }, + paymentId: { + type: "string", + label: "Payment Id", + description: "The identifier of a payment", + async options({ page }) { + return this.getPropOptions({ + page, + resource: "Payment", + mapper: ({ + Id: value, CustomerRef: customerRef, TotalAmt: totalAmt, TxnDate: txnDate, + }) => ({ + value, + label: `${customerRef.name} - Amount: ${totalAmt} - ${txnDate}`, + }), + }); + }, + }, }, methods: { _companyId() { @@ -535,6 +552,14 @@ export default { ...opts, }); }, + getPayment({ + paymentId, ...opts + }) { + return this._makeRequest({ + path: `company/${this._companyId()}/payment/${paymentId}`, + ...opts, + }); + }, query(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/query`, From 9db325919c07c62a7a4ab8c544b66026cb97a394 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 3 Dec 2024 10:32:41 -0500 Subject: [PATCH 12/19] wip --- .../actions/create-bill/create-bill.mjs | 110 ++++++++++++------ .../create-customer/create-customer.mjs | 11 +- .../actions/create-invoice/create-invoice.mjs | 105 +++++++++++------ .../create-purchase/create-purchase.mjs | 9 -- .../delete-purchase/delete-purchase.mjs | 8 -- .../quickbooks/actions/get-bill/get-bill.mjs | 9 -- .../actions/get-customer/get-customer.mjs | 9 -- .../actions/get-invoice/get-invoice.mjs | 9 -- .../actions/get-payment/get-payment.mjs | 9 -- .../get-purchase-order/get-purchase-order.mjs | 10 +- .../actions/get-purchase/get-purchase.mjs | 9 -- .../get-sales-receipt/get-sales-receipt.mjs | 9 -- .../get-time-activity/get-time-activity.mjs | 10 +- .../search-accounts/search-accounts.mjs | 7 -- .../search-customers/search-customers.mjs | 7 -- .../search-invoices/search-invoices.mjs | 7 -- .../actions/search-items/search-items.mjs | 7 -- .../search-products/search-products.mjs | 7 -- .../search-purchases/search-purchases.mjs | 7 -- .../actions/search-query/search-query.mjs | 7 -- .../search-services/search-services.mjs | 7 -- .../search-time-activities.mjs | 7 -- .../actions/search-vendors/search-vendors.mjs | 7 -- .../sparse-update-invoice.mjs | 9 -- .../update-customer/update-customer.mjs | 9 -- .../actions/update-item/update-item.mjs | 9 -- components/quickbooks/quickbooks.app.mjs | 18 +-- .../quickbooks_sandbox.app.mjs | 2 +- 28 files changed, 157 insertions(+), 277 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index 5e2160540f274..cb3341271b74b 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -15,52 +15,93 @@ export default { "vendorIds", ], type: "string", - label: "Vendor Ref Value", - description: "Reference to the vendor for this transaction. Query the Vendor name list resource to determine the appropriate Vendor object for this reference. Use `Vendor.Id` from that object for `VendorRef.value`.", - }, - lineItems: { - description: "Individual line items of a transaction. Valid Line types include: `ItemBasedExpenseLine` and `AccountBasedExpenseLine`. One minimum line item required for the request to succeed. E.g `[ { \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 200.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"value\": \"1\" } } } ]`", - propDefinition: [ - quickbooks, - "lineItems", - ], - }, - vendorRefName: { - label: "Vendor Reference Name", - type: "string", - description: "Reference to the vendor for this transaction. Query the Vendor name list resource to determine the appropriate Vendor object for this reference. Use `Vendor.Name` from that object for `VendorRef.name`.", - optional: true, + label: "Vendor ID", + description: "Reference to the vendor for this transaction", }, currencyRefValue: { propDefinition: [ quickbooks, - "currencyRefValue", + "currency", ], }, - currencyRefName: { + lineItemsAsObjects: { propDefinition: [ quickbooks, - "currencyRefName", + "lineItemsAsObjects", ], + reloadProps: true, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], + }, + async additionalProps() { + const props = {}; + if (this.lineItemsAsObjects) { + props.lineItems = { + type: "string[]", + label: "Line Items", + description: "Line items of a bill. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", + }; + return props; + } + props.numLineItems = { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`account_${i}`] = { + type: "string", + label: `Line ${i} - Account ID`, + options: await this.quickbooks.getPropOptions({ + resource: "Account", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }), + }; + props[`amount_${i}`] = { + type: "string", + label: `Line ${i} - Amount`, + }; + } + return props; + }, + methods: { + buildLineItems() { + const lineItems = []; + for (let i = 1; i <= this.numLineItems; i++) { + lineItems.push({ + DetailType: "AccountBasedExpenseLineDetail", + Amount: this[`amount_${i}`], + AccountBasedExpenseLineDetail: { + AccountRef: { + value: this[`account_${i}`], + }, + }, + }); + } + return lineItems; }, }, async run({ $ }) { - if (!this.vendorRefValue || !this.lineItems) { + if (!this.vendorRefValue || (!this.numLineItems && !this.lineItemsAsObjects)) { throw new ConfigurationError("Must provide vendorRefValue, and lineItems parameters."); } - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + if (this.lineItemsAsObjects) { + try { + this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" + ? JSON.parse(lineItem) + : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + } } const response = await this.quickbooks.createBill({ @@ -68,21 +109,16 @@ export default { data: { VendorRef: { value: this.vendorRefValue, - name: this.vendorRefName, }, - Line: this.lineItems, + Line: this.buildLineItems(), CurrencyRef: { value: this.currencyRefValue, - name: this.currencyRefName, }, }, - params: { - minorversion: this.minorVersion, - }, }); if (response) { - $.export("summary", `Successfully created bill with id ${response.Bill.Id}`); + $.export("summary", `Successfully created bill with ID ${response.Bill.Id}`); } return response; diff --git a/components/quickbooks/actions/create-customer/create-customer.mjs b/components/quickbooks/actions/create-customer/create-customer.mjs index 5f84441dc41a0..7d2569c86eb4a 100644 --- a/components/quickbooks/actions/create-customer/create-customer.mjs +++ b/components/quickbooks/actions/create-customer/create-customer.mjs @@ -45,12 +45,6 @@ export default { "suffix", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if ( @@ -70,13 +64,10 @@ export default { FamilyName: this.familyName, GivenName: this.givenName, }, - params: { - minorversion: this.minorVersion, - }, }); if (response) { - $.export("summary", `Successfully created customer with id ${response.Customer.Id}`); + $.export("summary", `Successfully created customer with ID ${response.Customer.Id}`); } return response; diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 36a0c5d1d0650..215ffbcb708c5 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -9,76 +9,113 @@ export default { type: "action", props: { quickbooks, - lineItems: { - propDefinition: [ - quickbooks, - "lineItems", - ], - }, customerRefValue: { propDefinition: [ quickbooks, "customer", ], }, - customerRefName: { - propDefinition: [ - quickbooks, - "customerRefName", - ], - }, currencyRefValue: { propDefinition: [ quickbooks, - "currencyRefValue", + "currency", ], }, - currencyRefName: { + lineItemsAsObjects: { propDefinition: [ quickbooks, - "currencyRefName", + "lineItemsAsObjects", ], + reloadProps: true, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], + }, + async additionalProps() { + const props = {}; + if (this.lineItemsAsObjects) { + props.lineItems = { + type: "string[]", + label: "Line Items", + description: "Line items of an invoice. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + }; + return props; + } + props.numLineItems = { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`item_${i}`] = { + type: "string", + label: `Line ${i} - Item ID`, + options: await this.quickbooks.getPropOptions({ + resource: "Item", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }), + }; + props[`amount_${i}`] = { + type: "string", + label: `Line ${i} - Amount`, + }; + } + return props; + }, + methods: { + buildLineItems() { + const lineItems = []; + for (let i = 1; i <= this.numLineItems; i++) { + lineItems.push({ + DetailType: "SalesItemLineDetail", + Amount: this[`amount_${i}`], + SalesItemLineDetail: { + ItemRef: { + value: this[`item_${i}`], + }, + }, + }); + } + return lineItems; }, }, async run({ $ }) { - if (!this.lineItems || !this.customerRefValue) { + if ((!this.numLineItems && !this.lineItemsAsObjects) || !this.customerRefValue) { throw new ConfigurationError("Must provide lineItems, and customerRefValue parameters."); } - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + if (this.lineItemsAsObjects) { + try { + this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" + ? JSON.parse(lineItem) + : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + } } const response = await this.quickbooks.createInvoice({ $, data: { - Line: this.lineItems, + Line: this.buildLineItems(), CustomerRef: { value: this.customerRefValue, - name: this.customerRefName, }, CurrencyRef: { value: this.currencyRefValue, - name: this.currencyRefName, }, }, - params: { - minorversion: this.minorVersion, - }, }); if (response) { - $.export("summary", `Successfully created invoice with id ${response.Invoice.Id}`); + $.export("summary", `Successfully created invoice with ID ${response.Invoice.Id}`); } return response; diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index 4c585b6b3b0e5..b07b158a22bc7 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -52,12 +52,6 @@ export default { "currencyRefName", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { let parsedLineItems = parseOne(this.lineItems); @@ -78,9 +72,6 @@ export default { name: this.currencyRefName, }, }, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index 0be20dcff973e..1d2d1b57479de 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -14,18 +14,11 @@ export default { "purchaseId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { const { quickbooks, purchaseId, - minorVersion, } = this; const [ @@ -40,7 +33,6 @@ export default { SyncToken, }, params: { - minorversion: minorVersion, operation: "delete", }, }); diff --git a/components/quickbooks/actions/get-bill/get-bill.mjs b/components/quickbooks/actions/get-bill/get-bill.mjs index 0fce44cd4fe53..04d0d3a7d73e8 100644 --- a/components/quickbooks/actions/get-bill/get-bill.mjs +++ b/components/quickbooks/actions/get-bill/get-bill.mjs @@ -15,12 +15,6 @@ export default { "billId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.billId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getBill({ $, billId: this.billId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-customer/get-customer.mjs b/components/quickbooks/actions/get-customer/get-customer.mjs index 190046788266b..92d193e6598f1 100644 --- a/components/quickbooks/actions/get-customer/get-customer.mjs +++ b/components/quickbooks/actions/get-customer/get-customer.mjs @@ -15,12 +15,6 @@ export default { "customer", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.customerId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getCustomer({ $, customerId: this.customerId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-invoice/get-invoice.mjs b/components/quickbooks/actions/get-invoice/get-invoice.mjs index 26f8145d70ab4..798aca1c6a6df 100644 --- a/components/quickbooks/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks/actions/get-invoice/get-invoice.mjs @@ -15,12 +15,6 @@ export default { "invoiceId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.invoiceId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getInvoice({ $, invoiceId: this.invoiceId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-payment/get-payment.mjs b/components/quickbooks/actions/get-payment/get-payment.mjs index bbfec932cf87a..405193fa01a48 100644 --- a/components/quickbooks/actions/get-payment/get-payment.mjs +++ b/components/quickbooks/actions/get-payment/get-payment.mjs @@ -15,12 +15,6 @@ export default { "paymentId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.paymentId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getPayment({ $, paymentId: this.paymentId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs index 90d7ca3c57ccf..6cdb78a5e8b39 100644 --- a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs +++ b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs @@ -15,12 +15,6 @@ export default { "purchaseOrderId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.purchaseOrderId) { @@ -30,9 +24,7 @@ export default { const response = await this.quickbooks.getPurchaseOrder({ $, purchaseOrderId: this.purchaseOrderId, - params: { - minorversion: this.minorVersion, - }, + params: {}, }); if (response) { diff --git a/components/quickbooks/actions/get-purchase/get-purchase.mjs b/components/quickbooks/actions/get-purchase/get-purchase.mjs index 3cf88468da4b8..cc45157a2a8b0 100644 --- a/components/quickbooks/actions/get-purchase/get-purchase.mjs +++ b/components/quickbooks/actions/get-purchase/get-purchase.mjs @@ -15,12 +15,6 @@ export default { "purchaseId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.purchaseId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getPurchase({ $, purchaseId: this.purchaseId?.value ?? this.purchaseId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs index 11ae01381ca61..80ae6ecc1da00 100644 --- a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs +++ b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs @@ -15,12 +15,6 @@ export default { "salesReceiptId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.salesReceiptId) { @@ -30,9 +24,6 @@ export default { const response = await this.quickbooks.getSalesReceipt({ $, salesReceiptId: this.salesReceiptId, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs index 27170910b05c5..1098f08cb4b26 100644 --- a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs +++ b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs @@ -15,12 +15,6 @@ export default { "timeActivityId", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.timeActivityId) { @@ -30,9 +24,7 @@ export default { const response = await this.quickbooks.getTimeActivity({ $, timeActivityId: this.timeActivityId, - params: { - minorversion: this.minorVersion, - }, + params: {}, }); if (response) { diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index 015084b87f94c..29b1601c2804d 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -73,7 +67,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 6836ae8741486..22e2939d74017 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -73,7 +67,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index 2882011ac4685..bdcd1db624871 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index 90413e3aaccdf..066e5982acfe2 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index 8c3b34fee1d9d..ec225b59fd190 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-purchases/search-purchases.mjs b/components/quickbooks/actions/search-purchases/search-purchases.mjs index 08ab964c572af..41e7c2fe42ff2 100644 --- a/components/quickbooks/actions/search-purchases/search-purchases.mjs +++ b/components/quickbooks/actions/search-purchases/search-purchases.mjs @@ -33,12 +33,6 @@ export default { ], optional: true, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { const whereClause = this.whereClause @@ -62,7 +56,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-query/search-query.mjs b/components/quickbooks/actions/search-query/search-query.mjs index 3b405f6cbf2d0..4a71284e3f609 100644 --- a/components/quickbooks/actions/search-query/search-query.mjs +++ b/components/quickbooks/actions/search-query/search-query.mjs @@ -14,12 +14,6 @@ export default { type: "string", description: "A search query against a Quickbooks entity. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.searchQuery) { @@ -29,7 +23,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query: this.searchQuery, }, }); diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index e1b61476b2f08..35edc8aa48772 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -41,12 +41,6 @@ export default { "maxResults", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.include_clause || !this.where_clause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index 2fd889604188e..c272b124f0cb5 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index 0fd23852b224d..0f29aaa6fc567 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -41,12 +41,6 @@ export default { ], optional: false, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.includeClause || !this.whereClause) { @@ -70,7 +64,6 @@ export default { const response = await this.quickbooks.query({ $, params: { - minorversion: this.minorVersion, query, }, }); diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index be716b6c7d334..6b80e9ef12931 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -34,12 +34,6 @@ export default { "currency", ], }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { try { @@ -63,9 +57,6 @@ export default { const response = await this.quickbooks.sparseUpdateInvoice({ $, data: Invoice, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index 512dcac4e5205..091f2c4496bfe 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -464,12 +464,6 @@ export default { optional: true, type: "string", }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#full-update-a-customer @@ -583,9 +577,6 @@ export default { }, TaxExemptionReasonId: this.taxExemptionReasonId, }, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs index 6a75896b094f7..21908d9671c91 100644 --- a/components/quickbooks/actions/update-item/update-item.mjs +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -263,12 +263,6 @@ export default { description: "The ID for the referenced parent item object as found in the Id field of the object payload. \n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", optional: true, }, - minorVersion: { - propDefinition: [ - quickbooks, - "minorVersion", - ], - }, }, async run({ $ }) { if (!this.itemId @@ -349,9 +343,6 @@ export default { const response = await this.quickbooks.updateItem({ $, data, - params: { - minorversion: this.minorVersion, - }, }); if (response) { diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index 42461d42fa4eb..5f00a92412e75 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -23,17 +23,16 @@ export default { }); }, }, - minorVersion: { - label: "Minor Version", - type: "string", - description: "Use the `minorversion` query parameter in REST API requests to access a version of the API other than the generally available version. For example, to invoke minor version 1 of the JournalEntry entity, issue the following request:\n`https://quickbooks.api.intuit.com/v3/company//journalentry/entityId?minorversion=1`", - optional: true, - }, lineItems: { label: "Line Items", type: "string[]", description: "Individual line items of a transaction. Valid Line types include: `ItemBasedExpenseLine` and `AccountBasedExpenseLine`. One minimum line item required for the request to succeed. E.g `[ { \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Meals and Entertainment\", \"value\": \"10\" } } } ]`", }, + lineItemsAsObjects: { + type: "boolean", + label: "Enter Line Items as Objects", + description: "Enter line items as an array of objects", + }, customer: { label: "Customer Reference", type: "string", @@ -58,10 +57,11 @@ export default { optional: true, }, currency: { - label: "Currency Reference", + label: "Currency Code", type: "string", - description: "This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", + description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", optional: true, + default: "USD", async options({ page }) { return this.getPropOptions({ page, @@ -422,7 +422,7 @@ export default { return await retryWithExponentialBackoff(requestFn); }, async getPropOptions({ - page, resource, mapper, + page = 0, resource, mapper, }) { const position = 1 + (page * 10); const { QueryResponse: queryResponse } = await this.query({ diff --git a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs index c1ee8dd8f6498..eb67fa0cd8dc1 100644 --- a/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs +++ b/components/quickbooks_sandbox/quickbooks_sandbox.app.mjs @@ -7,7 +7,7 @@ export default { methods: { ...common.methods, _apiUrl() { - return "https://quickbooks.api.intuit.com/v3"; + return "https://sandbox-quickbooks.api.intuit.com/v3"; }, }, }; From 7afacd59f70366ab4b1c89a4f10b6eaad6358d2c Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 4 Dec 2024 15:46:16 -0500 Subject: [PATCH 13/19] updates --- .../actions/create-bill/create-bill.mjs | 25 +- .../actions/create-invoice/create-invoice.mjs | 25 +- .../actions/create-payment/create-payment.mjs | 18 +- .../create-purchase/create-purchase.mjs | 104 ++++-- .../create-sales-receipt.mjs | 95 ++++-- .../delete-purchase/delete-purchase.mjs | 2 +- .../quickbooks/actions/get-bill/get-bill.mjs | 2 +- .../actions/get-customer/get-customer.mjs | 2 +- .../actions/get-invoice/get-invoice.mjs | 2 +- .../actions/get-my-company/get-my-company.mjs | 2 +- .../actions/get-payment/get-payment.mjs | 2 +- .../get-purchase-order/get-purchase-order.mjs | 2 +- .../actions/get-purchase/get-purchase.mjs | 2 +- .../get-sales-receipt/get-sales-receipt.mjs | 2 +- .../get-time-activity/get-time-activity.mjs | 2 +- .../search-accounts/search-accounts.mjs | 13 +- .../search-customers/search-customers.mjs | 13 +- .../search-invoices/search-invoices.mjs | 13 +- .../actions/search-items/search-items.mjs | 13 +- .../search-products/search-products.mjs | 13 +- .../search-services/search-services.mjs | 13 +- .../search-time-activities.mjs | 13 +- .../actions/search-vendors/search-vendors.mjs | 11 +- .../sparse-update-invoice.mjs | 89 +++++- .../update-customer/update-customer.mjs | 147 ++------- .../actions/update-item/update-item.mjs | 147 +++------ components/quickbooks/quickbooks.app.mjs | 301 +++++++++++------- 27 files changed, 557 insertions(+), 516 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index cb3341271b74b..c4486ce678310 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -55,15 +55,18 @@ export default { props[`account_${i}`] = { type: "string", label: `Line ${i} - Account ID`, - options: await this.quickbooks.getPropOptions({ - resource: "Account", - mapper: ({ - Id: value, Name: label, - }) => ({ - value, - label, - }), - }), + options: async ({ page }) => { + return this.quickbooks.getPropOptions({ + page, + resource: "Account", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, }; props[`amount_${i}`] = { type: "string", @@ -110,7 +113,9 @@ export default { VendorRef: { value: this.vendorRefValue, }, - Line: this.buildLineItems(), + Line: this.lineItemsAsObjects + ? this.lineItems + : this.buildLineItems(), CurrencyRef: { value: this.currencyRefValue, }, diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 215ffbcb708c5..da98156e5bf4b 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -52,15 +52,18 @@ export default { props[`item_${i}`] = { type: "string", label: `Line ${i} - Item ID`, - options: await this.quickbooks.getPropOptions({ - resource: "Item", - mapper: ({ - Id: value, Name: label, - }) => ({ - value, - label, - }), - }), + options: async ({ page }) => { + return this.quickbooks.getPropOptions({ + page, + resource: "Item", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, }; props[`amount_${i}`] = { type: "string", @@ -104,7 +107,9 @@ export default { const response = await this.quickbooks.createInvoice({ $, data: { - Line: this.buildLineItems(), + Line: this.lineItemsAsObjects + ? this.lineItems + : this.buildLineItems(), CustomerRef: { value: this.customerRefValue, }, diff --git a/components/quickbooks/actions/create-payment/create-payment.mjs b/components/quickbooks/actions/create-payment/create-payment.mjs index ba0c30b1c9169..bc0c3b7b92acc 100644 --- a/components/quickbooks/actions/create-payment/create-payment.mjs +++ b/components/quickbooks/actions/create-payment/create-payment.mjs @@ -19,22 +19,10 @@ export default { "customer", ], }, - customerRefName: { - propDefinition: [ - quickbooks, - "customerRefName", - ], - }, currencyRefValue: { propDefinition: [ quickbooks, - "currencyRefValue", - ], - }, - currencyRefName: { - propDefinition: [ - quickbooks, - "currencyRefName", + "currency", ], }, }, @@ -45,17 +33,15 @@ export default { TotalAmt: this.totalAmount, CustomerRef: { value: this.customerRefValue, - name: this.customerRefName, }, CurrencyRef: { value: this.currencyRefValue, - name: this.currencyRefName, }, }, }); if (response) { - $.export("summary", `Successfully created payment with id ${response.Payment.Id}`); + $.export("summary", `Successfully created payment with ID ${response.Payment.Id}`); } return response; diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index b07b158a22bc7..77136b285b822 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -1,5 +1,5 @@ -import { parseOne } from "../../common/utils.mjs"; import quickbooks from "../../quickbooks.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks-create-purchase", @@ -16,7 +16,8 @@ export default { ], type: "string", label: "Account Reference Value", - description: "Specifies the id of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", + description: "Specifies the ID of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", + optional: false, }, paymentType: { label: "Payment Type", @@ -28,33 +29,90 @@ export default { "CreditCard", ], }, - lineItems: { - propDefinition: [ - quickbooks, - "lineItems", - ], - }, - accountRefName: { - label: "Account Reference Name", - type: "string", - description: "Specifies the name of the account reference. Check must specify bank account, CreditCard must specify credit card account. Validation Rules:Valid and Active Account Reference of an appropriate type.", - optional: true, - }, currencyRefValue: { propDefinition: [ quickbooks, - "currencyRefValue", + "currency", ], }, - currencyRefName: { + lineItemsAsObjects: { propDefinition: [ quickbooks, - "currencyRefName", + "lineItemsAsObjects", ], + reloadProps: true, + }, + }, + async additionalProps() { + const props = {}; + if (this.lineItemsAsObjects) { + props.lineItems = { + type: "string[]", + label: "Line Items", + description: "Line items of a purchase. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", + }; + return props; + } + props.numLineItems = { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`account_${i}`] = { + type: "string", + label: `Line ${i} - Account ID`, + options: async ({ page }) => { + return this.quickbooks.getPropOptions({ + page, + resource: "Account", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, + }; + props[`amount_${i}`] = { + type: "string", + label: `Line ${i} - Amount`, + }; + } + return props; + }, + methods: { + buildLineItems() { + const lineItems = []; + for (let i = 1; i <= this.numLineItems; i++) { + lineItems.push({ + DetailType: "AccountBasedExpenseLineDetail", + Amount: this[`amount_${i}`], + AccountBasedExpenseLineDetail: { + AccountRef: { + value: this[`account_${i}`], + }, + }, + }); + } + return lineItems; }, }, async run({ $ }) { - let parsedLineItems = parseOne(this.lineItems); + if (this.lineItemsAsObjects) { + try { + this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" + ? JSON.parse(lineItem) + : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + } + } const response = await this.quickbooks.createPurchase({ $, @@ -62,20 +120,18 @@ export default { PaymentType: this.paymentType, AccountRef: { value: this.accountRefValue, - name: this.accountRefName, }, - Line: parsedLineItems.length - ? parsedLineItems.map((item) => parseOne(item)) - : [], + Line: this.lineItemsAsObjects + ? this.lineItems + : this.buildLineItems(), CurrencyRef: { value: this.currencyRefValue, - name: this.currencyRefName, }, }, }); if (response) { - $.export("summary", `Successfully created purchase with id ${response.Purchase.Id}`); + $.export("summary", `Successfully created purchase with ID ${response.Purchase.Id}`); } return response; diff --git a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs index a2e4b30492da5..d60b44bebd25c 100644 --- a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs +++ b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs @@ -9,12 +9,6 @@ export default { type: "action", props: { quickbooks, - lineItems: { - propDefinition: [ - quickbooks, - "lineItems", - ], - }, currencyRefValue: { propDefinition: [ quickbooks, @@ -22,50 +16,99 @@ export default { ], optional: true, }, - currencyRefName: { + lineItemsAsObjects: { propDefinition: [ quickbooks, - "currencyRefName", + "lineItemsAsObjects", ], - optional: true, + reloadProps: true, }, }, + async additionalProps() { + const props = {}; + if (this.lineItemsAsObjects) { + props.lineItems = { + type: "string[]", + label: "Line Items", + description: "Line items of a sales receipt. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + }; + return props; + } + props.numLineItems = { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`item_${i}`] = { + type: "string", + label: `Line ${i} - Item ID`, + options: async ({ page }) => { + return this.quickbooks.getPropOptions({ + page, + resource: "Item", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, + }; + props[`amount_${i}`] = { + type: "string", + label: `Line ${i} - Amount`, + }; + } + return props; + }, methods: { - async createSalesReceipt({ - $, data, - }) { - return this.quickbooks._makeRequest(`company/${this.quickbooks._companyId()}/salesreceipt`, { - method: "post", - data, - }, $); + buildLineItems() { + const lineItems = []; + for (let i = 1; i <= this.numLineItems; i++) { + lineItems.push({ + DetailType: "SalesItemLineDetail", + Amount: this[`amount_${i}`], + SalesItemLineDetail: { + ItemRef: { + value: this[`item_${i}`], + }, + }, + }); + } + return lineItems; }, }, async run({ $ }) { - try { - if (typeof (this.lineItems) === "string") { - this.lineItems = JSON.parse(this.lineItems); - } else { + if (this.lineItemsAsObjects) { + try { this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" ? JSON.parse(lineItem) : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); } - } catch (error) { - throw new ConfigurationError(`An error occurred while trying to parse the LineItems. Error: ${error}`); } - const response = await this.createSalesReceipt({ + const response = await this.quickbooks.createSalesReceipt({ $, data: { - Line: this.lineItems, + Line: this.lineItemsAsObjects + ? this.lineItems + : this.buildLineItems(), CurrencyRef: this.currencyRefValue && { value: this.currencyRefValue, - name: this.currencyRefName, }, }, }); if (response) { - $.export("summary", `Successfully created sales receipt with id ${response.SalesReceipt.Id}`); + $.export("summary", `Successfully created sales receipt with ID ${response.SalesReceipt.Id}`); } return response; diff --git a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs index 1d2d1b57479de..9967a38273458 100644 --- a/components/quickbooks/actions/delete-purchase/delete-purchase.mjs +++ b/components/quickbooks/actions/delete-purchase/delete-purchase.mjs @@ -38,7 +38,7 @@ export default { }); if (response) { - $.export("summary", `Successfully deleted purchase with id ${Id}`); + $.export("summary", `Successfully deleted purchase with ID ${Id}`); } return response; diff --git a/components/quickbooks/actions/get-bill/get-bill.mjs b/components/quickbooks/actions/get-bill/get-bill.mjs index 04d0d3a7d73e8..89d775c545a29 100644 --- a/components/quickbooks/actions/get-bill/get-bill.mjs +++ b/components/quickbooks/actions/get-bill/get-bill.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved bill with id ${response.Bill.Id}`); + $.export("summary", `Successfully retrieved bill with ID ${response.Bill.Id}`); } return response; diff --git a/components/quickbooks/actions/get-customer/get-customer.mjs b/components/quickbooks/actions/get-customer/get-customer.mjs index 92d193e6598f1..731b12a646d19 100644 --- a/components/quickbooks/actions/get-customer/get-customer.mjs +++ b/components/quickbooks/actions/get-customer/get-customer.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved customer with id ${response.Customer.Id}`); + $.export("summary", `Successfully retrieved customer with ID ${response.Customer.Id}`); } return response; diff --git a/components/quickbooks/actions/get-invoice/get-invoice.mjs b/components/quickbooks/actions/get-invoice/get-invoice.mjs index 798aca1c6a6df..37314345cf2da 100644 --- a/components/quickbooks/actions/get-invoice/get-invoice.mjs +++ b/components/quickbooks/actions/get-invoice/get-invoice.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved invoice with id ${response.Invoice.Id}`); + $.export("summary", `Successfully retrieved invoice with ID ${response.Invoice.Id}`); } return response; diff --git a/components/quickbooks/actions/get-my-company/get-my-company.mjs b/components/quickbooks/actions/get-my-company/get-my-company.mjs index 7a2a44887c548..dc56afda5b900 100644 --- a/components/quickbooks/actions/get-my-company/get-my-company.mjs +++ b/components/quickbooks/actions/get-my-company/get-my-company.mjs @@ -15,7 +15,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved company with id ${response.CompanyInfo.Id}`); + $.export("summary", `Successfully retrieved company with ID ${response.CompanyInfo.Id}`); } return response; diff --git a/components/quickbooks/actions/get-payment/get-payment.mjs b/components/quickbooks/actions/get-payment/get-payment.mjs index 405193fa01a48..df3ca845badf3 100644 --- a/components/quickbooks/actions/get-payment/get-payment.mjs +++ b/components/quickbooks/actions/get-payment/get-payment.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved payment with id ${response.Payment.Id}`); + $.export("summary", `Successfully retrieved payment with ID ${response.Payment.Id}`); } return response; diff --git a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs index 6cdb78a5e8b39..c3de216fd870e 100644 --- a/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs +++ b/components/quickbooks/actions/get-purchase-order/get-purchase-order.mjs @@ -28,7 +28,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved purchase order with id ${response.PurchaseOrder.Id}`); + $.export("summary", `Successfully retrieved purchase order with ID ${response.PurchaseOrder.Id}`); } return response; diff --git a/components/quickbooks/actions/get-purchase/get-purchase.mjs b/components/quickbooks/actions/get-purchase/get-purchase.mjs index cc45157a2a8b0..4b394660c9d89 100644 --- a/components/quickbooks/actions/get-purchase/get-purchase.mjs +++ b/components/quickbooks/actions/get-purchase/get-purchase.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved purchase with id ${response.Purchase.Id}`); + $.export("summary", `Successfully retrieved purchase with ID ${response.Purchase.Id}`); } return response; diff --git a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs index 80ae6ecc1da00..64e8c29d001e7 100644 --- a/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs +++ b/components/quickbooks/actions/get-sales-receipt/get-sales-receipt.mjs @@ -27,7 +27,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved sales receipt with id ${response.SalesReceipt.Id}`); + $.export("summary", `Successfully retrieved sales receipt with ID ${response.SalesReceipt.Id}`); } return response; diff --git a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs index 1098f08cb4b26..e9f45b43d7ae0 100644 --- a/components/quickbooks/actions/get-time-activity/get-time-activity.mjs +++ b/components/quickbooks/actions/get-time-activity/get-time-activity.mjs @@ -28,7 +28,7 @@ export default { }); if (response) { - $.export("summary", `Successfully retrieved time activity with id ${response.TimeActivity.Id}`); + $.export("summary", `Successfully retrieved time activity with ID ${response.TimeActivity.Id}`); } return response; diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index 29b1601c2804d..5d68063cee461 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } let orderClause = ""; @@ -62,7 +55,7 @@ export default { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - const query = `select ${this.includeClause} from Account where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Account where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 22e2939d74017..93d5cc09d19bf 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } let orderClause = ""; @@ -62,7 +55,7 @@ export default { maxResults = ` MAXRESULTS ${this.maxResults}` || ""; } - const query = `select ${this.includeClause} from Customer where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Customer where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index bdcd1db624871..9d35cb1283527 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } const orderClause = this.orderClause @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.includeClause} from Invoice where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Invoice where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-items/search-items.mjs b/components/quickbooks/actions/search-items/search-items.mjs index 066e5982acfe2..a25cd3ffb25fd 100644 --- a/components/quickbooks/actions/search-items/search-items.mjs +++ b/components/quickbooks/actions/search-items/search-items.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } const orderClause = this.orderClause @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.includeClause} from Item where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Item where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-products/search-products.mjs b/components/quickbooks/actions/search-products/search-products.mjs index ec225b59fd190..e6cc84a1da496 100644 --- a/components/quickbooks/actions/search-products/search-products.mjs +++ b/components/quickbooks/actions/search-products/search-products.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } const orderClause = this.orderClause @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.includeClause} from Item where Type = 'Inventory' and ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Item where Type = 'Inventory' and ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index 35edc8aa48772..c72eeb729269b 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, whereClause: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.include_clause || !this.where_clause) { - throw new ConfigurationError("Must provide include_clause, where_clause parameters."); + if (!this.where_clause) { + throw new ConfigurationError("Must provide whereClause parameter."); } const orderClause = this.orderClause @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.include_clause} from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs index c272b124f0cb5..93e06ecd4a109 100644 --- a/components/quickbooks/actions/search-time-activities/search-time-activities.mjs +++ b/components/quickbooks/actions/search-time-activities/search-time-activities.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,8 +36,8 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { - throw new ConfigurationError("Must provide includeClause, whereClause parameters."); + if (!this.whereClause) { + throw new ConfigurationError("Must provide whereClause parameter."); } const orderClause = this.orderClause @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.includeClause} from TimeActivity where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from TimeActivity where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/search-vendors/search-vendors.mjs b/components/quickbooks/actions/search-vendors/search-vendors.mjs index 0f29aaa6fc567..321b228a1ed49 100644 --- a/components/quickbooks/actions/search-vendors/search-vendors.mjs +++ b/components/quickbooks/actions/search-vendors/search-vendors.mjs @@ -9,13 +9,6 @@ export default { type: "action", props: { quickbooks, - includeClause: { - propDefinition: [ - quickbooks, - "includeClause", - ], - optional: false, - }, maxResults: { propDefinition: [ quickbooks, @@ -43,7 +36,7 @@ export default { }, }, async run({ $ }) { - if (!this.includeClause || !this.whereClause) { + if (!this.whereClause) { throw new ConfigurationError("Must provide includeClause, whereClause parameters."); } @@ -59,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select ${this.includeClause} from Vendor where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Vendor where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index 6b80e9ef12931..95d0187fb709c 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -16,12 +16,6 @@ export default { "invoiceId", ], }, - lineItems: { - propDefinition: [ - quickbooks, - "lineItems", - ], - }, customer: { propDefinition: [ quickbooks, @@ -34,14 +28,83 @@ export default { "currency", ], }, + lineItemsAsObjects: { + propDefinition: [ + quickbooks, + "lineItemsAsObjects", + ], + reloadProps: true, + }, + }, + async additionalProps() { + const props = {}; + if (this.lineItemsAsObjects) { + props.lineItems = { + type: "string[]", + label: "Line Items", + description: "Line items of an invoice. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + }; + return props; + } + props.numLineItems = { + type: "integer", + label: "Number of Line Items", + description: "The number of line items to enter", + reloadProps: true, + }; + if (!this.numLineItems) { + return props; + } + for (let i = 1; i <= this.numLineItems; i++) { + props[`item_${i}`] = { + type: "string", + label: `Line ${i} - Item ID`, + options: async ({ page }) => { + return this.quickbooks.getPropOptions({ + page, + resource: "Item", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, + }; + props[`amount_${i}`] = { + type: "string", + label: `Line ${i} - Amount`, + }; + } + return props; + }, + methods: { + buildLineItems() { + const lineItems = []; + for (let i = 1; i <= this.numLineItems; i++) { + lineItems.push({ + DetailType: "SalesItemLineDetail", + Amount: this[`amount_${i}`], + SalesItemLineDetail: { + ItemRef: { + value: this[`item_${i}`], + }, + }, + }); + } + return lineItems; + }, }, async run({ $ }) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the Line Items prop. Error: ${error}`); + if (this.lineItemsAsObjects) { + try { + this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" + ? JSON.parse(lineItem) + : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + } } const { Invoice } = await this.quickbooks.getInvoice({ @@ -60,7 +123,7 @@ export default { }); if (response) { - $.export("summary", `Successfully updated invoice with id ${response.Invoice.Id}`); + $.export("summary", `Successfully updated invoice with Id ${response.Invoice.Id}`); } return response; diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index 091f2c4496bfe..10b0811f84b09 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -54,13 +54,7 @@ export default { currencyRefValue: { propDefinition: [ quickbooks, - "currencyRefValue", - ], - }, - currencyRefName: { - propDefinition: [ - quickbooks, - "currencyRefName", + "currency", ], }, active: { @@ -75,29 +69,14 @@ export default { optional: true, type: "string", }, - arAccountRefName: { - description: "Name of the accounts receivable account to be used for this customer. Each customer must have his own AR account. Applicable for France companies, only. Available when endpoint is evoked with the minorversion=3 query parameter. Query the Account name list resource to determine the appropriate Account object for this reference, where Account.AccountType=Accounts Receivable. Use `Account.Name` from that object for `ARAccountRef.name`.", - label: "Ar Account Ref Name", - optional: true, - type: "string", - }, arAccountRefValue: { - description: "Id of the accounts receivable account to be used for this customer. Each customer must have his own AR account. Applicable for France companies, only. Available when endpoint is evoked with the minorversion=3 query parameter. Query the Account name list resource to determine the appropriate Account object for this reference, where Account.AccountType=Accounts Receivable. Use `Account.Id` from that object for `ARAccountRef.value`.", - label: "Ar Account Ref Value", - optional: true, - type: "string", - }, - balance: { - description: "Specifies the open balance amount or the amount unpaid by the customer. For the create operation, this represents the opening balance for the customer. When returned in response to the query request it represents the current open balance (unpaid amount) for that customer. Write-on-create.", - label: "Balance", - optional: true, - type: "string", - }, - balanceWithJob: { - description: "Cumulative open balance amount for the Customer (or Job) and all its sub-jobs. Cannot be written to QuickBooks.", - label: "Balance With Job", - optional: true, + description: "ID of the accounts receivable account to be used for this customer. Each customer must have his own AR account. Applicable for France companies, only. Available when endpoint is evoked with the minorversion=3 query parameter. Query the Account name list resource to determine the appropriate Account object for this reference, where Account.AccountType=Accounts Receivable. Use `Account.Id` from that object for `ARAccountRef.value`.", + label: "AR Account Ref Value", type: "string", + propDefinition: [ + quickbooks, + "accountIds", + ], }, billAddrCity: { description: "City name for the billing address.", @@ -117,12 +96,6 @@ export default { optional: true, type: "string", }, - billAddrId: { - description: "Unique identifier of the QuickBooks object for the billing address, used for modifying the address. \nThe BillAddr object represents the default billing address. If a physical address is updated from within the transaction object, the QuickBooks Online API flows individual address components differently into the Line elements of the transaction response then when the transaction was first created:\n* `Line1` and `Line2` elements are populated with the customer name and company name.\n* Original `Line1` through `Line5` contents, `City`, `SubDivisionCode`, and `PostalCode` flow into `Line3` through `Line5` as a free format strings.", - label: "Bill Addr Id", - optional: true, - type: "string", - }, billAddrLate: { description: "Latitude coordinate of Geocode (Geospacial Entity Object Code). `INVALID` is returned for invalid addresses.", label: "Bill Addr Late", @@ -190,19 +163,13 @@ export default { type: "string", }, customerTypeRefValue: { - description: "Id referencing to the customer type assigned to a customer. This field is only returned if the customer is assigned a customer type.", - label: "Customer Type Ref Value", - optional: true, - type: "string", - }, - defaultTaxCodeName: { - description: "Id of the default tax code associated with this Customer object. Reference is valid if `Customer.Taxable` is set to true; otherwise, it is ignored. If automated sales tax is enabled (`Preferences.TaxPrefs.PartnerTaxEnabled` is set to true) the default tax code is set by the system and can not be overridden. Query the `TaxCode` name list resource to determine the appropriate `TaxCode` object for this reference. Use `TaxCode.Name` from that object for `DefaultTaxCodeRef.name`.", - label: "Default Tax Code Name", - optional: true, - type: "string", + propDefinition: [ + quickbooks, + "customerType", + ], }, defaultTaxCodeValue: { - description: "Id of the default tax code associated with this Customer object. Reference is valid if `Customer.Taxable` is set to true; otherwise, it is ignored. If automated sales tax is enabled (`Preferences.TaxPrefs.PartnerTaxEnabled` is set to true) the default tax code is set by the system and can not be overridden. Query the `TaxCode` name list resource to determine the appropriate `TaxCode` object for this reference. Use `TaxCode.Id` from that object for `DefaultTaxCodeRef.value`.", + description: "ID of the default tax code associated with this Customer object. Reference is valid if `Customer.Taxable` is set to true; otherwise, it is ignored. If automated sales tax is enabled (`Preferences.TaxPrefs.PartnerTaxEnabled` is set to true) the default tax code is set by the system and can not be overridden. Query the `TaxCode` name list resource to determine the appropriate `TaxCode` object for this reference. Use `TaxCode.Id` from that object for `DefaultTaxCodeRef.value`.", label: "Default Tax Code Value", optional: true, type: "string", @@ -258,35 +225,11 @@ export default { optional: true, type: "string", }, - openBalanceDate: { - description: "Date of the Open Balance for the create operation. Write-on-create.", - label: "Open Balance Date", - optional: true, - type: "string", - }, - parentRefName: { - description: "Name referencing to a Customer object that is the immediate parent of the Sub-Customer/Job in the hierarchical Customer:Job list. Required for the create operation if this object is a sub-customer or Job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.Name` from that object for `ParentRef.name`.", - label: "Parent Ref Name", - optional: true, - type: "string", - }, - parentRefValue: { - description: "Id referencing to a Customer object that is the immediate parent of the Sub-Customer/Job in the hierarchical Customer:Job list. Required for the create operation if this object is a sub-customer or Job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.Id` from that object for `ParentRef.value`.", - label: "Parent Ref Value", - optional: true, - type: "string", - }, - paymentMethodRefName: { - description: "Id referencing a PaymentMethod object associated with this Customer object. Query the PaymentMethod name list resource to determine the appropriate PaymentMethod object for this reference. Use `PaymentMethod.Name` from that object for `PaymentMethodRef.name`.", - label: "Payment Method Ref Name", - optional: true, - type: "string", - }, paymentMethodRefValue: { - description: "Id referencing a PaymentMethod object associated with this Customer object. Query the PaymentMethod name list resource to determine the appropriate PaymentMethod object for this reference. Use `PaymentMethod.Id` from that object for `PaymentMethodRef.value`.", - label: "Payment Method Ref Value", - optional: true, - type: "string", + propDefinition: [ + quickbooks, + "paymentMethod", + ], }, preferredDeliveryMethod: { description: "Preferred delivery method. Values are `Print`, `Email`, or `None`.", @@ -329,17 +272,13 @@ export default { optional: true, type: "string", }, - saleTermRefName: { - description: "Name of a SalesTerm object associated with this Customer object. Query the Term name list resource to determine the appropriate Term object for this reference. Use `Term.Name` from that object for `SalesTermRef.name`.", - label: "Sale Term Ref Name", - optional: true, - type: "string", - }, saleTermRefValue: { - description: "Id of a SalesTerm object associated with this Customer object. Query the Term name list resource to determine the appropriate Term object for this reference. Use `Term.Id` from that object for `SalesTermRef.value`.", - label: "Sale Term Ref Value", - optional: true, + description: "ID of a SalesTerm object associated with this Customer object. Query the Term name list resource to determine the appropriate Term object for this reference. Use `Term.Id` from that object for `SalesTermRef.value`.", type: "string", + propDefinition: [ + quickbooks, + "termIds", + ], }, secondaryTaxIdentifier: { description: "Also called UTR No. in ( UK ) , CST Reg No. ( IN ) also represents the tax registration number of the Person or Organization. This value is masked in responses, exposing only last five characters. For example, the ID of `123-45-6789` is returned as `XXXXXX56789`", @@ -419,16 +358,6 @@ export default { optional: true, type: "string", }, - sparseUpdate: { - description: "When set to `true`, sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched.", - label: "Sparse Update", - type: "string", - }, - syncToken: { - description: "Version number of the object. It is used to lock an object for use by one app at a time. As soon as an application modifies an object, its SyncToken is incremented. Attempts to modify an object specifying an older SyncToken fails. Only the latest version of the object is maintained by QuickBooks Online.", - label: "Sync Token", - type: "string", - }, taxable: { description: "If true, transactions for this customer are taxable. Default behavior with minor version 10 and above: true, if `DefaultTaxCodeRef` is defined or false if `TaxExemptionReasonId` is set.", label: "Taxable", @@ -465,21 +394,28 @@ export default { type: "string", }, }, + methods: { + async getSyncToken($) { + const { Customer: customer } = await this.quickbooks.getCustomer({ + $, + customerId: this.customerId, + }); + return customer.SyncToken; + }, + }, async run({ $ }) { - //See Quickbooks API docs at: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#full-update-a-customer - if ( !this.displayName && (!this.title && !this.givenName && !this.middleName && !this.familyName && !this.suffix) || - !this.customerId || !this.syncToken || this.sparseUpdate === undefined + !this.customerId ) { - throw new ConfigurationError("Must provide displayName or at least one of title, givenName, middleName, familyName, or suffix, and customerId, syncToken parameters."); + throw new ConfigurationError("Must provide displayName or at least one of title, givenName, middleName, familyName, or suffix, and customerId parameters."); } const response = await this.quickbooks.updateCustomer({ $, data: { - sparse: this.sparseUpdate, + sparse: true, Id: this.customerId, DisplayName: this.displayName, Suffix: this.suffix, @@ -487,23 +423,20 @@ export default { MiddleName: this.middleName, FamilyName: this.familyName, GivenName: this.givenName, - SyncToken: this.syncToken, + SyncToken: await this.getSyncToken($), PrimaryEmailAddr: this.primaryEmailAddr, ResaleNum: this.resaleNum, SecondaryTaxIdentifier: this.secondaryTaxIdentifier, ARAccountRef: { value: this.arAccountRefValue, - name: this.arAccountRefName, }, DefaultTaxCodeRef: { value: this.defaultTaxCodeValue, - name: this.defaultTaxCodeName, }, PreferredDeliveryMethod: this.preferredDeliveryMethod, GSTIN: this.GSTIN, SalesTermRef: { value: this.saleTermRefValue, - name: this.saleRermRefName, }, CustomerTypeRef: { value: this.customerRypeRefValue, @@ -515,29 +448,21 @@ export default { BillWithParent: this.billWithParent, CurrencyRef: { value: this.currencyRefValue, - name: this.currencyRefName, }, Mobile: { FreeFormNumber: this.mobileFreeFormNumber, }, Job: this.job, - BalanceWithJobs: this.balanceWithJob, PrimaryPhone: { FreeFormNumber: this.primaryPhoneFreeFormNumber, }, - OpenBalanceDate: this.openBalanceDate, Taxable: this.taxable, AlternatePhone: { FreeFormNumber: this.alternatePhoneFreeFormNumber, }, - ParentRef: { - value: this.parentRefValue, - name: this.parentRefName, - }, Notes: this.notes, WebAddr: this.webAddr, Active: this.active, - Balance: this.balance, ShipAddr: { Id: this.shipAddrId, PostalCode: this.shipAddrPostalCode, @@ -554,7 +479,6 @@ export default { }, PaymentMethodRef: { value: this.paymentMethodRefValue, - name: this.paymentMethodRefName, }, IsProject: this.isProject, CompanyName: this.companyName, @@ -562,7 +486,6 @@ export default { GSTRegistrationType: this.gstRegistrationType, PrintOnCheckName: this.printOnCheckName, BillAddr: { - Id: this.billAddrId, PostalCode: this.billAddrPostalCode, City: this.billAddrCity, Country: this.billAddrCountry, @@ -580,7 +503,7 @@ export default { }); if (response) { - $.export("summary", `Successfully updated customer with id ${this.customerId}`); + $.export("summary", `Successfully updated customer with ID ${this.customerId}`); } return response; diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs index 21908d9671c91..118cd7cc59a23 100644 --- a/components/quickbooks/actions/update-item/update-item.mjs +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -20,21 +20,11 @@ export default { label: "Name", description: "Name of the item. This value must be unique.", }, - syncToken: { - type: "string", - label: "Sync Token", - description: "Version number of the entity. Required for the update operation.", - }, trackQtyOnHand: { type: "boolean", label: "Track Quantity on Hand", description: "True if there is quantity on hand to be tracked. Once this value is true, it cannot be updated to false. Applicable for items of type `Inventory`. Not applicable for `Service` or `NonInventory` item types.", }, - sparseUpdate: { - type: "string", - label: "Sparse Update", - description: "When set to `true`, sparse updating provides the ability to update a subset of properties for a given object; only elements specified in the request are updated. Missing elements are left untouched.", - }, qtyOnHand: { type: "string", label: "Quantity on Hand", @@ -45,13 +35,10 @@ export default { type: "string", label: "Income Account Ref Value", description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `IncomeAccountRef.value`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - incomeAccountRefName: { - type: "string", - label: "Income Account Ref Name", - description: "Reference to the posting account, that is, the account that records the proceeds from the sale of this item. Must be an account with account type of `Sales of Product Income`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `IncomeAccountRef.name`. See specifications for the IncomeAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, + propDefinition: [ + quickbooks, + "accountIds", + ], }, type: { type: "string", @@ -69,13 +56,10 @@ export default { type: "string", label: "Asset Account Ref Value", description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `AssetAccountRef.value`.", - optional: true, - }, - assetAccountRefName: { - type: "string", - label: "Asset Account Ref Name", - description: "Required for Inventory item types. Reference to the Inventory Asset account that tracks the current value of the inventory. If the same account is used for all inventory items, the current balance of this account will represent the current total value of the inventory. Must be an account with account type of `Other Current Asset`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `AssetAccountRef.name`.", - optional: true, + propDefinition: [ + quickbooks, + "accountIds", + ], }, invStartDate: { type: "string", @@ -87,13 +71,10 @@ export default { type: "string", label: "Expense Account Ref Value", description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Id` from that object for `ExpenseAccountRef.value`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, - }, - expenseAccountRefName: { - type: "string", - label: "Expense Account Ref Name", - description: "Reference to the expense account used to pay the vendor for this item. Must be an account with account type of `Cost of Goods Sold`. Query the Account name list resource to determine the appropriate Account object for this reference. Use `Account.Name` from that object for `ExpenseAccountRef.name`. See specifications for the ExpenseAccountRef parameters in the [Create an item page](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item#create-an-item).", - optional: true, + propDefinition: [ + quickbooks, + "accountIds", + ], }, sku: { type: "string", @@ -108,28 +89,21 @@ export default { optional: true, }, salesTaxCodeRefValue: { - type: "string", label: "Sales Tax Code Ref Value", - description: "Id of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `SalesTaxCodeRef.value`.", - optional: true, - }, - salesTaxCodeRefName: { - type: "string", - label: "Sales Tax Code Ref Name", - description: "Name of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `SalesTaxCodeRef.name`.", - optional: true, + description: "ID of the referenced sales tax code for the Sales item. Applicable to Service and Sales item types only. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `SalesTaxCodeRef.value`.", + propDefinition: [ + quickbooks, + "taxCodeId", + ], }, classRefValue: { type: "string", label: "Class Ref Value", - description: "Id of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", - optional: true, - }, - classRefName: { - type: "string", - label: "Class Ref Name", - description: "Name of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Name` from that object for `ClassRef.name`.", - optional: true, + description: "ID of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", + propDefinition: [ + quickbooks, + "classIds", + ], }, purchaseTaxIncluded: { type: "boolean", @@ -189,13 +163,10 @@ export default { type: "string", label: "Pref Vendor Ref Value", description: "Pref vendor ref value", - optional: true, - }, - prefVendorRefName: { - type: "string", - label: "Pref Vendor Ref Name", - description: "Pref vendor ref name", - optional: true, + propDefinition: [ + quickbooks, + "vendorIds", + ], }, active: { type: "boolean", @@ -206,20 +177,16 @@ export default { UqcId: { type: "string", label: "UQC ID", - description: "Id of Standard Unit of Measure (UQC:Unique Quantity Code) of the item according to GST rule.", + description: "ID of Standard Unit of Measure (UQC:Unique Quantity Code) of the item according to GST rule.", optional: true, }, purchaseTaxCodeRefValue: { - type: "string", label: "Purchase Tax Code Ref Value", description: "The ID for the referenced purchase tax code object as found in the Id field of the object payload. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Id` from that object for `PurchaseTaxCodeRef.value`.", - optional: true, - }, - purchaseTaxCodeRefName: { - type: "string", - label: "Purchase Tax Code Ref Name", - description: "An identifying name for the purchase tax code object being referenced by value and is derived from the field that holds the common name of that object. \n\nReference to the purchase tax code for the item. Applicable to Service, Other Charge, and Product (Non-Inventory) item types. Query the TaxCode name list resource to determine the appropriate TaxCode object for this reference. Use `TaxCode.Name` from that object for `PurchaseTaxCodeRef.name`.", - optional: true, + propDefinition: [ + quickbooks, + "taxCodeId", + ], }, serviceType: { type: "string", @@ -240,70 +207,64 @@ export default { optional: true, }, taxClassificationRefValue: { - type: "string", - label: "Tax Classification Ref Value", description: "The ID for the referenced Tax classification object as found in the Id field of the object payload.\n\nTax classification segregates different items into different classifications and the tax classification is one of the key parameters to determine appropriate tax on transactions involving items. Tax classifications are sourced by either tax governing authorities as in India/Malaysia or externally like Exactor. 'Fuel', 'Garments' and 'Soft drinks' are a few examples of tax classification in layman terms. User can choose a specific tax classification for an item while creating it. A level 1 tax classification cannot be associated to an Item", - optional: true, - }, - taxClassificationRefName: { - type: "string", - label: "Tax Classification Ref Name", - description: "An identifying name for the Tax classification object being referenced by value and is derived from the field that holds the common name of that object.", - optional: true, - }, - parentRefName: { - type: "string", - label: "Parent Ref Name", - description: "An identifying name for the parent item object being referenced by `value` and is derived from the field that holds the common name of that object.\n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", - optional: true, + propDefinition: [ + quickbooks, + "taxClassificationId", + ], }, parentRefValue: { - type: "string", label: "Parent Ref Value", description: "The ID for the referenced parent item object as found in the Id field of the object payload. \n\nThe immediate parent of the sub item in the hierarchical Category:Sub-category list. If SubItem is true, then ParenRef is required. Query the Item name list resource to determine the appropriate object for this reference. Use `Item.Id` from that object for `ParentRef.value`.", optional: true, + propDefinition: [ + quickbooks, + "itemId", + ], + }, + }, + methods: { + async getSyncToken($) { + const { Item: item } = await this.quickbooks.getItem({ + $, + itemId: this.itemId, + }); + return item.SyncToken; }, }, async run({ $ }) { if (!this.itemId || !this.name - || !this.syncToken || this.trackQtyOnHand === undefined - || this.sparseUpdate === undefined ) { - throw new ConfigurationError("Must provide itemId, name, syncToken, and trackQtyOnHand parameters."); + throw new ConfigurationError("Must provide itemId, name, and trackQtyOnHand parameters."); } const data = { - sparse: this.sparseUpdate, + sparse: true, Id: this.itemId, Name: this.name, QtyOnHand: this.qtyOnHand, - SyncToken: this.syncToken, + SyncToken: await this.getSyncToken($), IncomeAccountRef: { value: this.incomeAccountRefValue, - name: this.incomeAccountRefName, }, Type: this.type, AssetAccountRef: { value: this.assetAccountRefValue, - name: this.assetAccountRefName, }, InvStartDate: this.invStartDate, ExpenseAccountRef: { value: this.expenseAccountRefValue, - name: this.expenseAccountRefName, }, Sku: this.sku, SalesTaxIncluded: this.salesTaxIncluded, TrackQtyOnHand: this.trackQtyOnHand, SalesTaxCodeRef: { value: this.salesTaxCodeRefValue, - name: this.salesTaxCodeRefName, }, ClassRef: { value: this.classRefValue, - name: this.classRefName, }, PurchaseTaxIncluded: this.purchaseTaxIncluded, Description: this.description, @@ -316,27 +277,23 @@ export default { PurchaseDesc: this.purchaseDesc, PrefVendorRef: { value: this.prefVendorRefValue, - name: this.prefVendorRefName, }, Active: this.active, UQCId: this.UqcId, PurchaseTaxCodeRef: { value: this.purchaseTaxCodeRefValue, - name: this.purchaseTaxCodeRefName, }, ServiceType: this.serviceType, PurchaseCost: this.purchaseCost, UnitPrice: this.unitPrice, TaxClassificationRef: { value: this.taxClassificationRefValue, - name: this.taxClassificationRefName, }, }; if (this.parentRefValue || this.parentRefName) { data["ParentRef"] = { value: this.parentRefValue, - name: this.parentRefName, }; } @@ -346,7 +303,7 @@ export default { }); if (response) { - $.export("summary", `Successfully updated item with id ${this.itemId}`); + $.export("summary", `Successfully updated item with ID ${this.itemId}`); } return response; diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index 5f00a92412e75..c6da70c8ecb27 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -9,7 +9,7 @@ export default { invoiceId: { label: "Invoice ID", type: "string", - description: "Id of the invoice to get details of.", + description: "Id of the invoice to get details of", async options({ page }) { return this.getPropOptions({ page, @@ -23,20 +23,10 @@ export default { }); }, }, - lineItems: { - label: "Line Items", - type: "string[]", - description: "Individual line items of a transaction. Valid Line types include: `ItemBasedExpenseLine` and `AccountBasedExpenseLine`. One minimum line item required for the request to succeed. E.g `[ { \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Meals and Entertainment\", \"value\": \"10\" } } } ]`", - }, - lineItemsAsObjects: { - type: "boolean", - label: "Enter Line Items as Objects", - description: "Enter line items as an array of objects", - }, customer: { label: "Customer Reference", type: "string", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference.", + description: "Reference to a customer or job", async options({ page }) { return this.getPropOptions({ page, @@ -50,11 +40,41 @@ export default { }); }, }, - customerRefName: { - label: "Customer Reference Name", + customerType: { + label: "Customer Type", type: "string", - description: "Reference to a customer or job. Query the Customer name list resource to determine the appropriate Customer object for this reference. Use `Customer.DisplayName ` from that object for `CustomerRef.name`.", + description: "ID referencing the customer type assigned to a customer", optional: true, + async options({ page }) { + return this.getPropOptions({ + page, + resource: "CustomerType", + mapper: ({ + Id: id, Name: label, + }) => ({ + label, + value: id, + }), + }); + }, + }, + paymentMethod: { + label: "Payment Method", + type: "string", + description: "ID referencing a PaymentMethod object associated with this Customer object", + optional: true, + async options({ page }) { + return this.getPropOptions({ + page, + resource: "Payment Method", + mapper: ({ + Id: id, Name: label, + }) => ({ + label, + value: id, + }), + }); + }, }, currency: { label: "Currency Code", @@ -78,80 +98,10 @@ export default { }); }, }, - currencyRefValue: { - label: "Currency Reference Value", - type: "string", - description: "A three letter string representing the ISO 4217 code for the currency. For example, `USD`, `AUD`, `EUR`, and so on. This must be defined if multicurrency is enabled for the company.\nMulticurrency is enabled for the company if `Preferences.MultiCurrencyEnabled` is set to `true`. Read more about multicurrency support [here](https://developer.intuit.com/docs?RedirectID=MultCurrencies). Required if multicurrency is enabled for the company.", - optional: true, - }, - currencyRefName: { - label: "Currency Reference Name", - type: "string", - description: "The full name of the currency.", - optional: true, - }, - includeClause: { - description: "Fields to use in the select clause of the data query. See query language syntax, limitations, and other specifications on [Data queries](https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries)", - label: "Include Clause", - type: "string", - }, - maxResults: { - description: "The number of entity elements in the response.", - label: "Max Results", - optional: true, - type: "string", - }, - orderClause: { - description: "The `orderClause` is for sorting the result. Include the property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", - label: "Order Clause", - optional: true, - type: "string", - }, - startPosition: { - description: "The starting count of the response for pagination.", - label: "Start Position", - optional: true, - type: "string", - }, - whereClause: { - description: "Filters to use in the where clause of the data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", - label: "Where Clause", - type: "string", - }, - displayName: { - label: "Display Name", - type: "string", - description: "The name of the person or organization as displayed. Must be unique across all Customer, Vendor, and Employee objects. Cannot be removed with sparse update. If not supplied, the system generates DisplayName by concatenating customer name components supplied in the request from the following list: `Title`, `GivenName`, `MiddleName`, `FamilyName`, and `Suffix`.", - optional: true, - }, - title: { - label: "Title", - type: "string", - description: "Title of the person. This tag supports i18n, all locales. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, `Suffix`, or `FullyQualifiedName` attributes are required during create.", - optional: true, - }, - givenName: { - label: "Given Name", - type: "string", - description: "Given name or first name of a person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - middleName: { - label: "Middle Name", - type: "string", - description: "Middle name of the person. The person can have zero or more middle names. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - familyName: { - label: "Family Name", - type: "string", - description: "Family name or the last name of the person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, purchaseId: { - label: "Purchase Id", + label: "Purchase ID", type: "string", - description: "Id of the purchase.", + description: "ID of the purchase.", withLabel: true, async options({ page }) { return this.getPropOptions({ @@ -166,31 +116,9 @@ export default { }); }, }, - suffix: { - label: "Suffix", - type: "string", - description: "Suffix of the name. For example, `Jr`. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", - optional: true, - }, - accountingMethod: { - type: "string", - label: "Accounting Method", - description: "The accounting method used in the report", - options: [ - "Cash", - "Accrual", - ], - optional: true, - }, - columns: { - type: "string[]", - label: "Columns", - description: "Column types to be shown in the report", - optional: true, - }, termIds: { type: "string[]", - label: "Term Ids", + label: "Term IDs", description: "Filters report contents based on term or terms supplied", optional: true, async options({ page }) { @@ -208,7 +136,7 @@ export default { }, vendorIds: { type: "string[]", - label: "Vendor Ids", + label: "Vendor IDs", description: "Filters report contents to include information for specified vendors", optional: true, async options({ page }) { @@ -226,7 +154,7 @@ export default { }, accountIds: { type: "string[]", - label: "Account Ids", + label: "Account IDs", description: "Filters report contents to include information for specified accounts", optional: true, async options({ page }) { @@ -244,7 +172,7 @@ export default { }, classIds: { type: "string[]", - label: "Class Ids", + label: "Class IDs", description: "Filters report contents to include information for specified classes if so configured in the company file", optional: true, async options({ page }) { @@ -262,7 +190,7 @@ export default { }, employeeIds: { type: "string[]", - label: "Employee Ids", + label: "Employee IDs", description: "Filters report contents to include information for specified employees", optional: true, async options({ page }) { @@ -280,7 +208,7 @@ export default { }, departmentIds: { type: "string[]", - label: "Department Ids", + label: "Department IDs", description: "Filters report contents to include information for specified departments if so configured in the company file", optional: true, async options({ page }) { @@ -298,7 +226,7 @@ export default { }, itemId: { type: "string", - label: "Item Id", + label: "Item ID", description: "The identifier of an item", async options({ page }) { return this.getPropOptions({ @@ -315,7 +243,7 @@ export default { }, billId: { type: "string", - label: "Bill Id", + label: "Bill ID", description: "The identifier of a bill", async options({ page }) { return this.getPropOptions({ @@ -327,7 +255,7 @@ export default { }, purchaseOrderId: { type: "string", - label: "Purchase Order Id", + label: "Purchase Order ID", description: "The identifier of a purchase order", async options({ page }) { return this.getPropOptions({ @@ -344,7 +272,7 @@ export default { }, salesReceiptId: { type: "string", - label: "Sales Receipt Id", + label: "Sales Receipt ID", description: "The identifier of a sales receipt", async options({ page }) { return this.getPropOptions({ @@ -361,7 +289,7 @@ export default { }, timeActivityId: { type: "string", - label: "Time Activity Id", + label: "Time Activity ID", description: "The identifier of a time activity", async options({ page }) { return this.getPropOptions({ @@ -378,7 +306,7 @@ export default { }, paymentId: { type: "string", - label: "Payment Id", + label: "Payment ID", description: "The identifier of a payment", async options({ page }) { return this.getPropOptions({ @@ -393,6 +321,122 @@ export default { }); }, }, + taxCodeId: { + type: "string", + label: "Tax Code ID", + description: "The identifier of a tax code", + optional: true, + async options({ page }) { + return this.getPropOptions({ + page, + resource: "TaxCode", + mapper: ({ + Id: value, Name: label, + }) => ({ + value, + label, + }), + }); + }, + }, + taxClassificationId: { + type: "string", + label: "Tax Classification ID", + description: "The identifier of a tax classification", + optional: true, + async options({ page }) { + return this.getPropOptions({ + page, + resource: "TaxClassification", + mapper: ({ + id: value, name: label, + }) => ({ + value, + label, + }), + }); + }, + }, + lineItemsAsObjects: { + type: "boolean", + label: "Enter Line Items as Objects", + description: "Enter line items as an array of objects", + }, + maxResults: { + description: "The number of entity elements in the response.", + label: "Max Results", + optional: true, + type: "string", + }, + orderClause: { + description: "The `orderClause` is for sorting the result. Include the property to sort by. The default sort order is ascending; to indicate descending sort order, include DESC, for example: `Name DESC`", + label: "Order Clause", + optional: true, + type: "string", + }, + startPosition: { + description: "The starting count of the response for pagination.", + label: "Start Position", + optional: true, + type: "string", + }, + whereClause: { + description: "Filters to use in the where clause of the data query. Note: Multiple clauses (filters) are AND'd. The OR operation is not supported.", + label: "Where Clause", + type: "string", + }, + displayName: { + label: "Display Name", + type: "string", + description: "The name of the person or organization as displayed. Must be unique across all Customer, Vendor, and Employee objects. Cannot be removed with sparse update. If not supplied, the system generates DisplayName by concatenating customer name components supplied in the request from the following list: `Title`, `GivenName`, `MiddleName`, `FamilyName`, and `Suffix`.", + optional: true, + }, + title: { + label: "Title", + type: "string", + description: "Title of the person. This tag supports i18n, all locales. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, `Suffix`, or `FullyQualifiedName` attributes are required during create.", + optional: true, + }, + givenName: { + label: "Given Name", + type: "string", + description: "Given name or first name of a person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", + optional: true, + }, + middleName: { + label: "Middle Name", + type: "string", + description: "Middle name of the person. The person can have zero or more middle names. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", + optional: true, + }, + familyName: { + label: "Family Name", + type: "string", + description: "Family name or the last name of the person. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", + optional: true, + }, + suffix: { + label: "Suffix", + type: "string", + description: "Suffix of the name. For example, `Jr`. The `DisplayName` attribute or at least one of `Title`, `GivenName`, `MiddleName`, `FamilyName`, or `Suffix` attributes is required for object create.", + optional: true, + }, + accountingMethod: { + type: "string", + label: "Accounting Method", + description: "The accounting method used in the report", + options: [ + "Cash", + "Accrual", + ], + optional: true, + }, + columns: { + type: "string[]", + label: "Columns", + description: "Column types to be shown in the report", + optional: true, + }, }, methods: { _companyId() { @@ -470,6 +514,13 @@ export default { ...opts, }); }, + createSalesReceipt(opts = {}) { + return this._makeRequest({ + path: `company/${this._companyId()}/salesreceipt`, + method: "post", + ...opts, + }); + }, deletePurchase(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/purchase`, @@ -560,6 +611,14 @@ export default { ...opts, }); }, + getItem({ + itemId, ...opts + }) { + return this._makeRequest({ + path: `company/${this._companyId()}/item/${itemId}`, + ...opts, + }); + }, query(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/query`, From 8a8aa274170e646b3ddf2b3cc2ef80739bd7279b Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 4 Dec 2024 16:13:21 -0500 Subject: [PATCH 14/19] pnpm-lock.yaml --- pnpm-lock.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11e14b6f8eb02..08fe8a6ed2bf8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8137,8 +8137,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/quickbooks_sandbox: - specifiers: {} + components/quickbooks_sandbox: {} components/quickemailverification: dependencies: From 6d1a25fa1837436097e8f4c173267a28deaf8cb7 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 4 Dec 2024 16:21:35 -0500 Subject: [PATCH 15/19] fixes --- .../quickbooks/actions/search-accounts/search-accounts.mjs | 2 +- .../quickbooks/actions/search-customers/search-customers.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/quickbooks/actions/search-accounts/search-accounts.mjs b/components/quickbooks/actions/search-accounts/search-accounts.mjs index 5d68063cee461..107254935be5c 100644 --- a/components/quickbooks/actions/search-accounts/search-accounts.mjs +++ b/components/quickbooks/actions/search-accounts/search-accounts.mjs @@ -52,7 +52,7 @@ export default { let maxResults = ""; if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; + maxResults = ` MAXRESULTS ${this.maxResults}`; } const query = `select * from Account where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; diff --git a/components/quickbooks/actions/search-customers/search-customers.mjs b/components/quickbooks/actions/search-customers/search-customers.mjs index 93d5cc09d19bf..db6fe1a34300e 100644 --- a/components/quickbooks/actions/search-customers/search-customers.mjs +++ b/components/quickbooks/actions/search-customers/search-customers.mjs @@ -52,7 +52,7 @@ export default { let maxResults = ""; if (this.maxResults) { - maxResults = ` MAXRESULTS ${this.maxResults}` || ""; + maxResults = ` MAXRESULTS ${this.maxResults}`; } const query = `select * from Customer where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; From 10b78da15f376b09f511636086fd660b305b23b3 Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Thu, 5 Dec 2024 13:42:42 +0700 Subject: [PATCH 16/19] Require Vendor ID --- components/quickbooks/actions/create-bill/create-bill.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index c4486ce678310..86af50dc4caa2 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -17,6 +17,7 @@ export default { type: "string", label: "Vendor ID", description: "Reference to the vendor for this transaction", + optional: false, }, currencyRefValue: { propDefinition: [ From 5d7c9a9d1ba54d790d0aa3bd2e50ad9b7d9d8021 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 5 Dec 2024 13:04:32 -0500 Subject: [PATCH 17/19] updates --- .../actions/create-bill/create-bill.mjs | 13 +--- .../actions/create-invoice/create-invoice.mjs | 13 +--- .../create-purchase/create-purchase.mjs | 14 +--- .../create-sales-receipt.mjs | 26 +++----- .../search-invoices/search-invoices.mjs | 2 +- .../actions/search-query/search-query.mjs | 1 + .../search-services/search-services.mjs | 2 +- .../sparse-update-invoice.mjs | 37 ++++++----- .../update-customer/update-customer.mjs | 66 ++++++++++++------- .../actions/update-item/update-item.mjs | 34 +++------- components/quickbooks/common/utils.mjs | 17 +++++ components/quickbooks/package.json | 2 +- components/quickbooks/quickbooks.app.mjs | 6 +- components/quickbooks_sandbox/package.json | 2 +- 14 files changed, 111 insertions(+), 124 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index c4486ce678310..c125533ec83d2 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -1,5 +1,6 @@ import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; +import { parseLineItems } from "../../common/utils.mjs"; export default { key: "quickbooks-create-bill", @@ -97,16 +98,6 @@ export default { throw new ConfigurationError("Must provide vendorRefValue, and lineItems parameters."); } - if (this.lineItemsAsObjects) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); - } - } - const response = await this.quickbooks.createBill({ $, data: { @@ -114,7 +105,7 @@ export default { value: this.vendorRefValue, }, Line: this.lineItemsAsObjects - ? this.lineItems + ? parseLineItems(this.lineItems) : this.buildLineItems(), CurrencyRef: { value: this.currencyRefValue, diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index da98156e5bf4b..6c501de572e40 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -1,5 +1,6 @@ import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; +import { parseLineItems } from "../../common/utils.mjs"; export default { key: "quickbooks-create-invoice", @@ -94,21 +95,11 @@ export default { throw new ConfigurationError("Must provide lineItems, and customerRefValue parameters."); } - if (this.lineItemsAsObjects) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); - } - } - const response = await this.quickbooks.createInvoice({ $, data: { Line: this.lineItemsAsObjects - ? this.lineItems + ? parseLineItems(this.lineItems) : this.buildLineItems(), CustomerRef: { value: this.customerRefValue, diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index 77136b285b822..d020037ec1423 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -1,5 +1,5 @@ import quickbooks from "../../quickbooks.app.mjs"; -import { ConfigurationError } from "@pipedream/platform"; +import { parseLineItems } from "../../common/utils.mjs"; export default { key: "quickbooks-create-purchase", @@ -104,16 +104,6 @@ export default { }, }, async run({ $ }) { - if (this.lineItemsAsObjects) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); - } - } - const response = await this.quickbooks.createPurchase({ $, data: { @@ -122,7 +112,7 @@ export default { value: this.accountRefValue, }, Line: this.lineItemsAsObjects - ? this.lineItems + ? parseLineItems(this.lineItems) : this.buildLineItems(), CurrencyRef: { value: this.currencyRefValue, diff --git a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs index d60b44bebd25c..dd53ac5502e8b 100644 --- a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs +++ b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs @@ -1,5 +1,5 @@ -import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; +import { parseLineItems } from "../../common/utils.mjs"; export default { key: "quickbooks-create-sales-receipt", @@ -9,19 +9,19 @@ export default { type: "action", props: { quickbooks, - currencyRefValue: { + lineItemsAsObjects: { propDefinition: [ quickbooks, - "currencyRefValue", + "lineItemsAsObjects", ], - optional: true, + reloadProps: true, }, - lineItemsAsObjects: { + currencyRefValue: { propDefinition: [ quickbooks, - "lineItemsAsObjects", + "currency", ], - reloadProps: true, + optional: true, }, }, async additionalProps() { @@ -85,21 +85,11 @@ export default { }, }, async run({ $ }) { - if (this.lineItemsAsObjects) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); - } - } - const response = await this.quickbooks.createSalesReceipt({ $, data: { Line: this.lineItemsAsObjects - ? this.lineItems + ? parseLineItems(this.lineItems) : this.buildLineItems(), CurrencyRef: this.currencyRefValue && { value: this.currencyRefValue, diff --git a/components/quickbooks/actions/search-invoices/search-invoices.mjs b/components/quickbooks/actions/search-invoices/search-invoices.mjs index 9d35cb1283527..0c9c332f80ebd 100644 --- a/components/quickbooks/actions/search-invoices/search-invoices.mjs +++ b/components/quickbooks/actions/search-invoices/search-invoices.mjs @@ -5,7 +5,7 @@ export default { key: "quickbooks-search-invoices", name: "Search Invoices", description: "Searches for invoices. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#query-an-invoice)", - version: "0.1.7", + version: "0.0.1", type: "action", props: { quickbooks, diff --git a/components/quickbooks/actions/search-query/search-query.mjs b/components/quickbooks/actions/search-query/search-query.mjs index 4a71284e3f609..d92eff6a2ab38 100644 --- a/components/quickbooks/actions/search-query/search-query.mjs +++ b/components/quickbooks/actions/search-query/search-query.mjs @@ -30,5 +30,6 @@ export default { if (response) { $.export("summary", "Successfully retrieved query results"); } + return response; }, }; diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index c72eeb729269b..b334ffe2cb918 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -36,7 +36,7 @@ export default { }, }, async run({ $ }) { - if (!this.where_clause) { + if (!this.whereClause) { throw new ConfigurationError("Must provide whereClause parameter."); } diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index 95d0187fb709c..4e869655faeff 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -1,5 +1,4 @@ -import { ConfigurationError } from "@pipedream/platform"; -import { parseOne } from "../../common/utils.mjs"; +import { parseLineItems } from "../../common/utils.mjs"; import quickbooks from "../../quickbooks.app.mjs"; export default { @@ -97,33 +96,35 @@ export default { }, }, async run({ $ }) { - if (this.lineItemsAsObjects) { - try { - this.lineItems = this.lineItems.map((lineItem) => typeof lineItem === "string" - ? JSON.parse(lineItem) - : lineItem); - } catch (error) { - throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); - } - } + this.lineItems = this.lineItemsAsObjects + ? parseLineItems(this.lineItems) + : this.buildLineItems(); - const { Invoice } = await this.quickbooks.getInvoice({ + const { Invoice: invoice } = await this.quickbooks.getInvoice({ $, invoiceId: this.invoiceId, }); - if (this.lineItems.length) Invoice.Line?.push(...this.lineItems); - - Invoice.CurrencyRef = parseOne(this.currency); - Invoice.CustomerRef = parseOne(this.customer); + if (this.lineItems?.length) invoice.Line?.push(...this.lineItems); const response = await this.quickbooks.sparseUpdateInvoice({ $, - data: Invoice, + data: { + sparse: true, + Id: this.invoiceId, + SyncToken: invoice.SyncToken, + CurrencyRef: this.currencyRefValue && { + value: this.currencyRefValue, + }, + CustomerRef: { + value: this.customer, + }, + Line: invoice.Line, + }, }); if (response) { - $.export("summary", `Successfully updated invoice with Id ${response.Invoice.Id}`); + $.export("summary", `Successfully updated invoice with ID ${response.Invoice.Id}`); } return response; diff --git a/components/quickbooks/actions/update-customer/update-customer.mjs b/components/quickbooks/actions/update-customer/update-customer.mjs index 10b0811f84b09..23381476c4615 100644 --- a/components/quickbooks/actions/update-customer/update-customer.mjs +++ b/components/quickbooks/actions/update-customer/update-customer.mjs @@ -61,7 +61,7 @@ export default { description: "If true, this entity is currently enabled for use by QuickBooks. If there is an amount in `Customer.Balance` when setting this Customer object to inactive through the QuickBooks UI, a CreditMemo balancing transaction is created for the amount.", label: "Active", optional: true, - type: "string", + type: "boolean", }, alternatePhoneFreeFormNumber: { description: "Specifies the alternate phone number in free form.", @@ -201,12 +201,6 @@ export default { ], type: "string", }, - isProject: { - description: "If true, indicates this is a Project.", - label: "Is Project", - optional: true, - type: "boolean", - }, job: { description: "If true, this is a Job or sub-customer. If false or null, this is a top level customer, not a Job or sub-customer.", label: "Job", @@ -362,7 +356,7 @@ export default { description: "If true, transactions for this customer are taxable. Default behavior with minor version 10 and above: true, if `DefaultTaxCodeRef` is defined or false if `TaxExemptionReasonId` is set.", label: "Taxable", optional: true, - type: "string", + type: "boolean", }, taxExemptionReasonId: { label: "Tax Exemption Reason Id", @@ -412,6 +406,31 @@ export default { throw new ConfigurationError("Must provide displayName or at least one of title, givenName, middleName, familyName, or suffix, and customerId parameters."); } + const hasBillingAddress = this.billAddrPostalCode + || this.billAddrCity + || this.billAddrCountry + || this.billAddrLine5 + || this.billAddrLine4 + || this.billAddrLine3 + || this.billAddrLine2 + || this.billAddrLine1 + || this.billAddrLate + || this.billAddrLong + || this.billAddrCountrySubDivisionCode; + + const hasShippingAddress = this.shipAddrId + || this.shipAddrPostalCode + || this.shipAddrCity + || this.shipAddrCountry + || this.shipAddrLine5 + || this.shipAddrLine4 + || this.shipAddrLine3 + || this.shipAddrLine2 + || this.shipAddrLine1 + || this.shipAddrLate + || this.shipAddrLong + || this.shipAddrCountrySubDivisionCode; + const response = await this.quickbooks.updateCustomer({ $, data: { @@ -424,46 +443,48 @@ export default { FamilyName: this.familyName, GivenName: this.givenName, SyncToken: await this.getSyncToken($), - PrimaryEmailAddr: this.primaryEmailAddr, + PrimaryEmailAddr: this.primaryEmailAddr && { + Address: this.primaryEmailAddr, + }, ResaleNum: this.resaleNum, SecondaryTaxIdentifier: this.secondaryTaxIdentifier, - ARAccountRef: { + ARAccountRef: this.arAccountRefValue && { value: this.arAccountRefValue, }, - DefaultTaxCodeRef: { + DefaultTaxCodeRef: this.defaultTaxCodeValue && { value: this.defaultTaxCodeValue, }, PreferredDeliveryMethod: this.preferredDeliveryMethod, GSTIN: this.GSTIN, - SalesTermRef: { + SalesTermRef: this.saleTermRefValue && { value: this.saleTermRefValue, }, - CustomerTypeRef: { - value: this.customerRypeRefValue, + CustomerTypeRef: this.customerTypeRefValue && { + value: this.customerTypeRefValue, }, - Fax: { + Fax: this.faxFreeFormNumber && { FreeFormNumber: this.faxFreeFormNumber, }, BusinessNumber: this.businessNumber, BillWithParent: this.billWithParent, - CurrencyRef: { + CurrencyRef: this.currencyRefValue && { value: this.currencyRefValue, }, - Mobile: { + Mobile: this.mobileFreeFormNumber && { FreeFormNumber: this.mobileFreeFormNumber, }, Job: this.job, - PrimaryPhone: { + PrimaryPhone: this.primaryPhoneFreeFormNumber && { FreeFormNumber: this.primaryPhoneFreeFormNumber, }, Taxable: this.taxable, - AlternatePhone: { + AlternatePhone: this.alternatePhoneFreeFormNumber && { FreeFormNumber: this.alternatePhoneFreeFormNumber, }, Notes: this.notes, WebAddr: this.webAddr, Active: this.active, - ShipAddr: { + ShipAddr: hasShippingAddress && { Id: this.shipAddrId, PostalCode: this.shipAddrPostalCode, City: this.shipAddrCity, @@ -477,15 +498,14 @@ export default { Long: this.shipAddrLong, CountrySubDivisionCode: this.shipAddrCountrySubDivisionCode, }, - PaymentMethodRef: { + PaymentMethodRef: this.paymentMethodRefValue && { value: this.paymentMethodRefValue, }, - IsProject: this.isProject, CompanyName: this.companyName, PrimaryTaxIdentifier: this.primaryTaxIdentifier, GSTRegistrationType: this.gstRegistrationType, PrintOnCheckName: this.printOnCheckName, - BillAddr: { + BillAddr: hasBillingAddress && { PostalCode: this.billAddrPostalCode, City: this.billAddrCity, Country: this.billAddrCountry, diff --git a/components/quickbooks/actions/update-item/update-item.mjs b/components/quickbooks/actions/update-item/update-item.mjs index 118cd7cc59a23..ad28ecbf8bc10 100644 --- a/components/quickbooks/actions/update-item/update-item.mjs +++ b/components/quickbooks/actions/update-item/update-item.mjs @@ -24,6 +24,7 @@ export default { type: "boolean", label: "Track Quantity on Hand", description: "True if there is quantity on hand to be tracked. Once this value is true, it cannot be updated to false. Applicable for items of type `Inventory`. Not applicable for `Service` or `NonInventory` item types.", + optional: true, }, qtyOnHand: { type: "string", @@ -96,15 +97,6 @@ export default { "taxCodeId", ], }, - classRefValue: { - type: "string", - label: "Class Ref Value", - description: "ID of the referenced Class for the item. Query the Class name list resource to determine the appropriate object for this reference. Use `Class.Id` from that object for `ClassRef.value`.", - propDefinition: [ - quickbooks, - "classIds", - ], - }, purchaseTaxIncluded: { type: "boolean", label: "Purchase Tax Included", @@ -233,11 +225,8 @@ export default { }, }, async run({ $ }) { - if (!this.itemId - || !this.name - || this.trackQtyOnHand === undefined - ) { - throw new ConfigurationError("Must provide itemId, name, and trackQtyOnHand parameters."); + if (!this.itemId || !this.name) { + throw new ConfigurationError("Must provide itemId and name parameters."); } const data = { @@ -246,26 +235,23 @@ export default { Name: this.name, QtyOnHand: this.qtyOnHand, SyncToken: await this.getSyncToken($), - IncomeAccountRef: { + IncomeAccountRef: this.incomeAccountRefValue && { value: this.incomeAccountRefValue, }, Type: this.type, - AssetAccountRef: { + AssetAccountRef: this.assetAccountRefValue && { value: this.assetAccountRefValue, }, InvStartDate: this.invStartDate, - ExpenseAccountRef: { + ExpenseAccountRef: this.expenseAccountRefValue && { value: this.expenseAccountRefValue, }, Sku: this.sku, SalesTaxIncluded: this.salesTaxIncluded, TrackQtyOnHand: this.trackQtyOnHand, - SalesTaxCodeRef: { + SalesTaxCodeRef: this.salesTaxCodeRefValue && { value: this.salesTaxCodeRefValue, }, - ClassRef: { - value: this.classRefValue, - }, PurchaseTaxIncluded: this.purchaseTaxIncluded, Description: this.description, AbatementRate: this.abatementRate, @@ -275,18 +261,18 @@ export default { UQCDisplayText: this.UqcDisplayText, ReorderPoint: this.reorderPoint, PurchaseDesc: this.purchaseDesc, - PrefVendorRef: { + PrefVendorRef: this.prefVendorRefValue && { value: this.prefVendorRefValue, }, Active: this.active, UQCId: this.UqcId, - PurchaseTaxCodeRef: { + PurchaseTaxCodeRef: this.purchaseTaxCodeRefValue && { value: this.purchaseTaxCodeRefValue, }, ServiceType: this.serviceType, PurchaseCost: this.purchaseCost, UnitPrice: this.unitPrice, - TaxClassificationRef: { + TaxClassificationRef: this.taxClassificationRefValue && { value: this.taxClassificationRefValue, }, }; diff --git a/components/quickbooks/common/utils.mjs b/components/quickbooks/common/utils.mjs index c763da9d89e79..fb0d909f06b08 100644 --- a/components/quickbooks/common/utils.mjs +++ b/components/quickbooks/common/utils.mjs @@ -2,6 +2,7 @@ import { MAX_RETRIES, INITIAL_BACKOFF_MILLISECONDS, } from "./constants.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export const parseOne = (obj) => { let parsed; @@ -27,3 +28,19 @@ export async function retryWithExponentialBackoff( throw error; } } + +export function parseLineItems(arr) { + if (!arr) { + return undefined; + } + try { + if (typeof arr === "string") { + return JSON.parse(arr); + } + return arr.map((lineItem) => typeof lineItem === "string" + ? JSON.parse(lineItem) + : lineItem); + } catch (error) { + throw new ConfigurationError(`We got an error trying to parse the LineItems. Error: ${error}`); + } +} diff --git a/components/quickbooks/package.json b/components/quickbooks/package.json index 8da0524464043..29c6ffff7652d 100644 --- a/components/quickbooks/package.json +++ b/components/quickbooks/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/quickbooks", - "version": "0.3.1", + "version": "0.5.0", "description": "Pipedream Quickbooks Components", "main": "quickbooks.app.mjs", "keywords": [ diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index c6da70c8ecb27..3ee699c2a1c72 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -108,10 +108,10 @@ export default { page, resource: "Purchase", mapper: ({ - Id, PaymentType, SyncToken, + Id, PaymentType, TxnDate, }) => ({ - label: `${Id} - ${PaymentType}`, - value: `${Id}|${SyncToken}`, + label: `${Id} - ${PaymentType} - ${TxnDate}`, + value: Id, }), }); }, diff --git a/components/quickbooks_sandbox/package.json b/components/quickbooks_sandbox/package.json index 3d9196f26d78c..e1635aa04092b 100644 --- a/components/quickbooks_sandbox/package.json +++ b/components/quickbooks_sandbox/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/quickbooks_sandbox", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Quickbooks Sandbox Components", "main": "quickbooks_sandbox.app.mjs", "keywords": [ From 36f0b5c29c318293d7e9c38d37cad17faa93b23f Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Thu, 5 Dec 2024 13:14:38 -0500 Subject: [PATCH 18/19] versions --- .../sources/new-employee-created/new-employee-created.mjs | 2 +- .../sources/new-employee-updated/new-employee-updated.mjs | 2 +- .../sources/new-employee-created/new-employee-created.mjs | 2 +- .../sources/new-employee-updated/new-employee-updated.mjs | 2 +- pnpm-lock.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/quickbooks/sources/new-employee-created/new-employee-created.mjs b/components/quickbooks/sources/new-employee-created/new-employee-created.mjs index 5e919de6c754c..5c31af1d76ddb 100644 --- a/components/quickbooks/sources/new-employee-created/new-employee-created.mjs +++ b/components/quickbooks/sources/new-employee-created/new-employee-created.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-employee-created", name: "New Employee Created", description: "Emit new event when a new employee is created.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks/sources/new-employee-updated/new-employee-updated.mjs b/components/quickbooks/sources/new-employee-updated/new-employee-updated.mjs index 717840c9e022f..85565a3d86430 100644 --- a/components/quickbooks/sources/new-employee-updated/new-employee-updated.mjs +++ b/components/quickbooks/sources/new-employee-updated/new-employee-updated.mjs @@ -6,7 +6,7 @@ export default { key: "quickbooks-new-employee-updated", name: "New Employee Updated", description: "Emit new event when an employee is updated.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/quickbooks_sandbox/sources/new-employee-created/new-employee-created.mjs b/components/quickbooks_sandbox/sources/new-employee-created/new-employee-created.mjs index 4527818a02fed..78f8321c7f90d 100644 --- a/components/quickbooks_sandbox/sources/new-employee-created/new-employee-created.mjs +++ b/components/quickbooks_sandbox/sources/new-employee-created/new-employee-created.mjs @@ -11,7 +11,7 @@ const props = adjustPropDefinitions(others.props, app); export default { ...others, key: "quickbooks_sandbox-new-employee-created", - version: "0.0.1", + version: "0.0.2", name, description, type, diff --git a/components/quickbooks_sandbox/sources/new-employee-updated/new-employee-updated.mjs b/components/quickbooks_sandbox/sources/new-employee-updated/new-employee-updated.mjs index bffbfa3781f6b..bbb6619508377 100644 --- a/components/quickbooks_sandbox/sources/new-employee-updated/new-employee-updated.mjs +++ b/components/quickbooks_sandbox/sources/new-employee-updated/new-employee-updated.mjs @@ -11,7 +11,7 @@ const props = adjustPropDefinitions(others.props, app); export default { ...others, key: "quickbooks_sandbox-new-employee-updated", - version: "0.0.1", + version: "0.0.2", name, description, type, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b63ea3ed13242..ee9dabcfb2d81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40842,7 +40842,7 @@ snapshots: path-scurry@1.11.1: dependencies: lru-cache: 10.4.3 - minipass: 5.0.0 + minipass: 7.1.2 path-to-regexp@6.3.0: {} From affff4d00fa73a2cc7c121ab9e36c1072d4430fe Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 6 Dec 2024 11:52:42 -0500 Subject: [PATCH 19/19] updates --- .../actions/create-bill/create-bill.mjs | 16 ++++++++++++---- .../actions/create-invoice/create-invoice.mjs | 16 ++++++++++++---- .../actions/create-purchase/create-purchase.mjs | 16 ++++++++++++---- .../create-sales-receipt.mjs | 17 +++++++++++++---- .../actions/search-services/search-services.mjs | 2 +- .../sparse-update-invoice.mjs | 13 ++++++++++--- 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/components/quickbooks/actions/create-bill/create-bill.mjs b/components/quickbooks/actions/create-bill/create-bill.mjs index c62e37d87cf87..931adc8a90a3b 100644 --- a/components/quickbooks/actions/create-bill/create-bill.mjs +++ b/components/quickbooks/actions/create-bill/create-bill.mjs @@ -40,7 +40,7 @@ export default { props.lineItems = { type: "string[]", label: "Line Items", - description: "Line items of a bill. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", + description: "Line items of a bill. Set DetailType to `AccountBasedExpenseLineDetail`. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", }; return props; } @@ -99,15 +99,23 @@ export default { throw new ConfigurationError("Must provide vendorRefValue, and lineItems parameters."); } + const lines = this.lineItemsAsObjects + ? parseLineItems(this.lineItems) + : this.buildLineItems(); + + lines.forEach((line) => { + if (line.DetailType !== "AccountBasedExpenseLineDetail") { + throw new ConfigurationError("Line Item DetailType must be `AccountBasedExpenseLineDetail`"); + } + }); + const response = await this.quickbooks.createBill({ $, data: { VendorRef: { value: this.vendorRefValue, }, - Line: this.lineItemsAsObjects - ? parseLineItems(this.lineItems) - : this.buildLineItems(), + Line: lines, CurrencyRef: { value: this.currencyRefValue, }, diff --git a/components/quickbooks/actions/create-invoice/create-invoice.mjs b/components/quickbooks/actions/create-invoice/create-invoice.mjs index 6c501de572e40..01370ba853db0 100644 --- a/components/quickbooks/actions/create-invoice/create-invoice.mjs +++ b/components/quickbooks/actions/create-invoice/create-invoice.mjs @@ -36,7 +36,7 @@ export default { props.lineItems = { type: "string[]", label: "Line Items", - description: "Line items of an invoice. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + description: "Line items of an invoice. Set DetailType to `SalesItemLineDetail`, `GroupLineDetail`, or `DescriptionOnly`. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", }; return props; } @@ -95,12 +95,20 @@ export default { throw new ConfigurationError("Must provide lineItems, and customerRefValue parameters."); } + const lines = this.lineItemsAsObjects + ? parseLineItems(this.lineItems) + : this.buildLineItems(); + + lines.forEach((line) => { + if (line.DetailType !== "SalesItemLineDetail" && line.DetailType !== "GroupLineDetail" && line.DetailType !== "DescriptionOnly") { + throw new ConfigurationError("Line Item DetailType must be `SalesItemLineDetail`, `GroupLineDetail`, or `DescriptionOnly`"); + } + }); + const response = await this.quickbooks.createInvoice({ $, data: { - Line: this.lineItemsAsObjects - ? parseLineItems(this.lineItems) - : this.buildLineItems(), + Line: lines, CustomerRef: { value: this.customerRefValue, }, diff --git a/components/quickbooks/actions/create-purchase/create-purchase.mjs b/components/quickbooks/actions/create-purchase/create-purchase.mjs index d020037ec1423..c4322afbc521a 100644 --- a/components/quickbooks/actions/create-purchase/create-purchase.mjs +++ b/components/quickbooks/actions/create-purchase/create-purchase.mjs @@ -1,5 +1,6 @@ import quickbooks from "../../quickbooks.app.mjs"; import { parseLineItems } from "../../common/utils.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks-create-purchase", @@ -49,7 +50,7 @@ export default { props.lineItems = { type: "string[]", label: "Line Items", - description: "Line items of a purchase. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", + description: "Line items of a purchase. Set DetailType to `AccountBasedExpenseLineDetail`. Example: `{ \"DetailType\": \"AccountBasedExpenseLineDetail\", \"Amount\": 100.0, \"AccountBasedExpenseLineDetail\": { \"AccountRef\": { \"name\": \"Advertising\", \"value\": \"1\" } } }`", }; return props; } @@ -104,6 +105,15 @@ export default { }, }, async run({ $ }) { + const lines = this.lineItemsAsObjects + ? parseLineItems(this.lineItems) + : this.buildLineItems(); + + lines.forEach((line) => { + if (line.DetailType !== "AccountBasedExpenseLineDetail") { + throw new ConfigurationError("Line Item DetailType must be `AccountBasedExpenseLineDetail`"); + } + }); const response = await this.quickbooks.createPurchase({ $, data: { @@ -111,9 +121,7 @@ export default { AccountRef: { value: this.accountRefValue, }, - Line: this.lineItemsAsObjects - ? parseLineItems(this.lineItems) - : this.buildLineItems(), + Line: lines, CurrencyRef: { value: this.currencyRefValue, }, diff --git a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs index dd53ac5502e8b..8f7c0de62fb4e 100644 --- a/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs +++ b/components/quickbooks/actions/create-sales-receipt/create-sales-receipt.mjs @@ -1,5 +1,6 @@ import quickbooks from "../../quickbooks.app.mjs"; import { parseLineItems } from "../../common/utils.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks-create-sales-receipt", @@ -30,7 +31,7 @@ export default { props.lineItems = { type: "string[]", label: "Line Items", - description: "Line items of a sales receipt. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + description: "Line items of a sales receipt. Set DetailType to `SalesItemLineDetail` or `GroupLineDetail`. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", }; return props; } @@ -85,12 +86,20 @@ export default { }, }, async run({ $ }) { + const lines = this.lineItemsAsObjects + ? parseLineItems(this.lineItems) + : this.buildLineItems(); + + lines.forEach((line) => { + if (line.DetailType !== "SalesItemLineDetail" && line.DetailType !== "GroupLineDetail") { + throw new ConfigurationError("Line Item DetailType must be `SalesItemLineDetail` or `GroupLineDetail`"); + } + }); + const response = await this.quickbooks.createSalesReceipt({ $, data: { - Line: this.lineItemsAsObjects - ? parseLineItems(this.lineItems) - : this.buildLineItems(), + Line: lines, CurrencyRef: this.currencyRefValue && { value: this.currencyRefValue, }, diff --git a/components/quickbooks/actions/search-services/search-services.mjs b/components/quickbooks/actions/search-services/search-services.mjs index b334ffe2cb918..e8bd5dca67a30 100644 --- a/components/quickbooks/actions/search-services/search-services.mjs +++ b/components/quickbooks/actions/search-services/search-services.mjs @@ -52,7 +52,7 @@ export default { ? ` MAXRESULTS ${this.maxResults}` : ""; - const query = `select * from Item where Type = 'Service' and ${this.where_clause}${orderClause}${startPosition}${maxResults}`; + const query = `select * from Item where Type = 'Service' and ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, diff --git a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs index 4e869655faeff..31ccf5d7e06f3 100644 --- a/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs +++ b/components/quickbooks/actions/sparse-update-invoice/sparse-update-invoice.mjs @@ -1,5 +1,6 @@ import { parseLineItems } from "../../common/utils.mjs"; import quickbooks from "../../quickbooks.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "quickbooks-sparse-update-invoice", @@ -41,7 +42,7 @@ export default { props.lineItems = { type: "string[]", label: "Line Items", - description: "Line items of an invoice. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", + description: "Line items of an invoice. Set DetailType to `SalesItemLineDetail`, `GroupLineDetail`, `DescriptionOnly`, `DiscountLineDetail`, or `SubTotalLineDetail`. Example: `{ \"DetailType\": \"SalesItemLineDetail\", \"Amount\": 100.0, \"SalesItemLineDetail\": { \"ItemRef\": { \"name\": \"Services\", \"value\": \"1\" } } }`", }; return props; } @@ -96,16 +97,22 @@ export default { }, }, async run({ $ }) { - this.lineItems = this.lineItemsAsObjects + const lines = this.lineItemsAsObjects ? parseLineItems(this.lineItems) : this.buildLineItems(); + lines.forEach((line) => { + if (line.DetailType !== "SalesItemLineDetail" && line.DetailType !== "GroupLineDetail" && line.DetailType !== "DescriptionOnly" && line.DetailType !== "DiscountLineDetail" && line.DetailType !== "SubTotalLineDetail") { + throw new ConfigurationError("Line Item DetailType must be `SalesItemLineDetail`, `GroupLineDetail`, `DescriptionOnly`, `DiscountLineDetail`, or `SubTotalLineDetail`"); + } + }); + const { Invoice: invoice } = await this.quickbooks.getInvoice({ $, invoiceId: this.invoiceId, }); - if (this.lineItems?.length) invoice.Line?.push(...this.lineItems); + if (lines?.length) invoice.Line?.push(lines); const response = await this.quickbooks.sparseUpdateInvoice({ $,