2016-06-14 71 views
0

我想在我的ItemsKeyMapping.js中创建一个函数,该函数将计算客户将在产品上保存的百分比。我是JavaScript新手,一直在使用教程。这是我有:从Netsuite Suitecommerce Advanced中的价格水平计算折扣

// @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勃朗峰,可以帮助我完成此?谢谢。

+0

你可以发布更多的代码的上下文? – TonyH

+0

嗨,Tony,SCA中有大量的代码。有什么帮助? 该文件告诉后端在物料记录上给出onelnecustomer价格和价格水平15的值。这里是另一个呼叫请求在文本字段中的信息的一个例子: '// @财产_StoreDescription抢在网上商店描述字段的HTML \t \t,\t _StoreDescription:功能(项目) \t \t \t { \t ('storedescription')\t \t \t}' –

回答

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; 
    } 
+0

'这看起来更接近!还没有能够完成它的工作,不知道我是否想要onlinecustomer价格or_priceDetails例如。我会做一些额外的测试。 –