|
@@ -474,9 +474,28 @@ public class tpartreimbursement extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {tpartreimbursement.class, stockbill.class, Order.class, OrderItems.class})
|
|
@CACHEING_CLEAN(apiClass = {tpartreimbursement.class, stockbill.class, Order.class, OrderItems.class})
|
|
|
public String hexiao() throws YosException {
|
|
public String hexiao() throws YosException {
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
- BigDecimal amount =content.getBigDecimal("amount");
|
|
|
|
|
- BigDecimal discountamount =content.getBigDecimal("discountamount");
|
|
|
|
|
|
|
+ BigDecimal amount =BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal discountamount =BigDecimal.ZERO;
|
|
|
long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Rows sumamountRows = dbConnect.runSqlQuery("select min(t1.payamount) payamount, min(t1.paydiscountamount) paydiscountamount,t1.st_stockbillid from st_stockbill t1 " +
|
|
|
|
|
+ "inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid " +
|
|
|
|
|
+ "inner join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid" +
|
|
|
|
|
+ " where t1.siteid='" + siteid + "' and t1.status='审核' and t1.rb=1 and t1.type='销售出库' and t3.type='配件订单' and t3.sys_enterpriseid='" + sys_enterpriseid + "' and DATE_FORMAT( t1.checkdate, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) group by t1.st_stockbillid");
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL querySQL1 = SQLFactory.createQuerySQL(this, "st_stockbill","payamount","paydiscountamount");
|
|
|
|
|
+ querySQL1.setTableAlias("t1");
|
|
|
|
|
+ querySQL1.addJoinTable(JOINTYPE.left, "st_stockbill_items", "t2", "t2.st_stockbillid = t1.st_stockbillid AND t2.siteid = t1.siteid","amount");
|
|
|
|
|
+ querySQL1.setSiteid(siteid);
|
|
|
|
|
+ querySQL1.setWhere("t1.sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
+ querySQL1.setWhere("t1.sourceobject='tpartreimbursement' and t1.status='审核' and t1.type='销售出库' and DATE_FORMAT(t1.checkdate, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )");
|
|
|
|
|
+ Rows rows1 = querySQL1.query();
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<String,BigDecimal> map =new HashMap<>();
|
|
|
|
|
+ amount=sumamountRows.sum("payamount").subtract(rows1.sum("payamount"));
|
|
|
|
|
+ discountamount=sumamountRows.sum("paydiscountamount").subtract(rows1.sum("paydiscountamount"));
|
|
|
|
|
+
|
|
|
JSONArray sa_tpartreimbursementdetailids = content.getJSONArray("sa_tpartreimbursementdetailids");
|
|
JSONArray sa_tpartreimbursementdetailids = content.getJSONArray("sa_tpartreimbursementdetailids");
|
|
|
JSONArray iteminfos = content.getJSONArray("iteminfos");
|
|
JSONArray iteminfos = content.getJSONArray("iteminfos");
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid","isverified","qty","sa_orderitemsid","hongbillno");
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid","isverified","qty","sa_orderitemsid","hongbillno");
|
|
@@ -630,6 +649,9 @@ public class tpartreimbursement extends Controller {
|
|
|
insertSQL.setValue("payamount", totalamount.subtract(discountamount));
|
|
insertSQL.setValue("payamount", totalamount.subtract(discountamount));
|
|
|
insertSQL.setValue("paydiscountamount", discountamount);
|
|
insertSQL.setValue("paydiscountamount", discountamount);
|
|
|
}
|
|
}
|
|
|
|
|
+ if(totalamount.compareTo((discountamount.add(amount)))>0){
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("大于当月剩余可核销金额,无法核销").toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
sqllist.add(insertSQL.getSQL());
|
|
sqllist.add(insertSQL.getSQL());
|