Pārlūkot izejas kodu

业务处理单过滤

xuhao 5 mēneši atpakaļ
vecāks
revīzija
54323cd5ad

+ 99 - 6
src/main/java/fi/em/formPlugin/CostAllocationEditPlugin.java

@@ -7,7 +7,9 @@ import kd.bos.exception.KDBizException;
 import kd.bos.form.CloseCallBack;
 import kd.bos.form.FormShowParameter;
 import kd.bos.form.ShowType;
+import kd.bos.form.control.EntryGrid;
 import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.form.events.BeforeDoOperationEventArgs;
 import kd.bos.form.events.ClosedCallBackEvent;
 import kd.bos.list.plugin.AbstractListPlugin;
 import kd.bos.orm.query.QCP;
@@ -60,9 +62,98 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
             if (orgnumber == null){
                 throw new KDBizException("付费承担公司为空!");
             }
-            showParameter(nckd_agentparameterf7, btn_NOTICE,orgnumber,orgid);//调用弹出页面
+            showParameter(nckd_agentparameterf7, btn_NOTICE,orgnumber,orgid);//
+        }else if ("deleteentryyufu".equals(e.getOperateKey())) {
+            DynamicObjectCollection nckdClearloanentry = this.getModel().getEntryEntity("nckd_clearloanentry");
+            if(nckdClearloanentry.isEmpty()){
+                String nckdAmountfield4 = this.getModel().getValue("approveamount").toString();
+                BigDecimal bigDecimal = new BigDecimal(nckdAmountfield4);//总报销金额
+                BigDecimal bigDecimal1 = new BigDecimal(0);
+                DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
+                DynamicObject dynamicObject = accountentry.get(0);
+                if(dynamicObject!=null){
+                    String orireceiveamount = this.getModel().getValue("nckd_orireceiveamount", 0).toString();
+                    BigDecimal bigDecimal2 = new BigDecimal(orireceiveamount);//收款第一行
+                    if(accountentry.size()==1){
+                        bigDecimal=bigDecimal.subtract(bigDecimal1);
+                        this.getModel().setValue("nckd_orireceiveamount",bigDecimal,0);
+                    }else{
+                        BigDecimal bigDecimal3 = new BigDecimal(0);
+                        for(int i=0;i<accountentry.size();i++){
+                            DynamicObject dynamicObjects = accountentry.get(i);
+                            BigDecimal nckdUnexporiusedamount = dynamicObjects.getBigDecimal("nckd_orireceiveamount");
+                            if(i>0){
+                                bigDecimal3=bigDecimal3.add(nckdUnexporiusedamount);
+                            }
+                        }
+                        BigDecimal con1=bigDecimal.subtract(bigDecimal3);//收款信息第一行的金额
+                        if(con1.compareTo(BigDecimal.ZERO) > 0){
+                            this.getModel().setValue("nckd_orireceiveamount",con1,0);
+                        }else {
+                            this.getModel().setValue("nckd_orireceiveamount",new BigDecimal(0),0);
+                        }
+                    }
+                }
+            }else {
+                String nckdAmountfield4 = this.getModel().getValue("approveamount").toString();
+                BigDecimal bigDecimal = new BigDecimal(nckdAmountfield4);
+                BigDecimal bigDecimal1 = new BigDecimal(0);
+                DynamicObjectCollection nckdClearloanentrys = this.getModel().getEntryEntity("nckd_clearloanentry");
+                for(int i=0;i<nckdClearloanentrys.size();i++){
+                    DynamicObject dynamicObject = nckdClearloanentrys.get(i);
+                    BigDecimal nckdUnexporiusedamount = dynamicObject.getBigDecimal("nckd_unexporiusedamount");
+                    bigDecimal1=bigDecimal1.add(nckdUnexporiusedamount);
+                }
+                if(bigDecimal1.compareTo(bigDecimal) == 1){
+                    DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
+                    DynamicObject dynamicObject = accountentry.get(0);
+                    if(dynamicObject!=null){
+                        this.getModel().setValue("nckd_orireceiveamount",new BigDecimal(0),0);
+
+                    }
+                } else if (bigDecimal1.compareTo(bigDecimal) == 0) {
+                    DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
+                    DynamicObject dynamicObject = accountentry.get(0);
+                    if(dynamicObject!=null){
+                        this.getModel().setValue("nckd_orireceiveamount",new BigDecimal(0),0);
+                    }
+                }else {
+                    DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
+                    DynamicObject dynamicObject = accountentry.get(0);
+                    if(dynamicObject!=null){
+                        String orireceiveamount = this.getModel().getValue("nckd_orireceiveamount", 0).toString();
+                        BigDecimal bigDecimal2 = new BigDecimal(orireceiveamount);
+                        if(accountentry.size()==1){
+                            bigDecimal=bigDecimal.subtract(bigDecimal1);
+                            this.getModel().setValue("nckd_orireceiveamount",bigDecimal,0);
+                        }else{
+                            BigDecimal bigDecimal3 = new BigDecimal(0);
+                            for(int i=0;i<accountentry.size();i++){
+                                DynamicObject dynamicObjects = accountentry.get(i);
+                                BigDecimal nckdUnexporiusedamount = dynamicObjects.getBigDecimal("nckd_orireceiveamount");
+                                if(i>0){
+                                    bigDecimal3=bigDecimal3.add(nckdUnexporiusedamount);
+                                }
+                            }
+
+                            BigDecimal con1=bigDecimal.subtract(bigDecimal3);//收款信息第一行的金额
+                            con1=con1.subtract(bigDecimal1);
+                            if(con1.compareTo(BigDecimal.ZERO) > 0){
+                                this.getModel().setValue("nckd_orireceiveamount",con1,0);
+                            }else {
+                                this.getModel().setValue("nckd_orireceiveamount",new BigDecimal(0),0);
+                            }
+                        }
+
+
+                    }
+                }
+            }
         }
-    }
+        }
+
+
+
     @Override
     public void closedCallBack(ClosedCallBackEvent e) {
         super.closedCallBack(e);
@@ -180,7 +271,6 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
                    if(dynamicObject!=null){
                        String orireceiveamount = this.getModel().getValue("orireceiveamount", 0).toString();
                        BigDecimal bigDecimal2 = new BigDecimal(orireceiveamount);
-                       if(bigDecimal2.compareTo(bigDecimal1) == 1){
                            if(accountentry.size()==1){
                                bigDecimal=bigDecimal.subtract(bigDecimal1);
                                this.getModel().setValue("orireceiveamount",bigDecimal,0);
@@ -193,14 +283,17 @@ public class CostAllocationEditPlugin extends AbstractListPlugin implements Plug
                                        bigDecimal3=bigDecimal3.add(nckdUnexporiusedamount);
                                    }
                                }
+
                                BigDecimal con1=bigDecimal.subtract(bigDecimal3);//收款信息第一行的金额
                                con1=con1.subtract(bigDecimal1);
+                               if(con1.compareTo(BigDecimal.ZERO) > 0){
                                this.getModel().setValue("orireceiveamount",con1,0);
+                               }else {
+                                   this.getModel().setValue("orireceiveamount",new BigDecimal(0),0);
+                               }
                            }
 
-                       }else {
-                           this.getModel().setValue("orireceiveamount",new BigDecimal(0),0);
-                       }
+
                    }
                 }
             }