郭齐峰 hace 2 años
padre
commit
2425dae889

+ 68 - 0
src/custom/beans/accountbalance/Accountbalance.java

@@ -211,6 +211,74 @@ public class Accountbalance extends BaseClass {
         return sqlList;
     }
 
+    public static ArrayList<String> createCashbillIncome(Controller controller, long sys_enterpriseid, long sa_accountclassid,CashbillEntity cashbillEntity,Boolean ischeck,String type,String typemx) throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
+        long sa_cashbillid = controller.createTableID("sa_cashbill");
+        String billcode = controller.createBillCode("cashbill");
+        SQLFactory sqlFactory = new SQLFactory(new Accountbalance(), "收支凭证新增-分类分类明细");
+        sqlFactory.addParameter("billno", billcode);
+        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+        sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
+        sqlFactory.addParameter("type", 1);
+        sqlFactory.addParameter("siteid", controller.siteid);
+        sqlFactory.addParameter("remarks", cashbillEntity.getRemarks());
+        sqlFactory.addParameter("amount", cashbillEntity.getAmount());
+        sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
+        sqlFactory.addParameter("userid", controller.userid);
+        sqlFactory.addParameter("username", controller.username);
+        sqlFactory.addParameter("ownertable", cashbillEntity.getOwnertable());
+        sqlFactory.addParameter("ownerid", cashbillEntity.getOwnerid());
+        sqlFactory.addParameter("source", cashbillEntity.getSource());
+        sqlFactory.addParameter("sourcenote", cashbillEntity.getSourcenote());
+        sqlFactory.addParameter("sa_cashbillid_rebate", "null");
+        sqlFactory.addParameter("class", type);
+        sqlFactory.addParameter("subclass", typemx);
+        if (ischeck) {
+            BigDecimal balance;  //当前账户余额
+            sqlFactory.addParameter("status", "审核");
+            sqlFactory.addParameter("checkby", controller.username);
+            sqlFactory.addParameter_SQL("checkdate", "CURRENT_TIME");
+
+            // 审核逻辑判断
+            Rows rowsaccountbalance = controller.dbConnect.runSqlQuery(
+                    "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
+                            + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='"
+                            + controller.siteid + "'");
+
+            if (rowsaccountbalance.isEmpty()) {
+                SQLFactory accountbalanceaddSqlFactory = new SQLFactory(new Accountbalance(), "营销账户余额新增");
+                accountbalanceaddSqlFactory.addParameter("sa_accountbalanceid",
+                        controller.createTableID("sa_accountbalance"));
+                accountbalanceaddSqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+                accountbalanceaddSqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
+                accountbalanceaddSqlFactory.addParameter("siteid", controller.siteid);
+                accountbalanceaddSqlFactory.addParameter("balance", cashbillEntity.getAmount());
+                accountbalanceaddSqlFactory.addParameter("userid", controller.userid);
+                accountbalanceaddSqlFactory.addParameter("username", controller.username);
+                balance = cashbillEntity.getAmount();
+                sqlList.add(accountbalanceaddSqlFactory.getSQL());
+            } else {
+                BigDecimal newbalance = cashbillEntity.getAmount().add(rowsaccountbalance.get(0).getBigDecimal("balance"));
+                sqlList.add("update sa_accountbalance set balance='" + newbalance
+                        + "',changedate=CURRENT_TIME,changeby ='" + controller.username + "',changeuserid='"
+                        + controller.userid + "' where sys_enterpriseid ='" + sys_enterpriseid
+                        + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + controller.siteid
+                        + "'");
+                balance = newbalance;
+            }
+            sqlFactory.addParameter("balance", balance);
+        } else {
+            sqlFactory.addParameter("status", "新建");
+            sqlFactory.addParameter("checkby", "null");
+            sqlFactory.addParameter("checkdate", "null");
+            sqlFactory.addParameter("balance", 0);
+        }
+        sqlList.add(sqlFactory.getSQL());
+        String content = "您有一项来自【" + cashbillEntity.getSource() + "】金额为" + cashbillEntity.getAmount() + "的【收入】凭证";
+        new Accountbalance().sendMsg(controller, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
+        return sqlList;
+    }
+
     public static ArrayList<String> createCashbillPay(Controller controller, long sys_enterpriseid, long sa_accountclassid, CashbillEntity cashbillEntity, boolean ischeck, Long sa_cashbillid_rebate) throws YosException {
         ArrayList<String> sqlList = new ArrayList<>();
         long sa_cashbillid = controller.createTableID("sa_cashbill");

+ 0 - 0
src/custom/restcontroller/webmanage/sale/paybill/SQL/收支凭证新增.sql → src/custom/beans/accountbalance/SQL/收支凭证新增-分类分类明细.sql


+ 3 - 33
src/custom/restcontroller/webmanage/sale/paybill/Paybill.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.sale.paybill;
 
 import beans.accountbalance.Accountbalance;
+import beans.accountbalance.AccountbalanceEntity;
 import beans.accountbalance.CashbillEntity;
 import beans.data.BatchDeleteErr;
 import beans.datacontrllog.DataContrlLog;
@@ -197,7 +198,8 @@ public class Paybill extends Controller {
         String remarks = rows.get(0).getString("remarks");
         for (Row row : accountclassRows) {
             BigDecimal amount = row.getBigDecimal("amount");
-            sqlList.addAll(createCashbillIncome(this, sys_enterpriseid, row.getLong("sa_accountclassid"), remarks, amount,sa_paybillid,billno));
+            CashbillEntity cashbillEntity = new CashbillEntity(amount, remarks, "打款凭证", billno, "sa_paybill", sa_paybillid);
+            sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, row.getLong("sa_accountclassid"), cashbillEntity, false, "货款", ""));
         }
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
@@ -257,36 +259,4 @@ public class Paybill extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         return getSucReturnObject().setData(rows).toString();
     }
