代码语言:javascript
复制
var CU = pluginCtx.getUIContext().get(“sysContext”).getCurrentFIUnit();
//判断分录净重合计是否与表头净重一致
var total = new java.math.BigDecimal(0);
total = pluginCtx.getKDFormattedTextField(“txttotalNetQty”).getValue();
if(total!=null && total.compareTo(new java.math.BigDecimal(0))>0){
var nettotal = new java.math.BigDecimal(0);
var rowsize = pluginCtx.getKDTable(“detailTable”).getRowCount();
for(var i=0;i<rowsize;i++){
var netQty = pluginCtx.getKDTable(“detailTable”).getRow(i).getCell(“netQty”).getValue();
netQty = netQty==null?new java.math.BigDecimal(0):netQty;
nettotal = nettotal.add(netQty);
}
if(total.compareTo(nettotal)!=0){
com.kingdee.eas.util.client.MsgBox.showInfo(“分录明细净重之和与表头净重不一致,请重新调整!”);
com.kingdee.eas.util.SysUtil.abort();
}
}
//判断是否过磅
var srcbilltype = pluginCtx.getKDBizPromptBox(“kDBizPromptBoxSorBillType”).getValue();
if(srcbilltype!=null && srcbilltype.getName().equals(“采购收货单”)){
var isInit = pluginCtx.getKDCheckBox(“cboxIsInitBill”).isSelected();
var rowc=pluginCtx.getKDTable(“detailTable”).getRowCount();
if(CU!=null && !isInit){
for(var i=0;i<rowc;i++){
var material = pluginCtx.getKDTable(“detailTable”).getRow(i).getCell(“materialNum”).getValue();
if(material!=null){
var ev = new com.kingdee.bos.metadata.entity.EntityViewInfo();
var filter = new com.kingdee.bos.metadata.entity.FilterInfo();
filter.getFilterItems().add(new com.kingdee.bos.metadata.entity.FilterItemInfo(“material”, material.getId(), com.kingdee.bos.metadata.query.util.CompareType.EQUALS));
filter.getFilterItems().add(new com.kingdee.bos.metadata.entity.FilterItemInfo(“orgUnit”, CU.getId(), com.kingdee.bos.metadata.query.util.CompareType.EQUALS));
ev.setFilter(filter);
var materialPurColl = com.kingdee.eas.basedata.master.material.MaterialPurchasingFactory.getRemoteInstance().getMaterialPurchasingCollection(ev);
if(materialPurColl.size()>0){
var materialPurInfo = materialPurColl.get(0);
var isWeigh = materialPurInfo.get(“producingArea”);
var weighBill = pluginCtx.getKDBizPromptBox(“prmtweighBill”).getValue();
if(isWeigh!=null && isWeigh.equals(“Y”)){
if(weighBill==null){
com.kingdee.eas.util.client.MsgBox.showInfo(“必须先过磅才能入库,请选择磅单!”);
com.kingdee.eas.util.SysUtil.abort();
}
}
}
}
}
}
}
//计算运费
var weighDiff = pluginCtx.getKDFormattedTextField(“txtweighDiff”).getValue();
weighDiff = weighDiffnull?new java.math.BigDecimal(0):weighDiff;
var rowsize = pluginCtx.getKDTable(“detailTable”).getRowCount();
for(var i=0;i<rowsize;i++){
var shipQty = pluginCtx.getKDTable(“detailTable”).getRow(i).getCell(“shipQty”).getValue();
shipQty = shipQtynull?new java.math.BigDecimal(0):shipQty;
var netQty = pluginCtx.getKDTable(“detailTable”).getRow(i).getCell(“netQty”).getValue();
netQty = netQtynull?new java.math.BigDecimal(0):netQty;
var transPrice = pluginCtx.getKDTable(“detailTable”).getRow(i).getCell(“transPrice”).getValue();
transPrice = transPricenull?new java.math.BigDecimal(0):transPrice;
代码语言:javascript
复制
var transAmt = new java.math.BigDecimal(0);
if(transPrice==null || transPrice==0){
transAmt=0;
}
else if(shipQty.subtract(netQty).compareTo(weighDiff)>0){
transAmt = shipQty.multiply(transPrice);
}else{
var actualTaxPrice = pluginCtx.getKDTable("detailTable").getRow(i).getCell("actualTaxPrice").getValue();
transAmt = netQty.multiply(transPrice).subtract(shipQty.subtract(netQty).subtract(weighDiff).multiply(actualTaxPrice));
}
pluginCtx.getKDTable("detailTable").getRow(i).getCell("transAmt").setValue(transAmt);
}