Hi,
We have an issue which we did not encountered prior to 26 Apr.
Basically we have a custom function, that is used to update the expiry date of the invoice. As our payments terms are based on end-of-months of xx days.
Inclusive as well, in the invoice, we have a custom field DATE, that defines when we actually send the invoice to the client through a separate portal. The format of the custom field DATE (cf_posted_data) is dd/MM/yyyy (that matches our Zoho Books Org date setting).
As we are only updating the expiry date of the invoice, the custom function works successfully when custom field DATE (cf_posted_data) is blank.
But if there is a DATE value (cf_posted_data) e.g. 23/05/2022, the custom function fails with the error:
"code": 6, "message": "Invalid date 23/05/2022 specified."
Would anyone be able to provide some insights?
- invoiceID = invoice.get("invoice_id");
- invoicedate = invoice.get("date").toDate();
- organizationID = organization.get("organization_id");
- invoicepaymenttermslabel = invoice.get("payment_terms_label");
- invoicepaymenttermsdays = invoice.get("payment_terms");
- x_day = 0;
- if(invoicepaymenttermsdays == "121")
- {
- x_day = 120;
- }
- else if(invoicepaymenttermsdays == "91")
- {
- x_day = 90;
- }
- //OBTAIN THE END OF THE MONTH POST x days
- newinvoiceduedate = invoice.get("date").addDay(x_day).eomonth(0);
- DuenumberOfDays = daysBetween(invoicedate,newinvoiceduedate);
- invoice.put("due_in_days",DuenumberOfDays);
- //FORMAT THE NEW DUE DATE
- newupdatedinvoiceduedate = toString(newinvoiceduedate,"yyyy'-'MM'-'dd");
- newinvoiceduedateformatted = toString(newinvoiceduedate,"dd'/'MM'/'yyyy");
- invoice.put("due_date",newupdatedinvoiceduedate);
- invoice.put("due_date_formatted",newinvoiceduedateformatted);
- invoice.put("billing_address","");
- invoice.put("shipping_address","");
- //UPDATE INVOICE
- updatedinvoice = zoho.books.updateRecord("Invoices","2XXXXXXXXXXX",invoiceID,invoice);
- info updatedinvoice;
Thanks