-
Notifications
You must be signed in to change notification settings - Fork 5.5k
14645 components zoho books #14764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
14645 components zoho books #14764
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,131 +1,137 @@ | ||
| // legacy_hash_id: a_XziR2J | ||
| import { axios } from "@pipedream/platform"; | ||
| import { PAYMENT_MODE_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import zohoBooks from "../../zoho_books.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "zoho_books-create-customer-payment", | ||
| name: "Create Customer Payment", | ||
| description: "Creates a new payment.", | ||
| version: "0.2.1", | ||
| description: "Creates a new payment. [See the documentation](https://www.zoho.com/books/api/v3/customer-payments/#create-a-payment)", | ||
| version: "0.3.0", | ||
| type: "action", | ||
| props: { | ||
| zoho_books: { | ||
| type: "app", | ||
| app: "zoho_books", | ||
| }, | ||
| organization_id: { | ||
| type: "string", | ||
| description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", | ||
| }, | ||
| customer_id: { | ||
| type: "string", | ||
| description: "Customer ID of the customer involved in the payment.", | ||
| }, | ||
| payment_mode: { | ||
| type: "string", | ||
| description: "Mode through which payment is made. This can be `check`, `cash`, `creditcard`, `banktransfer`, `bankremittance`, `autotransaction` or `others`. Max-length [100]", | ||
| options: [ | ||
| "check", | ||
| "cash", | ||
| "creditcard", | ||
| "banktransfer", | ||
| "bankremittance", | ||
| "autotransaction", | ||
| "others", | ||
| zohoBooks, | ||
| customerId: { | ||
| propDefinition: [ | ||
| zohoBooks, | ||
| "customerId", | ||
| ], | ||
| }, | ||
| invoices: { | ||
| type: "any", | ||
| description: "List of invoices associated with the payment. Each invoice object contains `invoice_id`, `invoice_number`, `date`, `invoice_amount`, `amount_applied` and `balance_amount`.", | ||
| paymentMode: { | ||
| type: "string", | ||
| label: "Payment Mode", | ||
| description: "Mode through which payment is made.", | ||
| options: PAYMENT_MODE_OPTIONS, | ||
| }, | ||
| amount: { | ||
| type: "string", | ||
| label: "Amount", | ||
| description: "Amount paid in the respective payment.", | ||
| }, | ||
| date: { | ||
| type: "string", | ||
| label: "Date", | ||
| description: "Date on which payment is made. Format [yyyy-mm-dd]", | ||
| }, | ||
| reference_number: { | ||
| referenceNumber: { | ||
| type: "string", | ||
| label: "Reference Number", | ||
| description: "Reference number generated for the payment. A string of your choice can also be used as the reference number. Max-length [100]", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "Description about the payment.", | ||
| optional: true, | ||
| }, | ||
| exchange_rate: { | ||
| invoices: { | ||
| type: "string[]", | ||
| label: "Invoices", | ||
| description: "List of invoice objects associated with the payment. Each invoice object contains `invoice_id`, `invoice_number`, `date`, `invoice_amount`, `amount_applied` and `balance_amount`. **Example: {\"invoice_id\": \"90300000079426\", \"amount_applied\": 450}**", | ||
| }, | ||
| exchangeRate: { | ||
| type: "string", | ||
| label: "Exchange Rate", | ||
| description: "Exchange rate for the currency used in the invoices and customer's currency. The payment amount would be the multiplicative product of the original amount and the exchange rate. Default is 1.", | ||
| optional: true, | ||
| }, | ||
| bank_charges: { | ||
| bankCharges: { | ||
| type: "string", | ||
| label: "Bank Charges", | ||
| description: "Denotes any additional bank charges.", | ||
| optional: true, | ||
| }, | ||
| custom_fields: { | ||
| type: "any", | ||
| description: "Additional fields for the payments.", | ||
| customFields: { | ||
| propDefinition: [ | ||
| zohoBooks, | ||
| "customFields", | ||
| ], | ||
| description: "A list of Additional field objects for the payments. **Example: {\"label\": \"label\", \"value\": 129890}**", | ||
|
Comment on lines
+65
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unnecessary parsing of The Modify the - custom_fields: parseObject(this.customFields),
+ custom_fields: this.customFields,
|
||
| optional: true, | ||
| }, | ||
| invoice_id: { | ||
| type: "string", | ||
| description: "ID of the invoice to get payments of.", | ||
| optional: true, | ||
| invoiceId: { | ||
| propDefinition: [ | ||
| zohoBooks, | ||
| "invoiceId", | ||
| ({ customerId }) => ({ | ||
| customerId, | ||
| }), | ||
| ], | ||
| }, | ||
| amount_applied: { | ||
| amountApplied: { | ||
| type: "string", | ||
| label: "Amount Applied", | ||
|
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle zero values correctly for numeric fields Optional numeric fields like Update the code to explicitly check for - exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate),
+ exchange_rate: this.exchangeRate !== undefined ? parseFloat(this.exchangeRate) : undefined,
- bank_charges: this.bankCharges && parseFloat(this.bankCharges),
+ bank_charges: this.bankCharges !== undefined ? parseFloat(this.bankCharges) : undefined,
- amount_applied: this.amountApplied && parseFloat(this.amountApplied),
+ amount_applied: this.amountApplied !== undefined ? parseFloat(this.amountApplied) : undefined,
- tax_amount_withheld: this.taxAmountWithheld && parseFloat(this.taxAmountWithheld),
+ tax_amount_withheld: this.taxAmountWithheld !== undefined ? parseFloat(this.taxAmountWithheld) : undefined,Also applies to: 88-90, 123-124, 127-128 |
||
| description: "Amount paid for the invoice.", | ||
| optional: true, | ||
| }, | ||
| tax_amount_withheld: { | ||
| taxAmountWithheld: { | ||
| type: "string", | ||
| label: "Tax Amount Withheld", | ||
| description: "Amount withheld for tax.", | ||
| optional: true, | ||
| }, | ||
| account_id: { | ||
| type: "string", | ||
| description: "ID of the cash/bank account the payment has to be deposited.", | ||
| accountId: { | ||
| propDefinition: [ | ||
| zohoBooks, | ||
| "accountId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| contact_persons: { | ||
| type: "string", | ||
| description: "IDs of the contact personsthe thank you mail has to be triggered.", | ||
| contactPersons: { | ||
| propDefinition: [ | ||
| zohoBooks, | ||
| "contactPersons", | ||
| ({ customerId }) => ({ | ||
| customerId, | ||
| }), | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| //See the API docs: https://www.zoho.com/books/api/v3/#Customer-Payments_Create_a_payment | ||
|
|
||
| if (!this.organization_id || !this.customer_id || !this.payment_mode || !this.invoices || !this.amount || !this.date) { | ||
| throw new Error("Must provide organization_id, customer_id, payment_mode, invoices, amount, and date parameters."); | ||
| } | ||
|
|
||
| return await axios($, { | ||
| method: "post", | ||
| url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/customerpayments?organization_id=${this.organization_id}`, | ||
| headers: { | ||
| Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, | ||
| }, | ||
| const response = await this.zohoBooks.createCustomerPayment({ | ||
| $, | ||
| data: { | ||
| customer_id: this.customer_id, | ||
| payment_mode: this.payment_mode, | ||
| customer_id: this.customerId, | ||
| payment_mode: this.paymentMode, | ||
| amount: this.amount, | ||
| date: this.date, | ||
| reference_number: this.reference_number, | ||
| reference_number: this.referenceNumber, | ||
| description: this.description, | ||
| invoices: this.invoices, | ||
| exchange_rate: this.exchange_rate, | ||
| bank_charges: this.bank_charges, | ||
| custom_fields: this.custom_fields, | ||
| invoice_id: this.invoice_id, | ||
| amount_applied: this.amount_applied, | ||
| tax_amount_withheld: this.tax_amount_withheld, | ||
| account_id: this.account_id, | ||
| contact_persons: this.contact_persons, | ||
| invoices: parseObject(this.invoices), | ||
| exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), | ||
| bank_charges: this.bankCharges && parseFloat(this.bankCharges), | ||
| custom_fields: parseObject(this.customFields), | ||
| invoice_id: this.invoiceId, | ||
| amount_applied: this.amountApplied && parseFloat(this.amountApplied), | ||
| tax_amount_withheld: this.taxAmountWithheld && parseFloat(this.taxAmountWithheld), | ||
| account_id: this.accountId, | ||
| contact_persons: parseObject(this.contactPersons), | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Customer payment successfully created with Id: ${response.payment.payment_id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,166 @@ | ||||||||||||||||||||||||||
| // legacy_hash_id: a_Xzi1qo | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| CUSTOMER_SUB_TYPE_OPTIONS, | ||||||||||||||||||||||||||
| LANGUAGE_CODE_OPTIONS, | ||||||||||||||||||||||||||
| } from "../../common/constants.mjs"; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| clearObj, | ||||||||||||||||||||||||||
| parseObject, | ||||||||||||||||||||||||||
| } from "../../common/utils.mjs"; | ||||||||||||||||||||||||||
| import zohoBooks from "../../zoho_books.app.mjs"; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||
| key: "zoho_books-create-customer", | ||||||||||||||||||||||||||
| name: "Create Customer", | ||||||||||||||||||||||||||
| description: "Creates a new customer. [See the documentation](https://www.zoho.com/books/api/v3/items/#create-an-item)", | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect documentation link The documentation link points to the items API endpoint instead of the contacts/customers endpoint. - description: "Creates a new customer. [See the documentation](https://www.zoho.com/books/api/v3/items/#create-an-item)",
+ description: "Creates a new customer. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#create-a-contact)",📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| contactName: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Contact Name", | ||||||||||||||||||||||||||
| description: "Display Name of the contact. Max-length [200].", | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| companyName: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Company Name", | ||||||||||||||||||||||||||
| description: "Company Name of the contact. Max-length [200].", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| website: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Website", | ||||||||||||||||||||||||||
| description: "Website of the contact.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| languageCode: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Language Code", | ||||||||||||||||||||||||||
| description: "The language of a contact.", | ||||||||||||||||||||||||||
| options: LANGUAGE_CODE_OPTIONS, | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| customerSubType: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Customer Sub Type", | ||||||||||||||||||||||||||
| description: "Type of the customer.", | ||||||||||||||||||||||||||
| options: CUSTOMER_SUB_TYPE_OPTIONS, | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| creditLimit: { | ||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||
| label: "Credit Limit", | ||||||||||||||||||||||||||
| description: "Credit limit for a customer.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
|
Comment on lines
+51
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update credit limit type to number The credit limit should be a number type since it represents a monetary value. creditLimit: {
- type: "string",
+ type: "number",
label: "Credit Limit",
description: "Credit limit for a customer.",
optional: true,
},📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
| tags: { | ||||||||||||||||||||||||||
| type: "string[]", | ||||||||||||||||||||||||||
| label: "Tags", | ||||||||||||||||||||||||||
| description: "An array of tag objects. **Example: {\"tag_id\":\"124567890\",\"tag_option_id\":\"1234567890\"}**", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| isPortalEnabled: { | ||||||||||||||||||||||||||
| type: "boolean", | ||||||||||||||||||||||||||
| label: "Is Portal Enabled", | ||||||||||||||||||||||||||
| description: "To enable client portal for the contact.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| currencyId: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "currencyId", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| paymentTerms: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "paymentTerms", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| description: "Net payment term for the customer.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| paymentTermsLabel: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "paymentTermsLabel", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| description: "Label for the paymet due details.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| notes: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "notes", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| description: "Commennts about the payment made by the contact.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| exchangeRate: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "exchangeRate", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| description: "Exchange rate for the opening balance.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| vatTreatment: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "vatTreatment", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| gstNo: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "gstNo", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| avataxUseCode: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "avataxUseCode", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| taxId: { | ||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||
| zohoBooks, | ||||||||||||||||||||||||||
| "taxId", | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| description: "ID of the tax to be associated to the estimate.", | ||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||
| const response = await this.zohoBooks.createContact({ | ||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||
| data: clearObj({ | ||||||||||||||||||||||||||
| contact_name: this.contactName, | ||||||||||||||||||||||||||
| company_name: this.companyName, | ||||||||||||||||||||||||||
| website: this.website, | ||||||||||||||||||||||||||
| language_code: this.languageCode, | ||||||||||||||||||||||||||
| contact_type: "customer", | ||||||||||||||||||||||||||
| customer_sub_type: this.customerSubType, | ||||||||||||||||||||||||||
| credit_limit: this.creditLimit, | ||||||||||||||||||||||||||
| tags: parseObject(this.tags), | ||||||||||||||||||||||||||
| is_portal_enabled: this.isPortalEnabled, | ||||||||||||||||||||||||||
| currency_id: this.currencyId, | ||||||||||||||||||||||||||
| payment_terms: this.paymentTerms, | ||||||||||||||||||||||||||
| payment_terms_label: this.paymentTermsLabel, | ||||||||||||||||||||||||||
| notes: this.notes, | ||||||||||||||||||||||||||
| exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), | ||||||||||||||||||||||||||
| vat_treatment: this.vatTreatment, | ||||||||||||||||||||||||||
| gst_no: this.gstNo, | ||||||||||||||||||||||||||
| avatax_use_code: this.avataxUseCode, | ||||||||||||||||||||||||||
| tax_id: this.taxId, | ||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| $.export("$summary", `Contact successfully created with Id: ${response.contact.contact_id}`); | ||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust
invoicesprop type and parsing for correct data handlingThe
invoicesprop is defined astype: "string[]", but the description expects each item to be an object with invoice details. Usingstring[]may require users to input JSON strings, which can lead to parsing errors. Consider changing the type toobject[]and updating the parsing logic accordingly.Apply this diff to adjust the prop definition:
And update the
runmethod to remove unnecessary parsing: