mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix(Invoice Ninja Node): Fix assigning an invoice to a payment (#9590)
This commit is contained in:
parent
f64ca621e1
commit
7a3c127b2c
|
@ -660,18 +660,31 @@ export class InvoiceNinja implements INodeType {
|
|||
if (resource === 'payment') {
|
||||
if (operation === 'create') {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const invoice = this.getNodeParameter('invoice', i) as number;
|
||||
const invoice = this.getNodeParameter('invoice', i) as number | string;
|
||||
const client = (
|
||||
await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${invoice}`, {}, qs)
|
||||
).data?.client_id as string;
|
||||
const amount = this.getNodeParameter('amount', i) as number;
|
||||
const body: IPayment = {
|
||||
invoice_id: invoice,
|
||||
amount,
|
||||
client_id: client,
|
||||
};
|
||||
if (apiVersion === 'v4') {
|
||||
body.invoice_id = invoice as number;
|
||||
} else if (apiVersion === 'v5') {
|
||||
body.invoices = [
|
||||
{
|
||||
invoice_id: invoice as string,
|
||||
amount,
|
||||
},
|
||||
];
|
||||
}
|
||||
if (additionalFields.paymentType) {
|
||||
body.payment_type_id = additionalFields.paymentType as number;
|
||||
if (apiVersion === 'v4') {
|
||||
body.payment_type_id = additionalFields.paymentType as number;
|
||||
} else if (apiVersion == 'v5') {
|
||||
body.type_id = additionalFields.paymentType as number;
|
||||
}
|
||||
}
|
||||
if (additionalFields.transferReference) {
|
||||
body.transaction_reference = additionalFields.transferReference as string;
|
||||
|
|
|
@ -2,7 +2,14 @@ export interface IPayment {
|
|||
invoice_id?: number;
|
||||
amount?: number;
|
||||
payment_type_id?: number;
|
||||
type_id?: number;
|
||||
transaction_reference?: string;
|
||||
private_notes?: string;
|
||||
client_id?: string;
|
||||
invoices?: IInvoice[];
|
||||
}
|
||||
|
||||
export interface IInvoice {
|
||||
invoice_id: string;
|
||||
amount: number;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue