From 5a69178e6a741127883aefecdb7f3a37ebf53147 Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Tue, 31 May 2022 13:42:35 +0100 Subject: [PATCH 1/2] Added tax refs --- .../nodes/QuickBooks/GenericFunctions.ts | 11 ++++- .../nodes/QuickBooks/QuickBooks.node.ts | 5 ++- .../Estimate/EstimateDescription.ts | 9 ++++ .../Invoice/InvoiceDescription.ts | 41 +++++++++++-------- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index 4d51f43c9dbd9..3df51d7b47d54 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 f8ab9b721cda3..456237f8f1f07 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/Estimate/EstimateDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts index 2d5c2acaf68e6..fc9ff40d7a4da 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts @@ -140,6 +140,15 @@ export const estimateFields: INodeProperties[] = [ type: 'number', default: 1, }, + { + displayName: 'Tax Code Ref', + name: 'TaxCodeRef', + type: 'options', + default: [], + typeOptions: { + loadOptionsMethod: 'getTaxCodeRefs', + }, + }, ], }, { diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts index 10b2bd1f1231f..c54332a598b59 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts @@ -99,6 +99,13 @@ export const invoiceFields: INodeProperties[] = [ }, }, options: [ + { + displayName: 'Amount', + name: 'Amount', + description: 'Monetary amount of the line item', + type: 'number', + default: 0, + }, { displayName: 'Detail Type', name: 'DetailType', @@ -111,22 +118,6 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, - { - displayName: 'Item', - name: 'itemId', - type: 'options', - default: [], - typeOptions: { - loadOptionsMethod: 'getItems', - }, - }, - { - displayName: 'Amount', - name: 'Amount', - description: 'Monetary amount of the line item', - type: 'number', - default: 0, - }, { displayName: 'Description', name: 'Description', @@ -137,6 +128,15 @@ export const invoiceFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, }, + { + displayName: 'Item', + name: 'itemId', + type: 'options', + default: [], + typeOptions: { + loadOptionsMethod: 'getItems', + }, + }, { 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', + }, + }, ], }, { From 08201d8525449f6678a3df382b6879f25cff7419 Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Tue, 31 May 2022 13:58:17 +0100 Subject: [PATCH 2/2] Nodelinter fixes --- .../descriptions/Bill/BillDescription.ts | 48 +++++++++---------- .../Customer/CustomerDescription.ts | 2 +- .../Employee/EmployeeDescription.ts | 2 +- .../Estimate/EstimateDescription.ts | 38 +++++++-------- .../Invoice/InvoiceDescription.ts | 24 +++++----- .../descriptions/Item/ItemDescription.ts | 2 +- .../Payment/PaymentDescription.ts | 4 +- .../Purchase/PurchaseDescription.ts | 2 +- .../Transaction/TransactionDescription.ts | 33 +++++++------ .../descriptions/Vendor/VendorDescription.ts | 2 +- 10 files changed, 78 insertions(+), 79 deletions(-) diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts index 6b64033e1b203..d22bcab9502c9 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 3732447ae4c0f..c8107a2fef12a 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 6aa858e5186c1..6d34183109eec 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 fc9ff40d7a4da..9d595bd3eb465 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', @@ -219,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: [ @@ -299,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 c54332a598b59..6968860f41c29 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts @@ -106,6 +106,16 @@ export const invoiceFields: INodeProperties[] = [ 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', @@ -118,16 +128,6 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, - { - displayName: 'Description', - name: 'Description', - description: 'Textual description of the line item', - type: 'string', - default: '', - typeOptions: { - alwaysOpenEditWindow: true, - }, - }, { displayName: 'Item', name: 'itemId', @@ -223,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: [ @@ -303,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 1ca80be999ccc..b2febb226779b 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 17b41b95eb853..8b23cf711d9e1 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 7835bc542353d..3bb5d300487fd 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 fb1f903daf9eb..3bc33b9c4a18d 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 a11aefafe5d09..053711c5c6cad 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,