Browse Source

报销单分摊信息修改

wanwei 5 months ago
parent
commit
c8cf1ae5ad

+ 24 - 0
src/main/java/fi/er/formPlugin/PublicreimburFormPlugin.java

@@ -1,10 +1,14 @@
 package fi.er.formPlugin;
 
+import com.alibaba.druid.util.StringUtils;
 import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.list.plugin.AbstractListPlugin;
 import kd.sdk.plugin.Plugin;
 
+import java.math.BigDecimal;
+
 public class PublicreimburFormPlugin extends AbstractListPlugin implements Plugin {
     private final static String KEY_Card = "newassetentry";//资产信息分录增行
     @Override
@@ -16,6 +20,26 @@ public class PublicreimburFormPlugin extends AbstractListPlugin implements Plugi
             //赋值给资产信息的核算组织
             this.getModel().setValue("nckd_orgfield1", assetorg);
             this.getView().updateView("assetentry");
+        } else if ("newshareruleentry".equals(e.getOperateKey())) {
+            String sharemethod = (String) this.getModel().getValue("sharemethod");
+            if (StringUtils.equals(sharemethod, "avg")) {
+                DynamicObjectCollection expenseentryentity_rules = this.getModel().getEntryEntity("expenseentryentity_rule");
+                BigDecimal reimburseamount = (BigDecimal) this.getModel().getValue("reimburseamount");
+                BigDecimal nckd_ft_amount = reimburseamount.divide(BigDecimal.valueOf(expenseentryentity_rules.size()));
+                for (int i = 0; i < expenseentryentity_rules.size(); i++) {
+                    this.getModel().setValue("nckd_ft_amount", nckd_ft_amount, i);
+                }
+            }
+        } else if ("deleteshareruleentry".equals(e.getOperateKey())) {
+            String sharemethod = (String) this.getModel().getValue("sharemethod");
+            DynamicObjectCollection expenseentryentity_rules = this.getModel().getEntryEntity("expenseentryentity_rule");
+            if (StringUtils.equals(sharemethod, "avg") && expenseentryentity_rules.size() > 0) {
+                BigDecimal reimburseamount = (BigDecimal) this.getModel().getValue("reimburseamount");
+                BigDecimal nckd_ft_amount = reimburseamount.divide(BigDecimal.valueOf(expenseentryentity_rules.size()));
+                for (int i = 0; i < expenseentryentity_rules.size(); i++) {
+                    this.getModel().setValue("nckd_ft_amount", nckd_ft_amount, i);
+                }
+            }
         }
     }
 

+ 24 - 0
src/main/java/fi/er/opplugin/FinapbillBeforeF7SelectSample.java

@@ -337,6 +337,30 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 BasedataProp basedataProp = (BasedataProp) basedataEdit.getProperty();
                 basedataProp.setMustInput(false);
             }
+        }else if (StringUtils.equals("sharerate_comrule", fieldKey)) {
+            ChangeData changeData = e.getChangeSet()[0];
+            BigDecimal sharerate_comrule = (BigDecimal) changeData.getNewValue();
+            sharerate_comrule = sharerate_comrule.divide(BigDecimal.valueOf(100));
+            BigDecimal reimburseamount = (BigDecimal) this.getModel().getValue("reimburseamount");
+            BigDecimal ftAmount = reimburseamount.multiply(sharerate_comrule);
+            this.getModel().setValue("nckd_ft_amount", ftAmount);
+        }else if (StringUtils.equals("sharemethod", fieldKey)) {
+            ChangeData changeData = e.getChangeSet()[0];
+            String sharemethod = (String) changeData.getNewValue();
+            DynamicObjectCollection expenseentryentity_rules = this.getModel().getEntryEntity("expenseentryentity_rule");
+            if (expenseentryentity_rules.size() > 0) {
+                if (StringUtils.equals(sharemethod, "rate")) {
+                    for (int i = 0; i < expenseentryentity_rules.size(); i++) {
+                        this.getModel().setValue("nckd_ft_amount", null, i);
+                    }
+                } else if (StringUtils.equals(sharemethod, "avg")) {
+                    BigDecimal reimburseamount = (BigDecimal) this.getModel().getValue("reimburseamount");
+                    BigDecimal nckd_ft_amount = reimburseamount.divide(BigDecimal.valueOf(expenseentryentity_rules.size()));
+                    for (int i = 0; i < expenseentryentity_rules.size(); i++) {
+                        this.getModel().setValue("nckd_ft_amount", nckd_ft_amount, i);
+                    }
+                }
+            }
         }
     }
 

+ 22 - 0
src/main/java/fi/er/opplugin/PublicreimburOpPlugin.java

@@ -12,6 +12,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Arrays;
 import java.util.List;
 
@@ -83,6 +84,27 @@ public class PublicreimburOpPlugin extends AbstractOperationServicePlugIn {
                     }
                 }
 
+                //分摊信息分录显示分摊金额
+                DynamicObjectCollection expenseentryentity_rules = info.getDynamicObjectCollection("expenseentryentity_rule");
+                int FtLength = expenseentryentity_rules.size();
+                if (FtLength > 0) {
+                    //报销金额
+                    BigDecimal reimburseamount = info.getBigDecimal("reimburseamount");
+                    //根据分摊方法计算分摊金额
+                    String sharemethod = info.getString("sharemethod");
+                    for (DynamicObject object : expenseentryentity_rules) {
+                        //分摊比例
+                        BigDecimal sharerate_comrule = object.getBigDecimal("sharerate_comrule").divide(BigDecimal.valueOf(100));
+                        if (StringUtils.equals(sharemethod, "rate")) {
+                            BigDecimal ftAmount = reimburseamount.multiply(sharerate_comrule);
+                            object.set("nckd_ft_amount", ftAmount);
+                        } else if (StringUtils.equals(sharemethod, "avg")) {
+                            BigDecimal ftAmount = reimburseamount.divide(BigDecimal.valueOf(FtLength),2, RoundingMode.HALF_UP);
+                            object.set("nckd_ft_amount", ftAmount);
+                        }
+                    }
+                }
+
                 //反写预付借款单
                 DynamicObjectCollection writeoffmoneys = info.getDynamicObjectCollection("writeoffmoney");
                 Boolean exist = QueryServiceHelper.exists(info.getDynamicObjectType().getName(),  info.getPkValue());