Browse Source

Merge remote-tracking branch 'origin/develop' into develop

hu 1 year ago
parent
commit
38a7b841f8
1 changed files with 28 additions and 8 deletions
  1. 28 8
      src/custom/restcontroller/sale/cashbill/cashbill.java

+ 28 - 8
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -22,10 +22,7 @@ import restcontroller.system.attachment.Attachment;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 import static beans.order.Order.getOrderRows;
 import static restcontroller.webmanage.saletool.orderclue.orderclue.isBigDecimal;
@@ -800,15 +797,20 @@ public class cashbill extends Controller {
         //sqlFactoryquery.addParameter("siteid", siteid);
         //sqlFactoryquery.addParameter_in("sa_creditbillids", stringArray);
         Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='" + siteid + "'");
+        Date date = new Date();
         for (Row row : rows) {
             if (!row.getString("status").equals("审核")) {
                 return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核")
                         .toString();
             }
-            if (rows.get(0).getLong("type") != 1) {
+            if (row.getLong("type") != 1) {
                 return getErrReturnObject().setErrMsg("非收入凭证无法反审核")
                         .toString();
             }
+            if (!isMonth(row.getDate("checkdate"), date)) {
+                return getErrReturnObject().setErrMsg("跨月禁止反审").toString();
+            }
+
         }
 
         ArrayList<String> sqlList = new ArrayList<>();
@@ -861,16 +863,16 @@ public class cashbill extends Controller {
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_cashbillids.size());
         for (Object o : sa_cashbillids) {
             long sa_cashbillid = Long.parseLong(o.toString());
-            Rows RowsStatus = dbConnect.runSqlQuery("select sa_cashbillid,status from sa_cashbill where siteid='"
+            Rows RowsStatus = dbConnect.runSqlQuery("select billno,class,subclass,amount,status,sa_cashbillid,source,sourcenote,remarks from sa_cashbill where siteid='"
                     + siteid + "' and sa_cashbillid='" + sa_cashbillid + "'");
-
+            ArrayList<String> list = new ArrayList<>();
             if (RowsStatus.isNotEmpty()) {
                 if (!RowsStatus.get(0).getString("status").equals("新建")) {
                     batchDeleteErr.addErr(sa_cashbillid, "非新建状态的凭证无法删除");
                     continue;
                 }
+                list.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "删除",RowsStatus.get(0).toString()).getSQL());
             }
-            ArrayList<String> list = new ArrayList<>();
             SQLFactory deletesql = new SQLFactory("sql:delete from sa_cashbill where siteid='" + siteid
                     + "' and sa_cashbillid=" + sa_cashbillid);
             list.add(deletesql.getSQL());
@@ -1260,6 +1262,24 @@ public class cashbill extends Controller {
         return titleMap;
     }
 
+    /**
+     * 判断是否在同一个月
+     *
+     * @return false:不在同一个月内,true在同一个月内
+     */
+    public boolean isMonth(Date date1, Date date2) {
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(date1);
+        Calendar calendar2 = Calendar.getInstance();
+        calendar2.setTime(date2);
+        int year1 = calendar1.get(Calendar.YEAR);
+        int year2 = calendar2.get(Calendar.YEAR);
+        int month1 = calendar1.get(Calendar.MONTH);
+        int month2 = calendar2.get(Calendar.MONTH);
+        return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
+
+    }
+
     public void sendMsg(String content, Long sa_cashbillid, Long sys_enterpriseid) throws YosException {
 
         ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());