Now we’re finished and you shouldn’t even feel bad about viewing the full code here!
Just remember that you’ll have to modify some things. It’s not quite as simple as copying and pasting. But, this will give you a great start, something to build off of.
iteratorList = {1,2,3,4,5,6,7,8,9,10,11,12};
truncatedList = iteratorList.subList(0,installments.toNumber());
info truncatedList;
lineItemMap = Map();
lineItemMap.put("item_id",itemID);
lineItemMap.put("rate",monthly);
lineItemMap.put("quantity",1);
info "Pay " + installments + "installments for " + monthly;
for each number in truncatedList
{
lineItems = List();
des = "This is invoice " + number + "/" + installments + " to pay for the business plan";
lineItemMap.put("description",des);
lineItems.add(lineItemMap);
invoiceMap.put("line_items",lineItems);
dueDate = zoho.currentdate.addMonth(number - 1);
invoiceMap.put("due_date",dueDate);
response = zoho.books.createRecord("Invoices",orgId,invoiceMap,"zohobooks");
invoicesCreated = invoicesCreated + 1;
}