Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n8n-3703 QuickBooks Online: Creation of Invoices & Quotes fails for Non-US #3404

Merged
merged 2 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
Expand Down Expand Up @@ -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;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -116,30 +133,22 @@ 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',
description: 'Position of the line item relative to others',
type: 'number',
default: 1,
},
{
displayName: 'Tax Code Ref',
name: 'TaxCodeRef',
type: 'options',
default: [],
typeOptions: {
loadOptionsMethod: 'getTaxCodeRefs',
},
},
],
},
{
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -120,30 +137,22 @@ 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',
description: 'Position of the line item relative to others',
type: 'number',
default: 1,
},
{
displayName: 'Tax Code Ref',
name: 'TaxCodeRef',
type: 'options',
default: [],
typeOptions: {
loadOptionsMethod: 'getTaxCodeRefs',
},
},
],
},
{
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading