Browse Source

报销单计算不含税金额差额

wanwei 7 tháng trước cách đây
mục cha
commit
c31deb92c7

+ 82 - 3
src/main/java/fi/er/opplugin/FinapbillBeforeF7SelectSample.java

@@ -126,20 +126,39 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 DynamicObject receivingsupplierid = gzInfo.getDynamicObject("receivingsupplierid");//供应商
                 Date bookdate = gzInfo.getDate("bookdate");
                 String remark = gzInfo.getString("remark");
-                BigDecimal pricetaxtotal = gzInfo.getBigDecimal("pricetaxtotal");
+                BigDecimal pricetaxtotal = gzInfo.getBigDecimal("pricetaxtotal");//应付金额
+                BigDecimal e_amount = BigDecimal.ZERO;//不含税应付金额
                 BigDecimal expenseamount = BigDecimal.ZERO;//报销金额
+                BigDecimal orientryamount = BigDecimal.ZERO;//不含税金额
 
+                //应付挂账单明细分录
+                DynamicObjectCollection detailentry1 = gzInfo.getDynamicObjectCollection("detailentry");
+                for (DynamicObject object : detailentry1) {
+                    e_amount = e_amount.add(object.getBigDecimal("e_amount"));
+                }
 
                 //费用明细分录
                 DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
                 for (DynamicObject object : expenseentryentity) {
                     expenseamount = expenseamount.add(object.getBigDecimal("expenseamount"));
+                    orientryamount = orientryamount.add(object.getBigDecimal("orientryamount"));
                 }
 
                 //冲销金额
                 BigDecimal nckd_accloanamount = expenseamount;
+
+                //不含税借款余额
+                BigDecimal nckd_e_amount = e_amount;
+
+                //不含税冲销金额
+                BigDecimal nckd_amountfield6 = orientryamount;
+
                 //差额
                 BigDecimal nckd_sub_amount = pricetaxtotal.subtract(nckd_accloanamount);
+
+                //不含税差额
+                BigDecimal nckd_amountfield8 = nckd_e_amount.subtract(nckd_amountfield6);
+
                 //给冲预付借款赋值
                 this.getModel().deleteEntryData("nckd_ap_finapbill_detail");
                 int rowIndex = this.getModel().createNewEntryRow("nckd_ap_finapbill_detail");
@@ -155,9 +174,20 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 this.getModel().setValue("nckd_currloanamount",pricetaxtotal,rowIndex);
                 this.getModel().setValue("nckd_accloanamount",nckd_accloanamount,rowIndex);
                 this.getModel().setValue("nckd_curraccloanamount",nckd_accloanamount,rowIndex);
-                this.getModel().setValue("nckd_sub_amount",nckd_sub_amount,rowIndex);
+                this.getModel().setValue("nckd_amountfield7",nckd_sub_amount,rowIndex);
+                this.getModel().setValue("nckd_e_amount",nckd_e_amount,rowIndex);
+                this.getModel().setValue("nckd_amountfield6",nckd_amountfield6,rowIndex);
+                this.getModel().setValue("nckd_amountfield8",nckd_amountfield8,rowIndex);
+
+                DynamicObjectCollection assetentry = this.getModel().getEntryEntity("assetentry");
+                if(assetentry.size() > 0) {
+                    this.getModel().setValue("nckd_amountfield9",nckd_sub_amount,0);
+                    this.getModel().setValue("nckd_amountfield10",nckd_amountfield8,0);
+                }
+
                 //刷新冲预付借款分录
                 this.getView().updateView("nckd_ap_finapbill_detail");
