2021-04-29 02:56:19 -07:00
|
|
|
import {
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
import {
|
|
|
|
billingAddress,
|
|
|
|
makeGetAllFields,
|
|
|
|
productDetails,
|
|
|
|
shippingAddress,
|
|
|
|
} from './SharedFields';
|
|
|
|
|
|
|
|
export const invoiceOperations = [
|
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get All',
|
|
|
|
value: 'getAll',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
description: 'Operation to perform',
|
|
|
|
},
|
|
|
|
] as INodeProperties[];
|
|
|
|
|
|
|
|
export const invoiceFields = [
|
|
|
|
// ----------------------------------------
|
|
|
|
// invoice: create
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Subject',
|
|
|
|
name: 'subject',
|
|
|
|
description: 'Subject or title of the invoice.',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-05-07 08:28:42 -07:00
|
|
|
productDetails('invoice', 'create'),
|
2021-04-29 02:56:19 -07:00
|
|
|
{
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
name: 'additionalFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
2021-05-07 08:28:42 -07:00
|
|
|
displayName: 'Account',
|
2021-04-29 02:56:19 -07:00
|
|
|
name: 'Account_Name',
|
|
|
|
type: 'fixedCollection',
|
2021-05-07 08:28:42 -07:00
|
|
|
description: 'Account who the invoice is issued for.',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: {},
|
|
|
|
placeholder: 'Add Account Name Field',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Account Name Fields',
|
|
|
|
name: 'account_name_fields',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'ID',
|
|
|
|
name: 'id',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
2021-05-07 08:28:42 -07:00
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
2021-04-29 02:56:19 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Adjustment',
|
|
|
|
name: 'Adjustment',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Adjustment in the grand total, if any.',
|
|
|
|
},
|
|
|
|
billingAddress,
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
|
|
|
name: 'Currency',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Symbol of the currency in which revenue is generated.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'Description',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Due Date',
|
|
|
|
name: 'Due_Date',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'dateTime',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Exchange Rate',
|
|
|
|
name: 'Exchange_Rate',
|
2021-05-07 04:19:01 -07:00
|
|
|
type: 'number',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
description: 'Exchange rate of the default currency to the home currency.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Grand Total',
|
|
|
|
name: 'Grand_Total',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Total amount for the product after deducting tax and discounts.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Invoice Date',
|
|
|
|
name: 'Invoice_Date',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'dateTime',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Invoice Number',
|
|
|
|
name: 'Invoice_Number',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Sales Commission',
|
|
|
|
name: 'Sales_Commission',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'number',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
description: 'Commission of sales person on deal closure.',
|
|
|
|
},
|
|
|
|
shippingAddress,
|
|
|
|
{
|
|
|
|
displayName: 'Status',
|
|
|
|
name: 'Status',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Sub Total',
|
|
|
|
name: 'Sub_Total',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Total amount for the product excluding tax.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Tax',
|
|
|
|
name: 'Tax',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Tax amount as the sum of sales tax and value-added tax.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Terms and Conditions',
|
|
|
|
name: 'Terms_and_Conditions',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Terms and conditions associated with the invoice.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// invoice: delete
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Invoice ID',
|
|
|
|
name: 'invoiceId',
|
|
|
|
description: 'ID of the invoice to delete.',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'delete',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// invoice: get
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Invoice ID',
|
|
|
|
name: 'invoiceId',
|
|
|
|
description: 'ID of the invoice to retrieve.',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'get',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// invoice: getAll
|
|
|
|
// ----------------------------------------
|
|
|
|
...makeGetAllFields('invoice'),
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// invoice: update
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Invoice ID',
|
|
|
|
name: 'invoiceId',
|
|
|
|
description: 'ID of the invoice to update.',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Update Fields',
|
|
|
|
name: 'updateFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'invoice',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Account Name',
|
|
|
|
name: 'Account_Name',
|
|
|
|
type: 'fixedCollection',
|
|
|
|
default: {},
|
|
|
|
placeholder: 'Add Account Name Field',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Account Name Fields',
|
|
|
|
name: 'account_name_fields',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'ID',
|
|
|
|
name: 'id',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
2021-05-07 08:28:42 -07:00
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
2021-04-29 02:56:19 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Adjustment',
|
|
|
|
name: 'Adjustment',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Adjustment in the grand total, if any.',
|
|
|
|
},
|
|
|
|
billingAddress,
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
|
|
|
name: 'Currency',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Symbol of the currency in which revenue is generated.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'Description',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Due Date',
|
|
|
|
name: 'Due_Date',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'dateTime',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Exchange Rate',
|
|
|
|
name: 'Exchange_Rate',
|
2021-05-07 04:19:01 -07:00
|
|
|
type: 'number',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
description: 'Exchange rate of the default currency to the home currency.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Grand Total',
|
|
|
|
name: 'Grand_Total',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Total amount for the product after deducting tax and discounts.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Invoice Date',
|
|
|
|
name: 'Invoice_Date',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'dateTime',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Invoice Number',
|
|
|
|
name: 'Invoice_Number',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Sales Commission',
|
|
|
|
name: 'Sales_Commission',
|
2021-05-07 08:28:42 -07:00
|
|
|
type: 'number',
|
2021-04-29 02:56:19 -07:00
|
|
|
default: '',
|
|
|
|
description: 'Commission of sales person on deal closure.',
|
|
|
|
},
|
|
|
|
shippingAddress,
|
|
|
|
{
|
|
|
|
displayName: 'Status',
|
|
|
|
name: 'Status',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Sub Total',
|
|
|
|
name: 'Sub_Total',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Total amount for the product excluding tax.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Subject',
|
|
|
|
name: 'Subject',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Subject or title of the invoice.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Tax',
|
|
|
|
name: 'Tax',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
description: 'Tax amount as the sum of sales tax and value-added tax.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Terms and Conditions',
|
|
|
|
name: 'Terms_and_Conditions',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Terms and conditions associated with the invoice.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
] as INodeProperties[];
|