Late fee custom function

Late fee custom function

I am currently using the following custom function to execute a 1.5% late fee on invoices that are past due.

  1. //create a variable to get invoice total and add a 1.5% fee
  2. latefee = invoice.get("total").toDecimal() * 0.015;
  3. orgID = organization.get("organization_id").toString();
  4. invoiceID = invoice.get("invoice_id").toLong();
  5. //display the value stored in the latefee variable
  6. info latefee;
  7. //add late fee and adjustment and store the total amount in the variable 'adjustment'  
  8. adjustment = invoice.get("adjustment").toDecimal() + latefee;
  9. jsonMap = Map();
  10. jsonMap.put("adjustment",adjustment);
  11. jsonMap.put("reason","Late fee");
  12. // To update the current record
  13. result = zoho.invoice.update("invoices",orgID,invoiceID,jsonMap);
  14. 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.
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner

                        • Word of the Day

                          Word of the Day


                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner

                        • Word of the Day

                          Word of the Day



                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方