I am currently using the following custom function to execute a 1.5% late fee on invoices that are past due.
- //create a variable to get invoice total and add a 1.5% fee
- latefee = invoice.get("total").toDecimal() * 0.015;
- orgID = organization.get("organization_id").toString();
- invoiceID = invoice.get("invoice_id").toLong();
- //display the value stored in the latefee variable
- info latefee;
- //add late fee and adjustment and store the total amount in the variable 'adjustment'
- adjustment = invoice.get("adjustment").toDecimal() + latefee;
- jsonMap = Map();
- jsonMap.put("adjustment",adjustment);
- jsonMap.put("reason","Late fee");
- // To update the current record
- result = zoho.invoice.update("invoices",orgID,invoiceID,jsonMap);
- info result.toMap().get("message");
Currently it is taking the total invoice amount and adding 1.5% of that total. Is there a way I can have it calculate 1.5% of the unpaid balance?
For example: If an invoice is $10,000 but the customer makes a payment of $2,000, the 1.5% should only be calculated on $8,000.