|
@@ -1,5 +1,6 @@
|
|
-package fi.em.EditPlugin;
|
|
|
|
|
|
+package fi.em.editPlugin;
|
|
|
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.exception.KDBizException;
|
|
import kd.bos.exception.KDBizException;
|
|
import kd.bos.form.CloseCallBack;
|
|
import kd.bos.form.CloseCallBack;
|
|
import kd.bos.form.FormShowParameter;
|
|
import kd.bos.form.FormShowParameter;
|
|
@@ -28,9 +29,11 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
|
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
|
if (btn_NOTICE.equals(e.getOperateKey())) {
|
|
if (btn_NOTICE.equals(e.getOperateKey())) {
|
|
Object value = this.getModel().getValue("costcompany");//获取当前单据费用公司
|
|
Object value = this.getModel().getValue("costcompany");//获取当前单据费用公司
|
|
- DynamicObject costcompany = (DynamicObject) value;//强转
|
|
|
|
- String orgnumber = costcompany.getString("number");//公司编码
|
|
|
|
- String orgid = costcompany.getString("id");//公司id
|
|
|
|
|
|
+ DynamicObjectCollection expenseentryentityWait = this.getModel().getEntryEntity("expenseentryentity_wait");
|
|
|
|
+ DynamicObject dynamicObject = expenseentryentityWait.get(0);
|
|
|
|
+ DynamicObject entrycostcompanyWait = dynamicObject.getDynamicObject("entrycostcompany_wait");
|
|
|
|
+ String orgnumber = entrycostcompanyWait.getString("number");//公司编码
|
|
|
|
+ String orgid = entrycostcompanyWait.getString("id");//公司id
|
|
if (orgnumber == null){
|
|
if (orgnumber == null){
|
|
throw new KDBizException("付费承担公司为空!");
|
|
throw new KDBizException("付费承担公司为空!");
|
|
}
|
|
}
|
|
@@ -57,6 +60,9 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
|
|
BigDecimal nckdAgentvalue = reJo.getBigDecimal("nckd_agentvalue");
|
|
BigDecimal nckdAgentvalue = reJo.getBigDecimal("nckd_agentvalue");
|
|
sum=sum.add(nckdAgentvalue);
|
|
sum=sum.add(nckdAgentvalue);
|
|
}
|
|
}
|
|
|
|
+ BigDecimal max = new BigDecimal(0);
|
|
|
|
+ BigDecimal zonghe = new BigDecimal(0);
|
|
|
|
+ int count = 0;
|
|
//循环返回数组插入分录
|
|
//循环返回数组插入分录
|
|
for(int i =0;i<reJa.size();i++){
|
|
for(int i =0;i<reJa.size();i++){
|
|
//当前循环行
|
|
//当前循环行
|
|
@@ -69,12 +75,22 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
|
|
DynamicObject nckd_orgamountaccount = BusinessDataServiceHelper.loadSingle(bos_org,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
DynamicObject nckd_orgamountaccount = BusinessDataServiceHelper.loadSingle(bos_org,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
BigDecimal nckdAgentvalue = reJo.getBigDecimal("nckd_agentvalue");
|
|
BigDecimal nckdAgentvalue = reJo.getBigDecimal("nckd_agentvalue");
|
|
//计算当前动因值比例
|
|
//计算当前动因值比例
|
|
- nckdAgentvalue = (nckdAgentvalue.divide(sum)).multiply(new BigDecimal(100));
|
|
|
|
|
|
+ nckdAgentvalue = nckdAgentvalue.divide(sum,4,BigDecimal.ROUND_HALF_UP).setScale(4);
|
|
|
|
+ nckdAgentvalue = nckdAgentvalue.multiply(new BigDecimal(100));
|
|
//新增分录行
|
|
//新增分录行
|
|
int rowIndex = this.getModel().createNewEntryRow("expenseentryentity_rule");
|
|
int rowIndex = this.getModel().createNewEntryRow("expenseentryentity_rule");
|
|
|
|
+ zonghe=zonghe.add(nckdAgentvalue);
|
|
|
|
+ if(nckdAgentvalue.compareTo(max) == 1){
|
|
|
|
+ max=nckdAgentvalue;
|
|
|
|
+ count=count=rowIndex;
|
|
|
|
+ }
|
|
//set分录字段
|
|
//set分录字段
|
|
this.getModel().setValue("entrycostcompany_orgrule", nckd_orgamountaccount, rowIndex);
|
|
this.getModel().setValue("entrycostcompany_orgrule", nckd_orgamountaccount, rowIndex);
|
|
this.getModel().setValue("sharerate_comrule", nckdAgentvalue, rowIndex);
|
|
this.getModel().setValue("sharerate_comrule", nckdAgentvalue, rowIndex);
|
|
|
|
+ if(i+1==reJa.size()){
|
|
|
|
+ zonghe=zonghe.subtract(new BigDecimal(100));
|
|
|
|
+ this.getModel().setValue("sharerate_comrule", max.subtract(zonghe), count);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//刷新分录
|
|
//刷新分录
|
|
this.getView().updateView("expenseentryentity_rule");
|
|
this.getView().updateView("expenseentryentity_rule");
|