Script to list Vendor Credits in Vendor Payments, enjoy!

Script to list Vendor Credits in Vendor Payments, enjoy!

We realized that Zoho lacks the ability to select Vendor Credits and Bills when making Payments. The credits need to be applied to the bills prior to creating a payment but then the payment has no reference to which credits were used, therefore the Vendor sees bills pays but don't know that a credit was used.

We created a Custom Function that can be added as an automation for Workflows that triggers it every time that a Payment is Created or Edited, posted here for reference in case anyone else can use it, enjoy!

//Must create Custom Field in 'Payments Made' called 'Credit Memos Used'
//Custom Function, module: Vendor Payment
bills = vendor_payment.get("bills").toList();
credit_info = "";
for each  credit in bills
{
    result = zoho.books.getRecordsByID("bills",organization.get("organization_id"),credit.get("bill_id"));
    bill_details = result.get("bill");
    vendor_credits = bill_details.get("vendor_credits").toList();
    if(vendor_credits.isempty() == false)
    {
        for each  data in vendor_credits
        {
            credit_info = credit_info + "Credit Memo: " + data.get("vendor_credit_number") + " : $" + data.get("amount") + ", ";
        }
        credit_info = credit_info.removeLastOccurence(", ");
    }
}
if(credit_info.isblank() != true)
{
    Payment_Items = Map();
    Payment_CustomFields = Map();
    Payment_CustomFieldsList = List();
    Payment_CustomFields.put({"label":"Credit Memos Used","value":credit_info});
    Payment_CustomFieldsList.add(Payment_CustomFields);
    Payment_Items.put("custom_fields",Payment_CustomFieldsList);
    result = zoho.books.updateRecord("vendorpayments",organization.get("organization_id"),vendor_payment.get("payment_id"),Payment_Items);
    info result;
}

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts





                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner









                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方