diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 98c11223ff..395f366ee8 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -130,15 +130,25 @@ const adjustMailingAddressFields = adjustLocationFields('Mailing_Address'); const adjustShippingAddressFields = adjustLocationFields('Shipping_Address'); const adjustOtherAddressFields = adjustLocationFields('Other_Address'); -const adjustDateOfBirth = (allFields: { Date_of_Birth: string }) => { - if (!allFields.Date_of_Birth) return allFields; - allFields.Date_of_Birth = allFields.Date_of_Birth.split('T')[0]; +/** + * Remove a date field's timestamp. + */ +const adjustDateField = (dateType: DateType) => (allFields: DateField) => { + const dateField = allFields[dateType]; + + if (!dateField) return allFields; + + allFields[dateType] = dateField.split('T')[0]; return allFields; }; +const adjustDateOfBirthField = adjustDateField('Date_of_Birth'); +const adjustClosingDateField = adjustDateField('Closing_Date'); + export const adjustAccountFields = flow(adjustBillingAddressFields, adjustShippingAddressFields); -export const adjustContactFields = flow(adjustMailingAddressFields, adjustOtherAddressFields, adjustDateOfBirth); +export const adjustContactFields = flow(adjustMailingAddressFields, adjustOtherAddressFields, adjustDateOfBirthField); +export const adjustDealFields = adjustClosingDateField; export const adjustInvoiceFields = flow(adjustBillingAddressFields, adjustShippingAddressFields); // TODO: product details export const adjustLeadFields = adjustAddressFields; export const adjustPurchaseOrderFields = adjustInvoiceFields; @@ -165,3 +175,7 @@ type LocationType = 'Address' | 'Billing_Address' | 'Mailing_Address' | 'Shippin type LocationField = { address_fields: { [key in LocationType]: string }; }; + +type DateType = 'Date_of_Birth' | 'Closing_Date'; + +type DateField = { Date_of_Birth?: string; Closing_Date?: string; }; diff --git a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts index d9b2de8820..b1f297b1af 100644 --- a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts +++ b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts @@ -12,6 +12,7 @@ import { import { adjustAccountFields, adjustContactFields, + adjustDealFields, adjustInvoiceFields, adjustLeadFields, adjustPurchaseOrderFields, @@ -305,14 +306,14 @@ export class ZohoCrm implements INodeType { // ---------------------------------------- const body: IDataObject = { - Deal_Name: this.getNodeParameter('Deal_Name', i), - Stage: this.getNodeParameter('Stage', i), + Deal_Name: this.getNodeParameter('dealName', i), + Stage: this.getNodeParameter('stage', i), }; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (Object.keys(additionalFields).length) { - Object.assign(body, additionalFields); + Object.assign(body, adjustDealFields(additionalFields)); } responseData = await zohoApiRequest.call(this, 'POST', '/deals', body); @@ -355,7 +356,7 @@ export class ZohoCrm implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (Object.keys(updateFields).length) { - Object.assign(body, updateFields); + Object.assign(body, adjustDealFields(updateFields)); } const dealId = this.getNodeParameter('dealId', i); diff --git a/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts index 51bb018675..2abad88cfc 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts @@ -107,7 +107,7 @@ export const accountFields = [ { displayName: 'Annual Revenue', name: 'Annual_Revenue', - type: 'string', + type: 'number', default: '', }, billingAddress, @@ -140,7 +140,7 @@ export const accountFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, @@ -293,7 +293,7 @@ export const accountFields = [ { displayName: 'Annual Revenue', name: 'Annual_Revenue', - type: 'string', + type: 'number', default: '', }, billingAddress, @@ -326,7 +326,7 @@ export const accountFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, diff --git a/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts index 5c5ed6dab9..4a37f05969 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts @@ -110,7 +110,7 @@ export const dealFields = [ { displayName: 'Closing Date', name: 'Closing_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -150,9 +150,13 @@ export const dealFields = [ { displayName: 'Probability', name: 'Probability', - type: 'string', + type: 'number', + typeOptions: { + minValue: 0, + maxValue: 100, + }, default: '', - description: 'Probability of deal closure.', + description: 'Probability of deal closure as a percentage.', }, { displayName: 'Sales Cycle Duration', @@ -261,7 +265,7 @@ export const dealFields = [ { displayName: 'Closing Date', name: 'Closing_Date', - type: 'string', + type: 'dateTime', default: '', }, { @@ -307,9 +311,13 @@ export const dealFields = [ { displayName: 'Probability', name: 'Probability', - type: 'string', + type: 'number', + typeOptions: { + minValue: 0, + maxValue: 100, + }, default: '', - description: 'Probability of deal closure.', + description: 'Probability of deal closure as a percentage.', }, { displayName: 'Sales Cycle Duration', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts index b058c3b8e0..24ab842cee 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts @@ -155,7 +155,7 @@ export const invoiceFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, @@ -354,7 +354,7 @@ export const invoiceFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, diff --git a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts index 80c39b6dcd..9d8013b8b3 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts @@ -191,7 +191,7 @@ export const purchaseOrderFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, @@ -392,7 +392,7 @@ export const purchaseOrderFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, diff --git a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts index d22235202f..138ebcf202 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts @@ -134,7 +134,7 @@ export const quoteFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, @@ -307,7 +307,7 @@ export const quoteFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, diff --git a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts index 271dd19c2b..49edc9cc1f 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts @@ -201,7 +201,7 @@ export const salesOrderFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', }, @@ -476,7 +476,7 @@ export const salesOrderFields = [ { displayName: 'Exchange Rate', name: 'Exchange_Rate', - type: 'string', + type: 'number', default: '', description: 'Exchange rate of the default currency to the home currency.', },