我正在尝试在Zoho CRM中创建一个自定义函数,该函数将获取发票记录,查看订阅时间段(开始日期和结束日期),并将小计划分为订阅月份。 (4月,5月,6月等)我正在尝试创建一个日期,该日期的常数为04/30,并从开始日期的年份或结束日期的年份开始添加年份,但是我在语法上遇到了麻烦。我认为if语句也可能有问题。抱歉,这完全是菜鸟。如果有人可以提供指导,将不胜感激。
这里是我到目前为止的代码
invoice_record = zoho.crm.getRecordById("Invoices", invoice_id);
start_date = invoice_record.get("Service Start Date");
end_date = invoice_record.get("Service End Date");
invoice_date = invoice_record.get("Invoice Date");
start_date_month = start_date.getMonth();
start_date_year = start_date.getyear ();
end_date_year = end_date.getyear();
// calculate how many months in the service period
service_length = start_date.monthsBetween(end_date);
//April Revenue Recognition
april_date_start_year_datestring = "04/30/" + start_date_year;
april_date_start_year = april_date_start_year_datestring.todate( "MM/dd/yyyy") ;
april_date_end_year_datestring = "04/30/" + end_date_year;
april_date_end_year = april_date_end_year_datestring.todate( "mm/dd/yyyy") ;
if (april_date_start_year >= start_date || april_date_end_year < = april_date_end_year )
{ rev_rec_april = "Sub Total" / service_length }
else
{rev_rec_april = 0}
invoice_record.put("April Revenue", rev_rec_april);
update_resp = zoho.crm.updateRecord("invoices", invoice_id.toString(), invoice_record);