export const getValueToPay = (product, sales_consultant_fixed_discount, benchmarkingRange) => {

    var fixedDiscount = (typeof(benchmarkingRange) == 'undefined')? 
    sales_consultant_fixed_discount : parseFloat(benchmarkingRange.discount);
    var discountValue = 0;
    if (product.product_per_campaign.discount_type === "PERCENT") {

        discountValue =
            (product.sub_total * product.product_per_campaign.discount_value) / 100;

    } else if (product.product_per_campaign.discount_type === "CURRENCY_VALUE") {
        discountValue = product.quantity * product.product_per_campaign.discount_value;
    }else if (product.product_per_campaign.discount_type === "FIXED") {

        discountValue =
        (product.sub_total * fixedDiscount) / 100;

    }

return product.sub_total - discountValue;

}

export const getToPayUnity = (product, settings) => {
    if (product.discount_type === "PERCENT") {
        let valueWithDiscount =
            (product.catalog_value * product.discount_value) / 100;

        return product.catalog_value - valueWithDiscount;
    } else if (product.discount_type === "CURRENCY_VALUE") {
        return product.catalog_value - product.discount_value;
    } else if (product.discount_type === "FIXED") {
        let discountValue = 0;

        if (settings.discount_class === "P") {
            discountValue = settings.sales_consultant_fixed_discount.class_P;
        } else if (settings.discount_class === "S") {
            discountValue = settings.sales_consultant_fixed_discount.class_S;
        }

        let valueWithDiscount = (product.catalog_value * discountValue) / 100;

        return valueWithDiscount;
    }

    //NO_DISCOUNT
    return product.catalog_value;
}

export const getValueDiscount = (typeDiscount, discountValue, valueProduct) => {

    if (typeDiscount === "PERCENT") {

        return (valueProduct * discountValue) / 100;

    }else{

        return discountValue;

    }

}