从Netsuite Suitecommerce Advanced中的价格水平计算折扣

时间:2016-06-14 21:07:22

标签: javascript netsuite sca

我正在尝试在ItemsKeyMapping.js中创建一个函数,该函数将计算客户在产品上保存的百分比。我是javascript的新手,并且一直在使用教程。这就是我所拥有的:

// @property _DiscountPercent calculates the percentage between customers price and MSRP
    ,   _DiscountPercent: function (item)
        {
            var attributes = item.get('onlinecustomerprice') || ('pricelevel15');

            if ((pricelevel15 != 0) && (onlinecustomerprice != 0)) 

            {
                DiscountPercent = (1 - pricelevel15 / onlinecustomerprice) * 100;
            }
            else 
            {
             DiscountPercent = null;
             }
            return 'DiscountPercent';
        }

那些熟悉SCA勃朗峰的人可以帮助我完成这项任务吗?谢谢。

1 个答案:

答案 0 :(得分:1)

试试这个:

,   _DiscountPercent: function (item)
    {
        var normalPrice= item.get('onlinecustomerprice') 
        var discountedPrice= item.get('pricelevel15');
        var DiscountPercent = null;

        if ((discountedPrice > 0) && (normalPrice > 0)) 

        {
            DiscountPercent = (1 - discountedPrice / normalPrice) * 100;
        }

        return DiscountPercent;
    }