wanwei преди 7 месеца
родител
ревизия
42995b27a2
променени са 1 файла, в които са добавени 36 реда и са изтрити 44 реда
  1. 36 44
      src/main/java/fi/er/opplugin/FinapbillBeforeF7SelectSample.java

+ 36 - 44
src/main/java/fi/er/opplugin/FinapbillBeforeF7SelectSample.java

@@ -118,24 +118,17 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 Date bookdate = gzInfo.getDate("bookdate");
                 String remark = gzInfo.getString("remark");
                 BigDecimal pricetaxtotal = gzInfo.getBigDecimal("pricetaxtotal");
-                BigDecimal expeapproveamount = BigDecimal.ZERO;//核定金额
-                BigDecimal orireceiveamount = BigDecimal.ZERO;//收款金额
+                BigDecimal expenseamount = BigDecimal.ZERO;//报销金额
 
 
                 //费用明细分录
                 DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
                 for (DynamicObject object : expenseentryentity) {
-                     expeapproveamount = expeapproveamount.add(object.getBigDecimal("expeapproveamount"));
-                }
-
-                //收款信息分录
-                DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
-                for (DynamicObject object : accountentry) {
-                    orireceiveamount = orireceiveamount.add(object.getBigDecimal("orireceiveamount"));
+                    expenseamount = expenseamount.add(object.getBigDecimal("expenseamount"));
                 }
 
                 //冲销金额
-                BigDecimal nckd_accloanamount = expeapproveamount.subtract(orireceiveamount);
+                BigDecimal nckd_accloanamount = expenseamount;
                 //差额
                 BigDecimal nckd_sub_amount = pricetaxtotal.subtract(nckd_accloanamount);
                 //给冲预付借款赋值
@@ -221,49 +214,18 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
                 this.getModel().setValue("assettaxamount", assettaxamount, 0);
             }
-        } else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
-            ChangeData changeData = e.getChangeSet()[0];
-            BigDecimal assettaxrate = (BigDecimal) changeData.getNewValue();
-            this.getModel().setValue("assettaxrate", assettaxrate);//税率
 
-            //含税金额 = 含税单价 * 数量
-            BigDecimal nckd_amountfield3 = (BigDecimal) this.getModel().getValue("nckd_amountfield3");
-            BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
-            BigDecimal assetexpenseamount = nckd_amountfield3.multiply(asset_quantity);
-            this.getModel().setValue("assetexpenseamount", assetexpenseamount);
-
-            //不含税单价 = 含税单价/(1+税率)
-            assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
-            BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
-            BigDecimal assetpricewithouttax = nckd_amountfield3.divide(rate, 2 , RoundingMode.HALF_UP);
-            this.getModel().setValue("assetpricewithouttax", assetpricewithouttax);
-
-            //不含税金额 = 不含税单价*数量
-            BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
-            this.getModel().setValue("assetorientryamount", assetorientryamount);
-
-            //税额 = 含税金额-不含税金额
-            BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
-            this.getModel().setValue("assettaxamount", assettaxamount);
-        } else if (StringUtils.equals("expeapproveamount", fieldKey) || StringUtils.equals("orireceiveamount", fieldKey)) {
             DynamicObjectCollection nckd_ap_finapbill_detail = this.getModel().getEntryEntity("nckd_ap_finapbill_detail");
             if (nckd_ap_finapbill_detail.size() > 0) {
-                BigDecimal expeapproveamount = BigDecimal.ZERO;//核定金额
-                BigDecimal orireceiveamount = BigDecimal.ZERO;//收款金额
+                BigDecimal expenseamount = BigDecimal.ZERO;//核定金额
                 //费用明细分录
                 DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
                 for (DynamicObject object : expenseentryentity) {
-                    expeapproveamount = expeapproveamount.add(object.getBigDecimal("expeapproveamount"));
-                }
-
-                //收款信息分录
-                DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
-                for (DynamicObject object : accountentry) {
-                    orireceiveamount = orireceiveamount.add(object.getBigDecimal("orireceiveamount"));
+                    expenseamount = expenseamount.add(object.getBigDecimal("expenseamount"));
                 }
 
                 //冲销金额
-                BigDecimal nckd_accloanamount = expeapproveamount.subtract(orireceiveamount);
+                BigDecimal nckd_accloanamount = expenseamount;
                 //借款余额
                 BigDecimal nckd_loanamount = nckd_ap_finapbill_detail.get(0).getBigDecimal("nckd_loanamount");
                 //差额
@@ -277,6 +239,36 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 //刷新冲预付借款分录
                 this.getView().updateView("nckd_ap_finapbill_detail");
             }
+        } else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
+            String reimbursetype = (String) this.getModel().getValue("reimbursetype");
+            if("asset".equals(reimbursetype)) {
+                if (this.getModel().getEntryEntity("assetentry").size() == 0) {
+                    int rowIndex = this.getModel().createNewEntryRow("assetentry");
+                }
+                ChangeData changeData = e.getChangeSet()[0];
+                BigDecimal assettaxrate = (BigDecimal) changeData.getNewValue();
+                this.getModel().setValue("assettaxrate", assettaxrate,0);//税率
+
+                //含税金额 = 含税单价 * 数量
+                BigDecimal nckd_amountfield3 = (BigDecimal) this.getModel().getValue("nckd_amountfield3");
+                BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
+                BigDecimal assetexpenseamount = nckd_amountfield3.multiply(asset_quantity);
+                this.getModel().setValue("assetexpenseamount", assetexpenseamount,0);
+
+                //不含税单价 = 含税单价/(1+税率)
+                assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
+                BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
+                BigDecimal assetpricewithouttax = nckd_amountfield3.divide(rate, 2 , RoundingMode.HALF_UP);
+                this.getModel().setValue("assetpricewithouttax", assetpricewithouttax,0);
+
+                //不含税金额 = 不含税单价*数量
+                BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
+                this.getModel().setValue("assetorientryamount", assetorientryamount,0);
+
+                //税额 = 含税金额-不含税金额
+                BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
+                this.getModel().setValue("assettaxamount", assettaxamount, 0);
+            }
         }
     }