fix(Invoice Ninja Node): Fix emailing and marking invoice as paid / sent (#9589)

This commit is contained in:
CodeShakingSheep 2024-07-04 13:38:03 -05:00 committed by GitHub
parent 757feaf585
commit 908ddd8a24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 7 deletions

View file

@ -158,6 +158,12 @@ export const invoiceFields: INodeProperties[] = [
type: 'boolean', type: 'boolean',
default: false, default: false,
}, },
{
displayName: 'Mark Sent',
name: 'markSent',
type: 'boolean',
default: false,
},
{ {
displayName: 'Paid', displayName: 'Paid',
name: 'paid', name: 'paid',

View file

@ -421,7 +421,6 @@ export class InvoiceNinja implements INodeType {
if (apiVersion === 'v4') { if (apiVersion === 'v4') {
body.invoice_number = additionalFields.invoiceNumber as string; body.invoice_number = additionalFields.invoiceNumber as string;
} else if (apiVersion === 'v5') { } else if (apiVersion === 'v5') {
// eslint-disable-next-line id-denylist
body.number = additionalFields.invoiceNumber as string; body.number = additionalFields.invoiceNumber as string;
} }
} }
@ -462,10 +461,21 @@ export class InvoiceNinja implements INodeType {
body.discount = additionalFields.discount as number; body.discount = additionalFields.discount as number;
} }
if (additionalFields.paid) { if (additionalFields.paid) {
body.paid = additionalFields.paid as number; if (apiVersion === 'v4') {
body.paid = additionalFields.paid as number;
} else if (apiVersion === 'v5') {
qs.amount_paid = additionalFields.paid as number;
}
} }
if (additionalFields.emailInvoice) { if (additionalFields.emailInvoice) {
body.email_invoice = additionalFields.emailInvoice as boolean; if (apiVersion === 'v4') {
body.email_invoice = additionalFields.emailInvoice as boolean;
} else if (apiVersion === 'v5') {
qs.send_email = additionalFields.emailInvoice as boolean;
}
}
if (additionalFields.markSent) {
qs.mark_sent = additionalFields.markSent as boolean;
} }
const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject) const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject)
.invoiceItemsValues as IDataObject[]; .invoiceItemsValues as IDataObject[];
@ -501,6 +511,7 @@ export class InvoiceNinja implements INodeType {
'POST', 'POST',
'/invoices', '/invoices',
body as IDataObject, body as IDataObject,
qs,
); );
responseData = responseData.data; responseData = responseData.data;
} }
@ -879,7 +890,6 @@ export class InvoiceNinja implements INodeType {
if (apiVersion === 'v4') { if (apiVersion === 'v4') {
body.invoice_number = additionalFields.quoteNumber as string; body.invoice_number = additionalFields.quoteNumber as string;
} else if (apiVersion === 'v5') { } else if (apiVersion === 'v5') {
// eslint-disable-next-line id-denylist
body.number = additionalFields.quoteNumber as string; body.number = additionalFields.quoteNumber as string;
} }
} }

View file

@ -27,7 +27,7 @@ export const quoteOperations: INodeProperties[] = [
{ {
name: 'Email', name: 'Email',
value: 'email', value: 'email',
description: 'Email an quote', description: 'Email a quote',
action: 'Email a quote', action: 'Email a quote',
}, },
{ {

View file

@ -15,10 +15,10 @@ export interface IInvoice {
client_id?: number; client_id?: number;
custom_value1?: number; custom_value1?: number;
custom_value2?: number; custom_value2?: number;
email_invoice?: boolean;
email?: string;
discount?: number; discount?: number;
due_date?: string; due_date?: string;
email_invoice?: boolean;
email?: string;
invoice_date?: string; invoice_date?: string;
invoice_items?: IItem[]; invoice_items?: IItem[];
line_items?: IItem[]; line_items?: IItem[];