فهرست منبع

1.线上开票申请单,操作反审核,将单据置为提交状态
2.手工开票申请单,操作反审核,将单据置为提交状态,并重新核算订单的已开单金额

沈静伟 4 سال پیش
والد
کامیت
756c720877
2فایلهای تغییر یافته به همراه87 افزوده شده و 54 حذف شده
  1. 75 52
      src/apps/tinvoiceapply/tinvoiceapply.java
  2. 12 2
      src/apps/tinvoiceapply/tinvoiceapplyAppBean.java

+ 75 - 52
src/apps/tinvoiceapply/tinvoiceapply.java

@@ -126,71 +126,94 @@ public class tinvoiceapply extends PaoCust {
         setValue("submitdate", issubmit ? getDateTime() : null, 11L);
     }
 
-    public void checkvalidate() throws P2Exception {
+    public void checkvalidate(boolean ischeck) throws P2Exception {
         PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
         PaoSetRemote tinvoicebillSet = getPaoSet("tinvoicebill");
         /****************** 单据检验 *********************/
-
-        if (!"提交".equals(getString("fstatus"))) {
-            throw new P2AppException("", "非提交状态下不可审核");
-        }
-        if (tinvoiceapplyorderSet.isEmpty()) {
-            throw new P2AppException("", "订单信息为空不可审核");
-        }
-        if (tinvoicebillSet.isEmpty()) {
-            throw new P2AppException("", "开票信息为空不可审核");
-        }
-        if (tinvoiceapplyorderSet.min("finvoiceamount") <= 0) {
-            throw new P2AppException("", "订单行开票金额必须大于0");
-        }
-        PaoSetRemote tinvoiceapply_totalview = getPaoSet("tinvoiceapply_totalview");
-        if (tinvoiceapply_totalview.getPao(0).getDouble("forderamount") != tinvoiceapply_totalview.getPao(0).getDouble("fbillamount")) {
-            throw new P2AppException("", "订单金额和开票金额不一致");
-        }
-
-        int i = 0;
-        PaoRemote detailpao = null;
-        while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
-            double finvoiceamount = detailpao.getDouble("finvoiceamount");//本次开票金额
-
-            PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
-            PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
-            double freceivedamount = 0;
-            if (!saorder_receivedviewSet.isEmpty()) {
-                freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//订单已收货金额
+        if (ischeck) {
+            if (!"提交".equals(getString("fstatus"))) {
+                throw new P2AppException("", "非提交状态下不可审核");
             }
-            String fsonum = saorderdetail.getString("fsonum");//订单号
-            String fitemname = saorderdetail.getString("fitemname");//商品名称
-            double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
-            if (finvoiceamount > Math.sub(freceivedamount, finvoiceamount_order)) {
-                throw new P2AppException("", "订单" + fsonum + "商品" + fitemname + "本次开票金额" + finvoiceamount + "超过订单可开票金额" + Math.sub(freceivedamount, finvoiceamount_order));
+            if (tinvoiceapplyorderSet.isEmpty()) {
+                throw new P2AppException("", "订单信息为空不可审核");
+            }
+            if (tinvoicebillSet.isEmpty()) {
+                throw new P2AppException("", "开票信息为空不可审核");
+            }
+            if (tinvoiceapplyorderSet.min("finvoiceamount") <= 0) {
+                throw new P2AppException("", "订单行开票金额必须大于0");
+            }
+            PaoSetRemote tinvoiceapply_totalview = getPaoSet("tinvoiceapply_totalview");
+            if (tinvoiceapply_totalview.getPao(0).getDouble("forderamount") != tinvoiceapply_totalview.getPao(0).getDouble("fbillamount")) {
+                throw new P2AppException("", "订单金额和开票金额不一致");
             }
-            i++;
-        }
-    }
-
-    public void check() throws P2Exception {
 
-        if ("手工".equalsIgnoreCase(getString("ftype"))) {
-            PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
             int i = 0;
             PaoRemote detailpao = null;
             while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
-                double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
+                double finvoiceamount = detailpao.getDouble("finvoiceamount");//本次开票金额
+
                 PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
+                PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
+                double freceivedamount = 0;
+                if (!saorder_receivedviewSet.isEmpty()) {
+                    freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//订单已收货金额
+                }
+                String fsonum = saorderdetail.getString("fsonum");//订单号
+                String fitemname = saorderdetail.getString("fitemname");//商品名称
                 double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
-                saorderdetail.setValue("finvoiceamount", Math.add(finvoiceamount_order, finvoiceamount_detail), 111L);
+                if (finvoiceamount > Math.sub(freceivedamount, finvoiceamount_order)) {
+                    throw new P2AppException("", "订单" + fsonum + "商品" + fitemname + "本次开票金额" + finvoiceamount + "超过订单可开票金额" + Math.sub(freceivedamount, finvoiceamount_order));
+                }
                 i++;
             }
+        } else {
+            if (!"手工".equalsIgnoreCase(getString("ftype"))) {
+                int i = 0;
+                while (tinvoicebillSet.getPao(i) != null) {
+                    if (!tinvoicebillSet.getPao(i).getString("fstatus").equals("")) {
+                        throw new P2AppException("", "已对接开票接口,不可进行反审核!");
+                    }
+                    i++;
+                }
+            }
         }
+    }
 
-        setValue("fstatus", "审核", 11L);
-        setValue("checkby", getUserName(), 11L);
-        setValue("checkdate", getDateTime(), 11L);
-
-        //getPaoSet("tinvoicebill").selectAll();
-        //createBlueInvoice();
-
+    public void check(boolean ischeck) throws P2Exception {
+        if (ischeck) {
+            if ("手工".equalsIgnoreCase(getString("ftype"))) {
+                PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
+                int i = 0;
+                PaoRemote detailpao = null;
+                while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
+                    double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
+                    PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
+                    double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
+                    saorderdetail.setValue("finvoiceamount", Math.add(finvoiceamount_order, finvoiceamount_detail), 111L);
+                    i++;
+                }
+            }
+            setValue("fstatus", "审核", 11L);
+            setValue("checkby", getUserName(), 11L);
+            setValue("checkdate", getDateTime(), 11L);
+        } else {
+            if ("手工".equalsIgnoreCase(getString("ftype"))) {
+                PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
+                int i = 0;
+                PaoRemote detailpao = null;
+                while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
+                    double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
+                    PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
+                    double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
+                    saorderdetail.setValue("finvoiceamount", Math.sub(finvoiceamount_order, finvoiceamount_detail), 111L);
+                    i++;
+                }
+            }
+            setValue("fstatus", "提交", 11L);
+            setValue("checkby", "", 11L);
+            setValue("checkdate", "", 11L);
+        }
     }
 
     /**
@@ -354,8 +377,8 @@ public class tinvoiceapply extends PaoCust {
             if (!rows.isEmpty()) {
                 setValue("FINVOICEMOBILE", rows.get(0).getString("fphonenumber"));
                 setValue("FINVOICEBANKANDACCOUNT", rows.get(0).getString("fbankcardid"));
-            }else{
-                setValue("FINVOICEMOBILE","");
+            } else {
+                setValue("FINVOICEMOBILE", "");
                 setValue("FINVOICEBANKANDACCOUNT", "");
             }
         }

+ 12 - 2
src/apps/tinvoiceapply/tinvoiceapplyAppBean.java

@@ -33,8 +33,18 @@ public class tinvoiceapplyAppBean extends AppBeanCust {
     public int CHECK() throws P2Exception {
         this.SAVE();
         tinvoiceapply tinvoiceapply = (tinvoiceapply) getPao();
-        tinvoiceapply.checkvalidate();
-        tinvoiceapply.check();
+        tinvoiceapply.checkvalidate(true);
+        tinvoiceapply.check(true);
+        this.SAVE();
+        byrefresh();
+        return 1;
+    }
+    @Override
+    public int UNCHECK() throws P2Exception {
+        this.SAVE();
+        tinvoiceapply tinvoiceapply = (tinvoiceapply) getPao();
+        tinvoiceapply.checkvalidate(false);
+        tinvoiceapply.check(false);
         this.SAVE();
         byrefresh();
         return 1;