NetSuite项目收据计算总金额

问题描述 投票:0回答:1

在NetSuite中,我需要计算项目收货中的总金额(即,项目数量x项目费率)。这在标准功能中不可用,因此需要脚本。

下面是客户端脚本-如果我们手动在订单项上打勾,该脚本就可以正常工作。但是,一旦我们在商品收据中使用“全部标记”或“取消全部标记”按钮,它就会失真,因为不幸的是,这些按钮不会触发客户端脚本。我正在考虑使用重新计算按钮在用户保存交易之前更正金额。有任何想法吗?

我也尝试过工作流操作脚本,但是在第一次创建/编辑事务时,重新计算按钮显示为灰色。非常感谢。

function fieldChng() {
  var qty = nlapiGetCurrentLineItemValue('item', 'quantity');
  var rate = nlapiGetCurrentLineItemValue('item', 'rate');
  var total = qty * rate;
  nlapiSetCurrentLineItemValue('item', 'custcol_ir_line_item_amount', total.toFixed(2), false);
  //'custcol_ir_line_item_amount' is the internal id of Custom Transaction Line Field

}
function updateTotalAmount(type, name) {
  // initialize variable for total amount
  var totalAmount = 0;

  // count number of lines in 'item' sublist
  var itemCount = nlapiGetLineItemCount('item');

  // for each line in the 'item' sublist, add value in amount column to
  // the total amount variable
  for (var i = 1; i <= itemCount; i++) {
    lineLevelAmount = nlapiGetLineItemValue('item', 'custcol_ir_line_item_amount', i)
    if (lineLevelAmount != '' && lineLevelAmount != null) {
      totalAmount += parseFloat(lineLevelAmount);
    }
  }

  // assuming custbody_ir_total_amount is the custom body field for the total
  // amount, change its value based the value from the computation above
  nlapiSetFieldValue('custbody_ir_total_amount', totalAmount.toFixed(2), false);
}

netsuite suitescript
1个回答
0
投票

正如Mike所说,最好在“保存”上执行此操作,但始终可以选择劫持“全部标记”按钮并触发脚本。尽管NetSuite批准的次数较少,但效果也一样。

© www.soinside.com 2019 - 2024. All rights reserved.