合同登记付款计划分录联动合同总价区域税率01

This commit is contained in:
zengweihai 2024-06-14 17:34:01 +08:00
parent a4447de1fa
commit 4965528d29
1 changed files with 37 additions and 7 deletions

View File

@ -4,6 +4,8 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.IDataEntityProperty;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.AfterDeleteRowEventArgs;
import kd.bos.entity.datamodel.events.BeforeDeleteRowEventArgs;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
@ -46,17 +48,14 @@ public class ContractbillFromPlugin extends AbstractFormPlugin {
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
IDataModel model = this.getModel();
String name = e.getProperty().getName();
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
switch (name){
case "contractparty" :
DynamicObject newValue = (DynamicObject)changeData.getNewValue();
this.getModel().setValue("costcompany",newValue);
case "orientryamount":
case "orientryamount"://监听税额变化
DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
BigDecimal orientryamounttotal = BigDecimal.ZERO;
BigDecimal taxamounttotal = BigDecimal.ZERO;
@ -67,9 +66,40 @@ public class ContractbillFromPlugin extends AbstractFormPlugin {
orientryamounttotal = orientryamounttotal.add(orientryamount);
taxamounttotal = taxamounttotal.add(taxamount);
}
BigDecimal divide = orientryamounttotal.divide(taxamounttotal, 2, 4); //计算税率
this.getModel().setValue("taxrate",divide);
if (orientryamounttotal.compareTo(BigDecimal.ZERO) != 0){
BigDecimal divide = taxamounttotal.divide(orientryamounttotal, 4, 4); //计算税率
divide = divide.multiply(new BigDecimal(100));
this.getModel().setValue("billtaxrate",divide);
}else {
this.getModel().setValue("billtaxrate",0);
}
}
}
@Override
public void afterDeleteRow(AfterDeleteRowEventArgs e) {
super.afterDeleteRow(e);
String name = e.getEntryProp().getName();
if (name.equals("expenseentryentity")){
DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
BigDecimal orientryamounttotal = BigDecimal.ZERO;
BigDecimal taxamounttotal = BigDecimal.ZERO;
for(int i = 0;i<expenseentryentity.size();i++){
DynamicObject dynamicObject = expenseentryentity.get(i);
BigDecimal orientryamount = dynamicObject.getBigDecimal("orientryamount");
BigDecimal taxamount = dynamicObject.getBigDecimal("taxamount");
orientryamounttotal = orientryamounttotal.add(orientryamount);
taxamounttotal = taxamounttotal.add(taxamount);
}
if (orientryamounttotal.compareTo(BigDecimal.ZERO) != 0){
BigDecimal divide = taxamounttotal.divide(orientryamounttotal, 2, 4); //计算税率
divide = divide.multiply(new BigDecimal(100));
this.getModel().setValue("billtaxrate",divide);
}else {
this.getModel().setValue("billtaxrate",0);
}
}
}
}