mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
Add Create and Update for Invoice API
This commit is contained in:
parent
2a57b15e10
commit
0121e3b85c
|
@ -362,6 +362,21 @@ export class Harvest implements INodeType {
|
|||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||
returnData.push(responseData);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// update
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'PATCH';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
endpoint = `${resource}/${id}`;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
Object.assign(body, updateFields);
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||
returnData.push(responseData);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// delete
|
||||
|
@ -574,7 +589,7 @@ export class Harvest implements INodeType {
|
|||
requestMethod = 'POST';
|
||||
endpoint = resource;
|
||||
|
||||
body.name = this.getNodeParameter('name', i) as string;
|
||||
body.client_id = this.getNodeParameter('client_id', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
Object.assign(body, additionalFields);
|
||||
|
|
|
@ -204,6 +204,254 @@ export const invoiceFields = [
|
|||
},
|
||||
},
|
||||
description: 'The ID of the invoice want to delete.',
|
||||
}
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'client_id',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource,
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
required: true,
|
||||
description: 'The ID of the retainer associated with this invoice..',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource,
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Retainer Id',
|
||||
name: 'retainer_id',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'The ID of the retainer associated with this invoice.'
|
||||
},
|
||||
{
|
||||
displayName: 'Estimate Id',
|
||||
name: 'estimate_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the estimate associated with this invoice.'
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'If no value is set, the number will be automatically generated.'
|
||||
},
|
||||
{
|
||||
displayName: 'Purchase Order',
|
||||
name: 'purchase_order',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The purchase order number.'
|
||||
},
|
||||
{
|
||||
displayName: 'Tax',
|
||||
name: 'tax',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Tax2',
|
||||
name: 'tax2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Discount',
|
||||
name: 'over_budget_notification_percentage',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The invoice subject.'
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies'
|
||||
},
|
||||
{
|
||||
displayName: 'Payment Term',
|
||||
name: 'payment_term',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Notes about the project.'
|
||||
},
|
||||
{
|
||||
displayName: 'Issue Date',
|
||||
name: 'issue_date',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date the invoice was issued. Defaults to today’s date.'
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'ends_on',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource,
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'client_id',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the retainer associated with this invoice..',
|
||||
},
|
||||
{
|
||||
displayName: 'Retainer Id',
|
||||
name: 'retainer_id',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'The ID of the retainer associated with this invoice.'
|
||||
},
|
||||
{
|
||||
displayName: 'Estimate Id',
|
||||
name: 'estimate_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the estimate associated with this invoice.'
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'If no value is set, the number will be automatically generated.'
|
||||
},
|
||||
{
|
||||
displayName: 'Purchase Order',
|
||||
name: 'purchase_order',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The purchase order number.'
|
||||
},
|
||||
{
|
||||
displayName: 'Tax',
|
||||
name: 'tax',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Tax2',
|
||||
name: 'tax2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Discount',
|
||||
name: 'over_budget_notification_percentage',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The invoice subject.'
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies'
|
||||
},
|
||||
{
|
||||
displayName: 'Payment Term',
|
||||
name: 'payment_term',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Notes about the project.'
|
||||
},
|
||||
{
|
||||
displayName: 'Issue Date',
|
||||
name: 'issue_date',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date the invoice was issued. Defaults to today’s date.'
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'ends_on',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
|
|
@ -383,8 +383,8 @@ export const projectFields = [
|
|||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
|
@ -535,3 +535,4 @@ export const projectFields = [
|
|||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
|
|
Loading…
Reference in a new issue