Empowering Business Operations with Empress Cancel Rights

Introduction

Welcome to our guide on how to manage Cancel Rights in Empress, designed specifically for our business users. This powerful feature allows you to enforce custom rules and regulations before a transaction cancellation is approved, effectively ensuring the integrity of your financial operations.

Introduction to Cancel Rights

In Empress, Cancel Rights is a feature that provides you the ability to implement custom conditions before a transaction can be cancelled. This is particularly useful if you want to prevent certain user roles from cancelling transactions beyond a specified limit. By using this feature, you can maintain a tighter control over your business operations and reduce the risk of financial errors or mismanagement.

Using the Cancel Rights feature

Here’s how you can use Cancel Rights:

  1. Write a function and attach it to the custom_before_cancel event. This function will be used to execute your custom rules and conditions before a transaction is cancelled.

For example, let’s say you want to prevent users with the role ‘Accounts User’ from cancelling transactions with a grand total greater than 10,000. Here’s how you can do it:

cur_frm.cscript.custom_before_cancel = function(doc) {
    if (frappe.user_roles.indexOf("Accounts User")!=-1 && frappe.user_roles.indexOf("Accounts Manager")==-1
            && user_roles.indexOf("System Manager")==-1) {
        if (flt(doc.grand_total) > 10000) {
            frappe.msgprint("You can not cancel this transaction, because grand total \
                is greater than 10000");
            frappe.validated = false;
        }
    }
}

This code checks if the user has the role “Accounts User” but does not have the “Accounts Manager” or “System Manager” roles. If the user meets these conditions and the grand total of the transaction is greater than 10,000, then the transaction cancellation is not validated and a message is displayed to the user.

  1. Modify the conditions and logic in the function to suit your specific needs. For instance, you may want to change the roles that are checked or adjust the grand total limit.

Conclusion

The Cancel Rights feature in Empress allows you to implement business rules and checks before a transaction cancellation occurs. This functionality provides you with greater control and integrity in your financial operations. For more information or additional support, please refer to our comprehensive set of non-technical resources or reach out to our support team.