+                this.getView().updateView("assetentry");
             }
         }else if (StringUtils.equals("expenseamount", fieldKey) || StringUtils.equals("nckd_amountfield3", fieldKey)) {
             String reimbursetype = (String) this.getModel().getValue("reimbursetype");
@@ -193,26 +223,45 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
             DynamicObjectCollection nckd_ap_finapbill_detail = this.getModel().getEntryEntity("nckd_ap_finapbill_detail");
             if (nckd_ap_finapbill_detail.size() > 0) {
                 BigDecimal expenseamount = BigDecimal.ZERO;//核定金额
+                BigDecimal orientryamount = BigDecimal.ZERO;//不含税核定金额
                 //费用明细分录
                 DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
                 for (DynamicObject object : expenseentryentity) {
                     expenseamount = expenseamount.add(object.getBigDecimal("expenseamount"));
+                    orientryamount = orientryamount.add(object.getBigDecimal("orientryamount"));
                 }
 
                 //冲销金额
                 BigDecimal nckd_accloanamount = expenseamount;
+                //不含税冲销金额
+                BigDecimal nckd_amountfield6 = orientryamount;
                 //借款余额
                 BigDecimal nckd_loanamount = nckd_ap_finapbill_detail.get(0).getBigDecimal("nckd_loanamount");
+                //不含税借款余额
+                BigDecimal nckd_e_amount = nckd_ap_finapbill_detail.get(0).getBigDecimal("nckd_e_amount");
                 //差额
                 BigDecimal nckd_sub_amount = nckd_loanamount.subtract(nckd_accloanamount);
+                //不含税差额
+                BigDecimal nckd_amountfield8 = nckd_e_amount.subtract(nckd_amountfield6);
 
                 this.getModel().setValue("nckd_loanamount",nckd_loanamount,0);
                 this.getModel().setValue("nckd_currloanamount",nckd_loanamount,0);
                 this.getModel().setValue("nckd_accloanamount",nckd_accloanamount,0);
                 this.getModel().setValue("nckd_curraccloanamount",nckd_accloanamount,0);
-                this.getModel().setValue("nckd_sub_amount",nckd_sub_amount,0);
+                this.getModel().setValue("nckd_amountfield7",nckd_sub_amount,0);
+                this.getModel().setValue("nckd_e_amount",nckd_e_amount,0);
+                this.getModel().setValue("nckd_amountfield6",nckd_amountfield6,0);
+                this.getModel().setValue("nckd_amountfield8",nckd_amountfield8,0);
+
+                DynamicObjectCollection assetentry = this.getModel().getEntryEntity("assetentry");
+                if(assetentry.size() > 0) {
+                    this.getModel().setValue("nckd_amountfield9",nckd_sub_amount,0);
+                    this.getModel().setValue("nckd_amountfield10",nckd_amountfield8,0);
+                }
+
                 //刷新冲预付借款分录
                 this.getView().updateView("nckd_ap_finapbill_detail");
+                this.getView().updateView("assetentry");
             }
         } else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
             String reimbursetype = (String) this.getModel().getValue("reimbursetype");
@@ -244,6 +293,36 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
                 BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
                 this.getModel().setValue("assettaxamount", assettaxamount, 0);
             }
+
+            DynamicObjectCollection nckd_ap_finapbill_detail = this.getModel().getEntryEntity("nckd_ap_finapbill_detail");
+            if (nckd_ap_finapbill_detail.size() > 0) {
+                BigDecimal orientryamount = BigDecimal.ZERO;//不含税核定金额
+                //费用明细分录
+                DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
+                for (DynamicObject object : expenseentryentity) {
+                    orientryamount = orientryamount.add(object.getBigDecimal("orientryamount"));
+                }
+
+                //不含税冲销金额
+                BigDecimal nckd_amountfield6 = orientryamount;
+                //不含税借款余额
+                BigDecimal nckd_e_amount = nckd_ap_finapbill_detail.get(0).getBigDecimal("nckd_e_amount");
+                //不含税差额
+                BigDecimal nckd_amountfield8 = nckd_e_amount.subtract(nckd_amountfield6);
+
+                this.getModel().setValue("nckd_e_amount",nckd_e_amount,0);
+                this.getModel().setValue("nckd_amountfield6",nckd_amountfield6,0);
+                this.getModel().setValue("nckd_amountfield8",nckd_amountfield8,0);
+
+                DynamicObjectCollection assetentry = this.getModel().getEntryEntity("assetentry");
+                if(assetentry.size() > 0) {
+                    this.getModel().setValue("nckd_amountfield10",nckd_amountfield8,0);
+                }
+
+                //刷新冲预付借款分录
+                this.getView().updateView("nckd_ap_finapbill_detail");
+                this.getView().updateView("assetentry");
+            }
         }
     }