|
|
@@ -252,7 +252,7 @@ public class Accountbalance extends BaseClass {
|
|
|
throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
} else {
|
|
|
BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
|
|
|
- if ((cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(canuseamount) == 1) {
|
|
|
+ if ((cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(canuseamount) == 1 && (cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(BigDecimal.ZERO)>=0) {
|
|
|
throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
}
|
|
|
BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|
|
|
@@ -359,69 +359,69 @@ public class Accountbalance extends BaseClass {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static JSONObject 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");
|
|
|
- String billcode = controller.createBillCode("cashbill1");
|
|
|
- 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", 0);
|
|
|
- sqlFactory.addParameter("siteid", controller.siteid);
|
|
|
- sqlFactory.addParameter("remarks", cashbillEntity.getRemarks());
|
|
|
- sqlFactory.addParameter("amount", cashbillEntity.getAmount());
|
|
|
- sqlFactory.addParameter("discountamount", cashbillEntity.getDiscountamountamount());
|
|
|
- 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", sa_cashbillid_rebate);
|
|
|
- sqlFactory.addParameter("class", cashbillEntity.getType());
|
|
|
- sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
|
|
|
- sqlFactory.addParameter("period", cashbillEntity.getPeriod());
|
|
|
- if (ischeck) {
|
|
|
- BigDecimal balance = BigDecimal.ZERO; //当前账户余额
|
|
|
- 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()) {
|
|
|
- throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
- } else {
|
|
|
- BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
- if (cashbillEntity.getAmount().compareTo(canuseamount) == 1) {
|
|
|
- throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
- }
|
|
|
- BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|
|
|
- BigDecimal newdiscountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(cashbillEntity.getDiscountamountamount());
|
|
|
- sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount='" + newdiscountamount + "',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);
|
|
|
- Rows accountclassrows = controller.dbConnect.runSqlQuery("select * from sa_accountclass where siteid='" + controller.siteid + "' and sa_accountclassid=" + sa_accountclassid);
|
|
|
- if (!accountclassrows.isEmpty()) {
|
|
|
- String content = "您的" + accountclassrows.get(0).getString("accountname") + "已支出【" + cashbillEntity.getAmount() + "】元";
|
|
|
- new Accountbalance().sendMsg(controller, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
|
|
|
- }
|
|
|
- } else {
|
|
|
- sqlFactory.addParameter("status", "新建");
|
|
|
- sqlFactory.addParameter("checkby", "");
|
|
|
- sqlFactory.addParameter("checkdate", "");
|
|
|
- sqlFactory.addParameter("balance", 0);
|
|
|
- }
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
-
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("sa_cashbillid", sa_cashbillid);
|
|
|
- jsonObject.put("sqlList", sqlList);
|
|
|
- return jsonObject;
|
|
|
- }
|
|
|
+// public static JSONObject 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");
|
|
|
+// String billcode = controller.createBillCode("cashbill1");
|
|
|
+// 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", 0);
|
|
|
+// sqlFactory.addParameter("siteid", controller.siteid);
|
|
|
+// sqlFactory.addParameter("remarks", cashbillEntity.getRemarks());
|
|
|
+// sqlFactory.addParameter("amount", cashbillEntity.getAmount());
|
|
|
+// sqlFactory.addParameter("discountamount", cashbillEntity.getDiscountamountamount());
|
|
|
+// 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", sa_cashbillid_rebate);
|
|
|
+// sqlFactory.addParameter("class", cashbillEntity.getType());
|
|
|
+// sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
|
|
|
+// sqlFactory.addParameter("period", cashbillEntity.getPeriod());
|
|
|
+// if (ischeck) {
|
|
|
+// BigDecimal balance = BigDecimal.ZERO; //当前账户余额
|
|
|
+// 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()) {
|
|
|
+// throw new YosException(false, "该营销账户不存在,支出凭证无法审核");
|
|
|
+// } else {
|
|
|
+// BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
|
|
|
+// if (cashbillEntity.getAmount().compareTo(canuseamount) == 1 && (cashbillEntity.getAmount().add(cashbillEntity.getDiscountamountamount())).compareTo(BigDecimal.ZERO)>=0) {
|
|
|
+// throw new YosException(false, "该营销账户可用余额不足,支出凭证无法审核");
|
|
|
+// }
|
|
|
+// BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(cashbillEntity.getAmount());
|
|
|
+// BigDecimal newdiscountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(cashbillEntity.getDiscountamountamount());
|
|
|
+// sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount='" + newdiscountamount + "',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);
|
|
|
+// Rows accountclassrows = controller.dbConnect.runSqlQuery("select * from sa_accountclass where siteid='" + controller.siteid + "' and sa_accountclassid=" + sa_accountclassid);
|
|
|
+// if (!accountclassrows.isEmpty()) {
|
|
|
+// String content = "您的" + accountclassrows.get(0).getString("accountname") + "已支出【" + cashbillEntity.getAmount() + "】元";
|
|
|
+// new Accountbalance().sendMsg(controller, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// sqlFactory.addParameter("status", "新建");
|
|
|
+// sqlFactory.addParameter("checkby", "");
|
|
|
+// sqlFactory.addParameter("checkdate", "");
|
|
|
+// sqlFactory.addParameter("balance", 0);
|
|
|
+// }
|
|
|
+// sqlList.add(sqlFactory.getSQL());
|
|
|
+//
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("sa_cashbillid", sa_cashbillid);
|
|
|
+// jsonObject.put("sqlList", sqlList);
|
|
|
+// return jsonObject;
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 创建收入凭证(直接执行SQL语句)
|