mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
feat(QuickBooks Node): Add optional Tax item field (#3404)
* Added tax refs * Nodelinter fixes
This commit is contained in:
parent
f02421b5f3
commit
c341b45396
|
@ -138,7 +138,7 @@ export async function quickBooksApiRequestAllItems(
|
||||||
responseData = await quickBooksApiRequest.call(this, method, endpoint, qs, body);
|
responseData = await quickBooksApiRequest.call(this, method, endpoint, qs, body);
|
||||||
try {
|
try {
|
||||||
const nonResource = originalQuery.split(' ')?.pop();
|
const nonResource = originalQuery.split(' ')?.pop();
|
||||||
if (nonResource === 'CreditMemo' || nonResource === 'Term') {
|
if (nonResource === 'CreditMemo' || nonResource === 'Term' || nonResource === 'TaxCode') {
|
||||||
returnData.push(...responseData.QueryResponse[nonResource]);
|
returnData.push(...responseData.QueryResponse[nonResource]);
|
||||||
} else {
|
} else {
|
||||||
returnData.push(...responseData.QueryResponse[capitalCase(resource)]);
|
returnData.push(...responseData.QueryResponse[capitalCase(resource)]);
|
||||||
|
@ -334,18 +334,27 @@ export function processLines(
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
value: line.itemId,
|
value: line.itemId,
|
||||||
},
|
},
|
||||||
|
TaxCodeRef : {
|
||||||
|
value: line.TaxCodeRef,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
delete line.itemId;
|
delete line.itemId;
|
||||||
|
delete line.TaxCodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (resource === 'invoice') {
|
} else if (resource === 'invoice') {
|
||||||
if (line.DetailType === 'SalesItemLineDetail') {
|
if (line.DetailType === 'SalesItemLineDetail') {
|
||||||
line.SalesItemLineDetail = {
|
line.SalesItemLineDetail = {
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
value: line.itemId,
|
value: line.itemId,
|
||||||
},
|
},
|
||||||
|
TaxCodeRef : {
|
||||||
|
value: line.TaxCodeRef,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
delete line.itemId;
|
delete line.itemId;
|
||||||
|
delete line.TaxCodeRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,10 @@ export class QuickBooks implements INodeType {
|
||||||
return await loadResource.call(this, 'purchase');
|
return await loadResource.call(this, 'purchase');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getTaxCodeRefs(this: ILoadOptionsFunctions) {
|
||||||
|
return await loadResource.call(this, 'TaxCode');
|
||||||
|
},
|
||||||
|
|
||||||
async getTerms(this: ILoadOptionsFunctions) {
|
async getTerms(this: ILoadOptionsFunctions) {
|
||||||
return await loadResource.call(this, 'Term');
|
return await loadResource.call(this, 'Term');
|
||||||
},
|
},
|
||||||
|
@ -503,7 +507,6 @@ export class QuickBooks implements INodeType {
|
||||||
} as IDataObject;
|
} as IDataObject;
|
||||||
|
|
||||||
body.Line = processLines.call(this, body, lines, resource);
|
body.Line = processLines.call(this, body, lines, resource);
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
body = populateFields.call(this, body, additionalFields, resource);
|
body = populateFields.call(this, body, additionalFields, resource);
|
||||||
|
|
|
@ -91,6 +91,29 @@ export const billFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
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',
|
displayName: 'Detail Type',
|
||||||
name: 'DetailType',
|
name: 'DetailType',
|
||||||
|
@ -116,29 +139,6 @@ export const billFields: INodeProperties[] = [
|
||||||
loadOptionsMethod: 'getItems',
|
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',
|
displayName: 'Position',
|
||||||
name: 'LineNum',
|
name: 'LineNum',
|
||||||
|
@ -235,7 +235,7 @@ export const billFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -128,7 +128,7 @@ export const customerFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -142,7 +142,7 @@ export const employeeFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -95,6 +95,23 @@ export const estimateFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
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',
|
displayName: 'Detail Type',
|
||||||
name: 'DetailType',
|
name: 'DetailType',
|
||||||
|
@ -116,23 +133,6 @@ export const estimateFields: INodeProperties[] = [
|
||||||
loadOptionsMethod: 'getItems',
|
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',
|
displayName: 'Position',
|
||||||
name: 'LineNum',
|
name: 'LineNum',
|
||||||
|
@ -140,6 +140,15 @@ export const estimateFields: INodeProperties[] = [
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 1,
|
default: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Tax Code Ref',
|
||||||
|
name: 'TaxCodeRef',
|
||||||
|
type: 'options',
|
||||||
|
default: [],
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTaxCodeRefs',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -210,7 +219,7 @@ export const estimateFields: INodeProperties[] = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
required: true,
|
required: true,
|
||||||
default: false,
|
default: false,
|
||||||
description: 'Download the estimate as a PDF file',
|
description: 'Whether to download the estimate as a PDF file',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
@ -290,7 +299,7 @@ export const estimateFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -99,6 +99,23 @@ export const invoiceFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
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',
|
displayName: 'Detail Type',
|
||||||
name: 'DetailType',
|
name: 'DetailType',
|
||||||
|
@ -120,23 +137,6 @@ export const invoiceFields: INodeProperties[] = [
|
||||||
loadOptionsMethod: 'getItems',
|
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',
|
displayName: 'Position',
|
||||||
name: 'LineNum',
|
name: 'LineNum',
|
||||||
|
@ -144,6 +144,15 @@ export const invoiceFields: INodeProperties[] = [
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 1,
|
default: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Tax Code Ref',
|
||||||
|
name: 'TaxCodeRef',
|
||||||
|
type: 'options',
|
||||||
|
default: [],
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTaxCodeRefs',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -214,7 +223,7 @@ export const invoiceFields: INodeProperties[] = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
required: true,
|
required: true,
|
||||||
default: false,
|
default: false,
|
||||||
description: 'Download the invoice as a PDF file',
|
description: 'Whether to download the invoice as a PDF file',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
@ -294,7 +303,7 @@ export const invoiceFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -76,7 +76,7 @@ export const itemFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -163,7 +163,7 @@ export const paymentFields: INodeProperties[] = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
required: true,
|
required: true,
|
||||||
default: false,
|
default: false,
|
||||||
description: 'Download estimate as PDF file',
|
description: 'Whether to download estimate as PDF file',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
@ -243,7 +243,7 @@ export const paymentFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -76,7 +76,7 @@ export const purchaseFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
|
@ -44,7 +44,7 @@ export const transactionFields: INodeProperties[] = [
|
||||||
// transaction: getReport
|
// transaction: getReport
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Simplify',
|
displayName: 'Simplify Response',
|
||||||
name: 'simple',
|
name: 'simple',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
|
@ -264,13 +264,6 @@ export const transactionFields: INodeProperties[] = [
|
||||||
description: 'Predefined account modifiction date range to filter results by',
|
description: 'Predefined account modifiction date range to filter results by',
|
||||||
options: PREDEFINED_DATE_RANGES.map(toOptions),
|
options: PREDEFINED_DATE_RANGES.map(toOptions),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Document Number',
|
|
||||||
name: 'docnum',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
description: 'Transaction document number to filter results by',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Department',
|
displayName: 'Department',
|
||||||
name: 'department',
|
name: 'department',
|
||||||
|
@ -281,6 +274,13 @@ export const transactionFields: INodeProperties[] = [
|
||||||
loadOptionsMethod: 'getDepartments',
|
loadOptionsMethod: 'getDepartments',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Document Number',
|
||||||
|
name: 'docnum',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Transaction document number to filter results by',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Group By',
|
displayName: 'Group By',
|
||||||
name: 'group_by',
|
name: 'group_by',
|
||||||
|
@ -346,6 +346,14 @@ export const transactionFields: INodeProperties[] = [
|
||||||
default: 'Ascend',
|
default: 'Ascend',
|
||||||
options: ['Ascend', 'Descend'].map(toOptions),
|
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',
|
displayName: 'Term',
|
||||||
name: 'term',
|
name: 'term',
|
||||||
|
@ -374,15 +382,6 @@ export const transactionFields: INodeProperties[] = [
|
||||||
description: 'Transaction type to filter results by',
|
description: 'Transaction type to filter results by',
|
||||||
options: TRANSACTION_TYPES.map(toOptions).map(toDisplayName),
|
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',
|
displayName: 'Vendor',
|
||||||
name: 'vendor',
|
name: 'vendor',
|
||||||
|
|
|
@ -128,7 +128,7 @@ export const vendorFields: INodeProperties[] = [
|
||||||
displayName: 'Limit',
|
displayName: 'Limit',
|
||||||
name: 'limit',
|
name: 'limit',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 5,
|
default: 50,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
|
|
Loading…
Reference in a new issue