2016-06-14 74 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例如。我會做一些額外的測試。 –