Language: JavaScript
Label: safe
CWE: CWE-829 \u2014 Inclusion of Functionality from Untrusted Control Sphere
The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.

Code:
    isGivenDiscountPermitted: function(selector) {

        var totalAmount = $(".totalAmount").text();
        var orderDiscount = $(selector).val();

        if( get_options("maxDiscount") != "" ) { // If the current biller set a max discount

            var maxDiscountAmount = totalAmount - BMS.FUNCTIONS.calculateDiscount(totalAmount, get_options("maxDiscount"));
            var givenDiscountAmount = totalAmount - BMS.FUNCTIONS.calculateDiscount(totalAmount, orderDiscount);

            // In case of return/ negative value
            // -2 is greater then -4
            // So we are converting all negative value to abs
            return Math.abs(maxDiscountAmount) >= Math.abs(givenDiscountAmount);

        } else {
            return true;
        }

    }