diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java index d5feee5..8b75932 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java @@ -1,6 +1,15 @@ package zcgj.zcdev.zcdev.pr.plugin.form; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.ec.basedata.common.enums.PayDirectionEnum; import kd.ec.contract.formplugin.settle.ContractSettleCommonEditPlugin; +import kd.ec.contract.utils.SettleUpdateAmtUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; /** * 单据界面插件 @@ -12,4 +21,111 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{ protected void setDateEditMinAndMaxDate() { // super.setDateEditMinAndMaxDate(); } + + public void propertyChanged(PropertyChangedArgs e) { + String name = e.getProperty().getName(); + ChangeData changeData = e.getChangeSet()[0]; + if (StringUtils.equals(name, "contract")) { + DynamicObject contract = (DynamicObject)changeData.getNewValue(); + this.clearUnitproject(); + this.contractChanged(contract); + } else if (StringUtils.equals(name, "period")) { + this.periodChanged(changeData); + } else if (!StringUtils.equals(name, "begindate") && !StringUtils.equals(name, "enddate")) { + if (StringUtils.equals(name, "issettlebymatin")) { + this.isSettleByMaterialInChanged(changeData); + } else if (StringUtils.equals(name, "issettlebyreconc")) { + this.isSettleByReconciliationChanged(changeData); + } else if (StringUtils.equals(name, "oftaxamount")) { + this.ofTaxAmountChanged(changeData); + } else if (StringUtils.equals(name, "amount")) { + boolean checkbox= this.getModel().getDataEntity().getBoolean("zcgj_adjustmounttax");//获取微调金额 + if(checkbox){//微调打开,调用子类值改变方法 + this.amountChanged(changeData); + }else{//没打开,调用父类的 + super.amountChanged(changeData); + } + } else if (StringUtils.equals(name, "taxamt")) { + boolean checkbox= this.getModel().getDataEntity().getBoolean("zcgj_adjustmounttax");//获取微调金额 + if(checkbox){//微调打开,调用子类值改变方法 + this.taxamtChanged(changeData); + } + } else if (StringUtils.equals(name, "rate")) { + this.rateChanged(changeData); + } else if (StringUtils.equals("unitproject", name)) { + DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); + this.contractChanged(contract); + } + } else { + this.setDateEditMinAndMaxDate(); + } + + } + + private void taxamtChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + BigDecimal taxamt = (BigDecimal)changeData.getNewValue(); + BigDecimal oftaxamount = (BigDecimal) this.getModel().getValue("oftaxamount",rowIndex); + BigDecimal amount = oftaxamount.subtract(taxamt); + this.getModel().setValue("amount",amount,rowIndex); + } + + protected void rateChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + boolean isMultiRate = (Boolean)this.getModel().getValue("ismultirate"); + BigDecimal ofTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal amount = (BigDecimal)this.getModel().getValue("amount", rowIndex); + BigDecimal taxRate = (BigDecimal)changeData.getNewValue(); + String ignoreRateChanged = this.getPageCache().get("ignoreRateChanged"); + if (ignoreRateChanged != null) { + this.getPageCache().remove("ignoreRateChanged"); + } else { + if (isMultiRate) { + BigDecimal rate = BigDecimal.ONE.add(taxRate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)); + if (ofTaxAmount.compareTo(BigDecimal.ZERO) != 0) { + amount = ofTaxAmount.divide(rate, 6, 4); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("amount", amount, rowIndex); + } else { + ofTaxAmount = amount.multiply(rate); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("oftaxamount", ofTaxAmount, rowIndex); + } + } + + } + } + protected void ofTaxAmountChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + if (this.isNotNonDirection(rowIndex)) { + BigDecimal ofTaxAmount = (BigDecimal)this.getModel().getValue("oftaxamount", rowIndex); + BigDecimal rate = (BigDecimal)this.getModel().getValue("rate", rowIndex); + BigDecimal amount = ofTaxAmount.divide(BigDecimal.ONE.add(rate.divide(BigDecimal.valueOf(100L), 10, RoundingMode.HALF_UP)), 10, 4); + BigDecimal taxAmount = ofTaxAmount.subtract(amount); + this.getModel().setValue("taxamt", taxAmount, rowIndex); + this.getModel().setValue("amount", amount, rowIndex); + this.checkNeedReComputeItem(rowIndex); + SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView()); + SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); + } + + } + protected void amountChanged(ChangeData changeData) { + int rowIndex = changeData.getRowIndex(); + BigDecimal amount = (BigDecimal)changeData.getNewValue(); + BigDecimal oftaxamount = (BigDecimal) this.getModel().getValue("oftaxamount",rowIndex); + BigDecimal taxamt = oftaxamount.subtract(amount); + this.getModel().setValue("taxamt",taxamt,rowIndex); + + } + + private void clearUnitproject() { + if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) { + this.getModel().setValue("unitproject", (Object)null); + } + + } + } \ No newline at end of file