From c341b45396c7282da087046ade16265c99c8d9dd Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Fri, 3 Jun 2022 19:35:24 +0100 Subject: [PATCH] feat(QuickBooks Node): Add optional Tax item field (#3404) * Added tax refs * Nodelinter fixes --- .../nodes/QuickBooks/GenericFunctions.ts | 11 ++++- .../nodes/QuickBooks/QuickBooks.node.ts | 5 +- .../descriptions/Bill/BillDescription.ts | 48 +++++++++---------- .../Customer/CustomerDescription.ts | 2 +- .../Employee/EmployeeDescription.ts | 2 +- .../Estimate/EstimateDescription.ts | 47 ++++++++++-------- .../Invoice/InvoiceDescription.ts | 47 ++++++++++-------- .../descriptions/Item/ItemDescription.ts | 2 +- .../Payment/PaymentDescription.ts | 4 +- .../Purchase/PurchaseDescription.ts | 2 +- .../Transaction/TransactionDescription.ts | 33 +++++++------ .../descriptions/Vendor/VendorDescription.ts | 2 +- 12 files changed, 117 insertions(+), 88 deletions(-) diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index 4d51f43c9d..3df51d7b47 100644 --- a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts @@ -138,7 +138,7 @@ export async function quickBooksApiRequestAllItems( responseData = await quickBooksApiRequest.call(this, method, endpoint, qs, body); try { const nonResource = originalQuery.split(' ')?.pop(); - if (nonResource === 'CreditMemo' || nonResource === 'Term') { + if (nonResource === 'CreditMemo' || nonResource === 'Term' || nonResource === 'TaxCode') { returnData.push(...responseData.QueryResponse[nonResource]); } else { returnData.push(...responseData.QueryResponse[capitalCase(resource)]); @@ -334,18 +334,27 @@ export function processLines( ItemRef: { value: line.itemId, }, + TaxCodeRef : { + value: line.TaxCodeRef, + }, }; delete line.itemId; + delete line.TaxCodeRef; } + } else if (resource === 'invoice') { if (line.DetailType === 'SalesItemLineDetail') { line.SalesItemLineDetail = { ItemRef: { value: line.itemId, }, + TaxCodeRef : { + value: line.TaxCodeRef, + }, }; delete line.itemId; + delete line.TaxCodeRef; } } diff --git a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts index f8ab9b721c..456237f8f1 100644 --- a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts +++ b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts @@ -180,6 +180,10 @@ export class QuickBooks implements INodeType { return await loadResource.call(this, 'purchase'); }, + async getTaxCodeRefs(this: ILoadOptionsFunctions) { + return await loadResource.call(this, 'TaxCode'); + }, + async getTerms(this: ILoadOptionsFunctions) { return await loadResource.call(this, 'Term'); }, @@ -503,7 +507,6 @@ export class QuickBooks implements INodeType { } as IDataObject; body.Line = processLines.call(this, body, lines, resource); - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; body = populateFields.call(this, body, additionalFields, resource); diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts index 2d462a40c2..e240bbe11f 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts @@ -91,6 +91,29 @@ export const billFields: INodeProperties[] = [ }, }, options: [ + { + displayName: 'Account ID', + name: 'accountId', + type: 'string', + default: '', + }, + { + displayName: 'Amount', + name: 'Amount', + description: 'Monetary amount of the line item', + type: 'number', + default: 0, + }, + { + displayName: 'Description', + name: 'Description', + description: 'Textual description of the line item', + type: 'string', + default: '', + typeOptions: { + alwaysOpenEditWindow: true, + }, + }, { displayName: 'Detail Type', name: 'DetailType', @@ -116,29 +139,6 @@ export const billFields: INodeProperties[] = [ loadOptionsMethod: 'getItems', }, }, - { - displayName: 'Account ID', - name: 'accountId', - type: 'string', - default: '', - }, - { - displayName: 'Amount', - name: 'Amount', - description: 'Monetary amount of the line item', - type: 'number', - default: 0, - }, - { - displayName: 'Description', - name: 'Description', - description: 'Textual description of the line item', - type: 'string', - default: '', - typeOptions: { - alwaysOpenEditWindow: true, - }, - }, { displayName: 'Position', name: 'LineNum', @@ -235,7 +235,7 @@ export const billFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts index 3732447ae4..c8107a2fef 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts @@ -128,7 +128,7 @@ export const customerFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts index 6aa858e518..6d34183109 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts @@ -142,7 +142,7 @@ export const employeeFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts index 80649e0013..491a20fbca 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts @@ -95,6 +95,23 @@ export const estimateFields: INodeProperties[] = [ }, }, options: [ + { + displayName: 'Amount', + name: 'Amount', + description: 'Monetary amount of the line item', + type: 'number', + default: 0, + }, + { + displayName: 'Description', + name: 'Description', + description: 'Textual description of the line item', + type: 'string', + default: '', + typeOptions: { + alwaysOpenEditWindow: true, + }, + }, { displayName: 'Detail Type', name: 'DetailType', @@ -116,23 +133,6 @@ export const estimateFields: INodeProperties[] = [ loadOptionsMethod: 'getItems', }, }, - { - displayName: 'Amount', - name: 'Amount', - description: 'Monetary amount of the line item', - type: 'number', - default: 0, - }, - { - displayName: 'Description', - name: 'Description', - description: 'Textual description of the line item', - type: 'string', - default: '', - typeOptions: { - alwaysOpenEditWindow: true, - }, - }, { displayName: 'Position', name: 'LineNum', @@ -140,6 +140,15 @@ export const estimateFields: INodeProperties[] = [ type: 'number', default: 1, }, + { + displayName: 'Tax Code Ref', + name: 'TaxCodeRef', + type: 'options', + default: [], + typeOptions: { + loadOptionsMethod: 'getTaxCodeRefs', + }, + }, ], }, { @@ -210,7 +219,7 @@ export const estimateFields: INodeProperties[] = [ type: 'boolean', required: true, default: false, - description: 'Download the estimate as a PDF file', + description: 'Whether to download the estimate as a PDF file', displayOptions: { show: { resource: [ @@ -290,7 +299,7 @@ export const estimateFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts index 1cd05773d5..605ec60939 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts @@ -99,6 +99,23 @@ export const invoiceFields: INodeProperties[] = [ }, }, options: [ + { + displayName: 'Amount', + name: 'Amount', + description: 'Monetary amount of the line item', + type: 'number', + default: 0, + }, + { + displayName: 'Description', + name: 'Description', + description: 'Textual description of the line item', + type: 'string', + default: '', + typeOptions: { + alwaysOpenEditWindow: true, + }, + }, { displayName: 'Detail Type', name: 'DetailType', @@ -120,23 +137,6 @@ export const invoiceFields: INodeProperties[] = [ loadOptionsMethod: 'getItems', }, }, - { - displayName: 'Amount', - name: 'Amount', - description: 'Monetary amount of the line item', - type: 'number', - default: 0, - }, - { - displayName: 'Description', - name: 'Description', - description: 'Textual description of the line item', - type: 'string', - default: '', - typeOptions: { - alwaysOpenEditWindow: true, - }, - }, { displayName: 'Position', name: 'LineNum', @@ -144,6 +144,15 @@ export const invoiceFields: INodeProperties[] = [ type: 'number', default: 1, }, + { + displayName: 'Tax Code Ref', + name: 'TaxCodeRef', + type: 'options', + default: [], + typeOptions: { + loadOptionsMethod: 'getTaxCodeRefs', + }, + }, ], }, { @@ -214,7 +223,7 @@ export const invoiceFields: INodeProperties[] = [ type: 'boolean', required: true, default: false, - description: 'Download the invoice as a PDF file', + description: 'Whether to download the invoice as a PDF file', displayOptions: { show: { resource: [ @@ -294,7 +303,7 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts index 1ca80be999..b2febb2267 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts @@ -76,7 +76,7 @@ export const itemFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts index 458496edc6..3a00e7be0f 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts @@ -163,7 +163,7 @@ export const paymentFields: INodeProperties[] = [ type: 'boolean', required: true, default: false, - description: 'Download estimate as PDF file', + description: 'Whether to download estimate as PDF file', displayOptions: { show: { resource: [ @@ -243,7 +243,7 @@ export const paymentFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts index 7835bc5423..3bb5d30048 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts @@ -76,7 +76,7 @@ export const purchaseFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts index fb1f903daf..3bc33b9c4a 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts @@ -44,7 +44,7 @@ export const transactionFields: INodeProperties[] = [ // transaction: getReport // ---------------------------------- { - displayName: 'Simplify', + displayName: 'Simplify Response', name: 'simple', type: 'boolean', displayOptions: { @@ -264,13 +264,6 @@ export const transactionFields: INodeProperties[] = [ description: 'Predefined account modifiction date range to filter results by', options: PREDEFINED_DATE_RANGES.map(toOptions), }, - { - displayName: 'Document Number', - name: 'docnum', - type: 'string', - default: '', - description: 'Transaction document number to filter results by', - }, { displayName: 'Department', name: 'department', @@ -281,6 +274,13 @@ export const transactionFields: INodeProperties[] = [ loadOptionsMethod: 'getDepartments', }, }, + { + displayName: 'Document Number', + name: 'docnum', + type: 'string', + default: '', + description: 'Transaction document number to filter results by', + }, { displayName: 'Group By', name: 'group_by', @@ -346,6 +346,14 @@ export const transactionFields: INodeProperties[] = [ default: 'Ascend', options: ['Ascend', 'Descend'].map(toOptions), }, + { + displayName: 'Source Account Type', + name: 'source_account_type', + default: 'Bank', + type: 'options', + description: 'Account type to filter results by', + options: SOURCE_ACCOUNT_TYPES.map(toOptions).map(toDisplayName), + }, { displayName: 'Term', name: 'term', @@ -374,15 +382,6 @@ export const transactionFields: INodeProperties[] = [ description: 'Transaction type to filter results by', options: TRANSACTION_TYPES.map(toOptions).map(toDisplayName), }, - - { - displayName: 'Source Account Type', - name: 'source_account_type', - default: 'Bank', - type: 'options', - description: 'Account type to filter results by', - options: SOURCE_ACCOUNT_TYPES.map(toOptions).map(toDisplayName), - }, { displayName: 'Vendor', name: 'vendor', diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts index a11aefafe5..053711c5c6 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts @@ -128,7 +128,7 @@ export const vendorFields: INodeProperties[] = [ displayName: 'Limit', name: 'limit', type: 'number', - default: 5, + default: 50, description: 'Max number of results to return', typeOptions: { minValue: 1,