-
-    public static ArrayList<String> createCashbillIncome(Controller controller, long sys_enterpriseid, long sa_accountclassid,String remarks,BigDecimal amount,Long sa_paybillid,String billno) throws YosException {
-        ArrayList<String> sqlList = new ArrayList<>();
-        long sa_cashbillid = controller.createTableID("sa_cashbill");
-        String billcode = controller.createBillCode("cashbill");
-        SQLFactory sqlFactory = new SQLFactory(controller, "收支凭证新增");
-        sqlFactory.addParameter("billno", billcode);
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-        sqlFactory.addParameter("type", 1);
-        sqlFactory.addParameter("siteid", controller.siteid);
-        sqlFactory.addParameter("remarks", remarks);
-        sqlFactory.addParameter("amount", amount);
-        sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
-        sqlFactory.addParameter("userid", controller.userid);
-        sqlFactory.addParameter("username", controller.username);
-        sqlFactory.addParameter("ownertable", "sa_paybill");
-        sqlFactory.addParameter("ownerid", sa_paybillid);
-        sqlFactory.addParameter("source", "打款凭证");
-        sqlFactory.addParameter("sourcenote", billno);
-        sqlFactory.addParameter("sa_cashbillid_rebate", "null");
-        sqlFactory.addParameter("status", "审核");
-        sqlFactory.addParameter("class", "货款");
-        sqlFactory.addParameter("status", "新建");
-        sqlFactory.addParameter("checkby", "null");
-        sqlFactory.addParameter("checkdate", "null");
-        sqlFactory.addParameter("balance", 0);
-        sqlList.add(sqlFactory.getSQL());
-        String content = "您有一项来自【打款凭证】金额为" + amount + "的【收入】凭证";
-        new Accountbalance().sendMsg(controller, content, sa_paybillid, sys_enterpriseid);
-        return sqlList;
-    }
 }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/transferbill/Transferbill.java

@@ -119,9 +119,9 @@ public class Transferbill extends Controller {
         ArrayList<String> sqlList = new ArrayList<>();
         sqlList.add("update sa_transferbill set checkby='" + username + "',checkdate=current_date,status='审核' where siteid='" + siteid + "' and sa_transferbillid=" + sa_transferbillid);
         CashbillEntity cashbillEntity = new CashbillEntity(amount.negate(), "", "转账单", rows.get(0).getString("billno"), "sa_transferbill", sa_transferbillid);
-        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, sa_accountclassid, cashbillEntity, true));
+        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, sa_accountclassid, cashbillEntity, true,"货款",""));
         cashbillEntity.setAmount(amount);
-        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true));
+        sqlList.addAll(Accountbalance.createCashbillIncome(this, sys_enterpriseid, inaccountclassid, cashbillEntity, true,"货款",""));
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
     }