|
|
@@ -6,9 +6,12 @@ import common.UserInfo;
|
|
|
import common.YosException;
|
|
|
import common.data.*;
|
|
|
import common.data.db.DBConnect;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
public abstract class BasicBill {
|
|
|
@@ -80,16 +83,20 @@ public abstract class BasicBill {
|
|
|
通用校验
|
|
|
*/
|
|
|
if (ischeck) {
|
|
|
+ if(StringUtils.isBlank(period)){
|
|
|
+ period = getPeriod(true,billRow.getDate("billdate"));
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set period='"+period+"' where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
if (!status.equals("新建")) {
|
|
|
throw new YosException("单号为:【" + billno + "】的出入库单为非新建状态,无法审核");
|
|
|
}
|
|
|
RowsMap rowsMap = dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
|
|
|
if (rowsMap.containsKey(period)) {
|
|
|
if (rowsMap.get(period).toRowsMap("isclose").containsKey("1")) {
|
|
|
- throw new YosException("原单据会计期间已关闭,不可调整");
|
|
|
+ throw new YosException("原单据会计期间已关闭,不可审核");
|
|
|
}
|
|
|
} else {
|
|
|
- throw new YosException("原单据会计期间未生成,不可调整");
|
|
|
+ throw new YosException("原单据会计期间未生成,不可审核");
|
|
|
}
|
|
|
if (itemRows.isEmpty()) {
|
|
|
throw new YosException("表体为空");
|
|
|
@@ -115,9 +122,21 @@ public abstract class BasicBill {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ if(StringUtils.isBlank(period)){
|
|
|
+ period = getPeriod(true,billRow.getDate("billdate"));
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set period='"+period+"' where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
if (!status.equals("审核")) {
|
|
|
throw new YosException("单号为:【" + billno + "】的出入库单为非审核状态,无法反审核");
|
|
|
}
|
|
|
+ RowsMap rowsMap = dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
|
|
|
+ if (rowsMap.containsKey(period)) {
|
|
|
+ if (rowsMap.get(period).toRowsMap("isclose").containsKey("1")) {
|
|
|
+ throw new YosException("原单据会计期间已关闭,不可反审核");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new YosException("单据日期所属会计期间未生成,不可反审核");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -287,6 +306,21 @@ public abstract class BasicBill {
|
|
|
codeRows = dbConnect.runSqlQuery("select t1.* from st_stockbill_items_sku t1 where t1.st_stockbillid ='" + st_stockbillid + "'");
|
|
|
}
|
|
|
|
|
|
+ public String getPeriod(boolean isjudge , Date date) throws YosException {
|
|
|
+
|
|
|
+ String preioddate = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
|
|
+ Rows rows =dbConnect.runSqlQuery("select CONCAT_WS('-', year, LPAD(month, 2, '0')) period from st_period where begdate<='"+preioddate+"' and enddate>='"+preioddate+"'");
|
|
|
+ if (rows.size() != 1) {
|
|
|
+ if(isjudge){
|
|
|
+ throw new YosException("单据日期所属会计期间未生成");
|
|
|
+ }else{
|
|
|
+ return "null";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return rows.get(0).getString("period");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public abstract boolean isInStock(boolean fischeck);
|
|
|
|