系统校验计量清单变动的单价
This commit is contained in:
parent
f66388a623
commit
6550181717
|
@ -8,11 +8,15 @@ import kd.bos.entity.datamodel.events.ChangeData;
|
|||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.CloseCallBack;
|
||||
import kd.bos.form.ShowFormHelper;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.field.TextEdit;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.contract.common.enums.PriceAdjustModeEnum;
|
||||
import kd.ec.contract.formplugin.InContractMeasureBillEditPlugin;
|
||||
import org.xhtmlrenderer.simple.xhtml.controls.TextControl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
|
@ -174,32 +178,62 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|||
super.propertyChanged(e);
|
||||
String propName = e.getProperty().getName();
|
||||
ChangeData changeData = e.getChangeSet()[0];
|
||||
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
int parentRowIndex = changeData.getParentRowIndex();
|
||||
if (StringUtils.equals(propName, "zcgj_hsjell")) {
|
||||
doLockFieldWithPriceAdjustMode((PriceAdjustModeEnum)null);
|
||||
} else if (StringUtils.equals(propName, "thisqty") || StringUtils.equals(propName, "thisoftaxmount")) {
|
||||
BigDecimal thisqty = (BigDecimal)this.getModel().getValue("thisqty", rowIndex, parentRowIndex);
|
||||
BigDecimal thisoftaxmount =(BigDecimal) this.getModel().getValue("thisoftaxmount", rowIndex, parentRowIndex);
|
||||
BigDecimal totalqty =(BigDecimal) this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
||||
BigDecimal entrytaxrate =(BigDecimal) this.getModel().getValue("entrytaxrate", rowIndex, parentRowIndex);
|
||||
} else if ( StringUtils.equals(propName, "thisoftaxmount")) {//StringUtils.equals(propName, "thisqty") ||
|
||||
|
||||
BigDecimal oldValue = (BigDecimal)changeData.getOldValue();
|
||||
if(oldValue.compareTo(new BigDecimal(0)) == 0){return;}
|
||||
BigDecimal thisqty = (BigDecimal)this.getModel().getValue("thisqty", rowIndex, parentRowIndex);//本期计量数量
|
||||
BigDecimal thisoftaxmount =(BigDecimal) this.getModel().getValue("thisoftaxmount", rowIndex, parentRowIndex);//本期计量含税金额
|
||||
BigDecimal totalqty =(BigDecimal) this.getModel().getValue("totalqty", rowIndex, parentRowIndex);//数量
|
||||
BigDecimal entrytaxrate =(BigDecimal) this.getModel().getValue("entrytaxrate", rowIndex, parentRowIndex);//税率(%)
|
||||
BigDecimal tax = entrytaxrate.divide(new BigDecimal(100)).add(new BigDecimal(1));
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
|
||||
BigDecimal oldPrice = (BigDecimal) this.getModel().getValue("currentprice", rowIndex, parentRowIndex);
|
||||
BigDecimal currentprice = null;
|
||||
|
||||
if (thisqty.compareTo(zero)>0 && thisoftaxmount.compareTo(zero)>0) {
|
||||
BigDecimal curtaxprice = thisoftaxmount.divide(thisqty,6,BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal currentprice = curtaxprice.divide(tax, 6, BigDecimal.ROUND_HALF_UP);
|
||||
currentprice = curtaxprice.divide(tax, 6, BigDecimal.ROUND_HALF_UP);
|
||||
DynamicObjectCollection listmodelentry = this.getModel().getDataEntity().getDynamicObjectCollection("listmodelentry");
|
||||
DynamicObject listentry = listmodelentry.get(parentRowIndex).getDynamicObjectCollection("listentry").get(rowIndex);
|
||||
listentry.set("curtaxprice",curtaxprice);
|
||||
listentry.set("currentprice",currentprice);
|
||||
listentry.set("currentamt",currentprice.multiply(totalqty));
|
||||
listentry.set("currenttaxamt",curtaxprice.multiply(totalqty).subtract(currentprice.multiply(totalqty)));
|
||||
listentry.set("currentoftax",curtaxprice.multiply(totalqty));
|
||||
// BigDecimal oldPrice = listentry.getBigDecimal("currentprice");//获取变动前的单价
|
||||
listentry.set("curtaxprice",curtaxprice);//当前含税单价 = 本期计量含税金额 /本 期计量数量
|
||||
listentry.set("currentprice",currentprice);//当前单价 = 当前含税单价 / (税率+1)
|
||||
listentry.set("currentamt",currentprice.multiply(totalqty));//当前金额 = 当前单价 * 数量
|
||||
listentry.set("currenttaxamt",curtaxprice.multiply(totalqty).subtract(currentprice.multiply(totalqty)));//当前税额
|
||||
listentry.set("currentoftax",curtaxprice.multiply(totalqty));//当前价税合计
|
||||
this.getView().updateView();
|
||||
}
|
||||
// String resname = (String)this.getModel().getValue("resname", rowIndex, parentRowIndex);
|
||||
PriceChangedWarn(oldPrice,currentprice,rowIndex, parentRowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void PriceChangedWarn(BigDecimal oldPrice, BigDecimal newPrice , int rowIndex, int parentRowIndex) {
|
||||
String resname = (String)this.getModel().getValue("resname", rowIndex, parentRowIndex);
|
||||
// String desc = (String)this.getModel().getValue("desc", rowIndex, parentRowIndex);
|
||||
if((newPrice.compareTo(oldPrice.multiply(new BigDecimal(2)))>=0)||
|
||||
(newPrice.compareTo(oldPrice.multiply(new BigDecimal(0.5)))<=0)){
|
||||
this.getView().showTipNotification(
|
||||
"请注意,清单项:"+resname+"的单价变动较大,\n" +
|
||||
" 请检查是否存在错误",5000);
|
||||
//设置说明字段的必录属性
|
||||
TextEdit descEdit = this.getView().getControl("desc");
|
||||
if(descEdit != null){
|
||||
descEdit.setMustInput(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void updateAmount(ChangeData changeData) {
|
||||
// int rowIndex = changeData.getRowIndex();
|
||||
// int parentRowIndex = changeData.getParentRowIndex();
|
||||
|
|
Loading…
Reference in New Issue