import _ from "./FormulaConstants";
import currency from 'currency.js/dist/currency.js'
/**
 * 数值比较公式
 * 比较左右两个操作数是否相等 参数可以是返回值类型为number的公式
 * @author fengjiansheng
 * @date 2022-02-07
 */
export default {
    formulaName: "AmountComp",
    execute: function () {
        if (arguments && arguments[0] && arguments[0].length === 2) {
            let leftOperand = arguments[0][0];
            let rightOperand = arguments[0][1];
            if (leftOperand && rightOperand) {
                leftOperand = currency(_.getFormulaParamValue(leftOperand)).value
                rightOperand = currency(_.getFormulaParamValue(rightOperand)).value
                if (_.isNumber(leftOperand) && _.isNumber(rightOperand)) {
                    return _.isAmountEqual(leftOperand, rightOperand);
                } else {
                    console.error(this.formulaName + _.ERROR_MSG.PARAM_TYPE);
                    return false;
                }
            } else {
                return false;
            }
        } else {
            console.error(this.formulaName + _.ERROR_MSG.PARAM_NUM);
            return false;
        }
    },
    getResultType: function () {
        return _.resultType.boolean;
    }
}