diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 395f366ee8..abbff679a0 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -133,11 +133,12 @@ const adjustOtherAddressFields = adjustLocationFields('Other_Address'); /** * Remove a date field's timestamp. */ -const adjustDateField = (dateType: DateType) => (allFields: DateField) => { +const adjustDateField = (dateType: DateType) => (allFields: IDataObject) => { const dateField = allFields[dateType]; if (!dateField) return allFields; + // @ts-ignore TODO allFields[dateType] = dateField.split('T')[0]; return allFields; @@ -145,14 +146,47 @@ const adjustDateField = (dateType: DateType) => (allFields: DateField) => { const adjustDateOfBirthField = adjustDateField('Date_of_Birth'); const adjustClosingDateField = adjustDateField('Closing_Date'); +const adjustInvoiceDateField = adjustDateField('Invoice_Date'); +const adjustDueDateField = adjustDateField('Due_Date'); + +const adjustAccountField = (allFields: IDataObject) => { + if (!allFields.Account_Name) return allFields; + + // @ts-ignore TODO + return { ...omit('Account_Name', allFields), ...allFields.Account_Name.account_name_fields }; +}; + +// ---------------------------------------- +// field adjusters per resource +// ---------------------------------------- + +export const adjustAccountFields = flow( + adjustBillingAddressFields, + adjustShippingAddressFields, +); + +export const adjustContactFields = flow( + adjustMailingAddressFields, + adjustOtherAddressFields, + adjustDateOfBirthField, +); -export const adjustAccountFields = flow(adjustBillingAddressFields, adjustShippingAddressFields); -export const adjustContactFields = flow(adjustMailingAddressFields, adjustOtherAddressFields, adjustDateOfBirthField); export const adjustDealFields = adjustClosingDateField; -export const adjustInvoiceFields = flow(adjustBillingAddressFields, adjustShippingAddressFields); // TODO: product details + +export const adjustInvoiceFields = flow( + adjustBillingAddressFields, + adjustShippingAddressFields, + adjustInvoiceDateField, + adjustDueDateField, + adjustAccountField, +); + export const adjustLeadFields = adjustAddressFields; + export const adjustPurchaseOrderFields = adjustInvoiceFields; + export const adjustQuoteFields = adjustInvoiceFields; + export const adjustSalesOrderFields = adjustInvoiceFields; // ---------------------------------------- @@ -176,6 +210,6 @@ type LocationField = { address_fields: { [key in LocationType]: string }; }; -type DateType = 'Date_of_Birth' | 'Closing_Date'; +type DateType = 'Date_of_Birth' | 'Closing_Date' | 'Due_Date' | 'Invoice_Date'; -type DateField = { Date_of_Birth?: string; Closing_Date?: string; }; +type DateField = { Date_of_Birth?: string; Closing_Date?: string; Due_Date?: string; Invoice_Date?: string }; diff --git a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts index b1f297b1af..21ee86d514 100644 --- a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts +++ b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts @@ -380,8 +380,10 @@ export class ZohoCrm implements INodeType { // ---------------------------------------- const body: IDataObject = { - Product_Details: this.getNodeParameter('Product_Details', i), - Subject: this.getNodeParameter('Subject', i), + Product_Details: [ + this.getNodeParameter('Product_Details', i), + ], + Subject: this.getNodeParameter('subject', i), }; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; diff --git a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts index 24ab842cee..9fc38861cd 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts @@ -52,23 +52,6 @@ export const invoiceFields = [ // ---------------------------------------- // invoice: create // ---------------------------------------- - { - displayName: 'Product Details', - name: 'productDetails', - type: '', - required: true, - default: '', - displayOptions: { - show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], - }, - }, - }, { displayName: 'Subject', name: 'subject', @@ -87,6 +70,7 @@ export const invoiceFields = [ }, }, }, + productDetails('invoice', 'create'), { displayName: 'Additional Fields', name: 'additionalFields', @@ -105,9 +89,10 @@ export const invoiceFields = [ }, options: [ { - displayName: 'Account Name', + displayName: 'Account', name: 'Account_Name', type: 'fixedCollection', + description: 'Account who the invoice is issued for.', default: {}, placeholder: 'Add Account Name Field', options: [ @@ -121,6 +106,12 @@ export const invoiceFields = [ type: 'string', default: '', }, + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + }, ], }, ], @@ -149,7 +140,7 @@ export const invoiceFields = [ { displayName: 'Due Date', name: 'Due_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -169,7 +160,7 @@ export const invoiceFields = [ { displayName: 'Invoice Date', name: 'Invoice_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -181,7 +172,7 @@ export const invoiceFields = [ { displayName: 'Sales Commission', name: 'Sales_Commission', - type: 'string', + type: 'number', default: '', description: 'Commission of sales person on deal closure.', }, @@ -320,6 +311,12 @@ export const invoiceFields = [ type: 'string', default: '', }, + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + }, ], }, ], @@ -348,7 +345,7 @@ export const invoiceFields = [ { displayName: 'Due Date', name: 'Due_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -368,7 +365,7 @@ export const invoiceFields = [ { displayName: 'Invoice Date', name: 'Invoice_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -377,11 +374,10 @@ export const invoiceFields = [ type: 'string', default: '', }, - productDetails, { displayName: 'Sales Commission', name: 'Sales_Commission', - type: 'string', + type: 'number', default: '', description: 'Commission of sales person on deal closure.', }, diff --git a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts index 9d8013b8b3..ed34545945 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts @@ -216,7 +216,7 @@ export const purchaseOrderFields = [ default: '', description: 'ID of the purchase order after creating a case.', }, - productDetails, + // productDetails, { displayName: 'Sales Commission', name: 'Sales_Commission', @@ -417,7 +417,7 @@ export const purchaseOrderFields = [ default: '', description: 'ID of the purchase order after creating a case.', }, - productDetails, + // productDetails, { displayName: 'Sales Commission', name: 'Sales_Commission', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts index 138ebcf202..719fc8135e 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts @@ -52,23 +52,6 @@ export const quoteFields = [ // ---------------------------------------- // quote: create // ---------------------------------------- - { - displayName: 'Product Details', - name: 'productDetails', - type: '', - required: true, - default: '', - displayOptions: { - show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], - }, - }, - }, { displayName: 'Subject', name: 'subject', @@ -318,7 +301,7 @@ export const quoteFields = [ default: '', description: 'Total amount for the product after deducting tax and discounts.', }, - productDetails, + // productDetails, { displayName: 'Quote Stage', name: 'Quote_Stage', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts index 49edc9cc1f..109bccf38f 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts @@ -212,7 +212,7 @@ export const salesOrderFields = [ default: '', description: 'Total amount for the product after deducting tax and discounts.', }, - productDetails, + // productDetails, { displayName: 'Purchase Order', name: 'Purchase_Order', @@ -487,7 +487,7 @@ export const salesOrderFields = [ default: '', description: 'Total amount for the product after deducting tax and discounts.', }, - productDetails, + // productDetails, { displayName: 'Purchase Order', name: 'Purchase_Order', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts b/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts index 13e58c5262..a20447be0c 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts @@ -222,87 +222,105 @@ export const address = { ], }; -export const productDetails = { +export const productDetails = (resource: string, operation: string) => ({ displayName: 'Product Details', name: 'Product_Details', - type: 'fixedCollection', + type: 'collection', default: {}, - placeholder: 'Add Product Details Field', + placeholder: 'Add Field', + displayOptions: { + show: { + resource: [ + resource, + ], + operation: [ + operation, + ], + }, + }, options: [ { - displayName: 'Product Details Fields', - name: 'product_details_fields', - values: [ + displayName: 'List Price', + name: 'list_price', + type: 'number', + default: '', + }, + { + displayName: 'Net Total', + name: 'net_total', + type: 'number', + default: '', + }, + { + displayName: 'Product', + name: 'product', + type: 'collection', + default: {}, + options: [ { - displayName: 'Tax', - name: 'Tax', + displayName: 'ID', + name: 'id', type: 'string', default: '', }, { - displayName: 'Book', - name: 'book', + displayName: 'Name', + name: 'name', type: 'string', default: '', }, { - displayName: 'List Price', - name: 'list_price', - type: 'string', - default: '', - }, - { - displayName: 'Net Total', - name: 'net_total', - type: 'string', - default: '', - }, - { - displayName: 'Product', - name: 'product', - type: 'string', - default: '', - }, - { - displayName: 'Product Description', - name: 'product_description', - type: 'string', - default: '', - }, - { - displayName: 'Quantity', - name: 'quantity', - type: 'string', - default: '', - }, - { - displayName: 'Quantity in Stock', - name: 'quantity_in_stock', - type: 'string', - default: '', - }, - { - displayName: 'Total', - name: 'total', - type: 'string', - default: '', - }, - { - displayName: 'Total After Discount', - name: 'total_after_discount', - type: 'string', - default: '', - }, - { - displayName: 'Unit Price', - name: 'unit_price', + displayName: 'Product Code', + name: 'Product_Code', type: 'string', default: '', }, ], }, + { + displayName: 'Product Description', + name: 'product_description', + type: 'string', + default: '', + }, + { + displayName: 'Quantity', + name: 'quantity', + type: 'number', + default: '', + }, + { + displayName: 'Quantity in Stock', + name: 'quantity_in_stock', + type: 'number', + default: '', + }, + { + displayName: 'Tax', + name: 'Tax', + type: 'number', + default: '', + }, + { + displayName: 'Total', + name: 'total', + type: 'number', + default: '', + }, + { + displayName: 'Total After Discount', + name: 'total_after_discount', + type: 'number', + default: '', + }, + { + displayName: 'Unit Price', + name: 'unit_price', + type: 'number', + default: '', + }, ], -}; +}); export const makeGetAllFields = (resource: string) => [ {