|
|
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static beans.stockbill.bills.XSCK.getCashbillEntity;
|
|
|
@@ -435,12 +436,12 @@ public class tpartreimbursement extends Controller {
|
|
|
@CACHEING
|
|
|
public String queryReimbursableAmount() throws YosException {
|
|
|
sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
- Rows sumamountRows = dbConnect.runSqlQuery("select amount from st_stockbill t1 " +
|
|
|
+ Rows sumamountRows = dbConnect.runSqlQuery("select t1.payamount,t1.paydiscountamount 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.type='销售出库' and t3.type='配件订单' and t3.sys_enterpriseid='" + sys_enterpriseid + "' and DATE_FORMAT( t1.checkdate, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )");
|
|
|
+ " 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' )");
|
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill","payamount","paydiscountamount");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "st_stockbill_items", "t2", "t2.st_stockbillid = t1.st_stockbillid AND t2.siteid = t1.siteid","amount");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
@@ -448,8 +449,10 @@ public class tpartreimbursement extends Controller {
|
|
|
querySQL.setWhere("t1.sourceobject='tpartreimbursement' and t1.status='审核' and t1.type='销售出库' and DATE_FORMAT(t1.checkdate, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )");
|
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
-
|
|
|
- return getSucReturnObject().setData(sumamountRows.sum("amount").subtract(rows.sum("amount"))).toString();
|
|
|
+ HashMap<String,BigDecimal> map =new HashMap<>();
|
|
|
+ map.put("amount",sumamountRows.sum("payamount").subtract(rows.sum("payamount")));
|
|
|
+ map.put("discountamount",sumamountRows.sum("paydiscountamount").subtract(rows.sum("paydiscountamount")));
|
|
|
+ return getSucReturnObject().setData(map).toString();
|
|
|
}
|
|
|
|
|
|
@API(title = "查询审核需核销金额", apiversion = R.ID2025081815213903.v1.class)
|
|
|
@@ -471,6 +474,8 @@ public class tpartreimbursement extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {tpartreimbursement.class, stockbill.class, Order.class, OrderItems.class})
|
|
|
public String hexiao() throws YosException {
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ BigDecimal amount =content.getBigDecimal("amount");
|
|
|
+ BigDecimal discountamount =content.getBigDecimal("discountamount");
|
|
|
long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
JSONArray sa_tpartreimbursementdetailids = content.getJSONArray("sa_tpartreimbursementdetailids");
|
|
|
JSONArray iteminfos = content.getJSONArray("iteminfos");
|
|
|
@@ -618,9 +623,14 @@ public class tpartreimbursement extends Controller {
|
|
|
Integer sa_tpartreimbursementdetailid = (Integer) object;
|
|
|
sqllist.add("update sa_tpartreimbursementdetail set hongbillno='"+billno+"' where sa_tpartreimbursementdetailid="+sa_tpartreimbursementdetailid);
|
|
|
}
|
|
|
+ if (discountamount.compareTo(totalamount) > 0) {
|
|
|
+ insertSQL.setValue("payamount", 0);
|
|
|
+ insertSQL.setValue("paydiscountamount", totalamount);
|
|
|
+ } else {
|
|
|
+ insertSQL.setValue("payamount", totalamount.subtract(discountamount));
|
|
|
+ insertSQL.setValue("paydiscountamount", discountamount);
|
|
|
+ }
|
|
|
|
|
|
- insertSQL.setValue("payamount", totalamount);
|
|
|
- insertSQL.setValue("paydiscountamount", 0);
|
|
|
|
|
|
sqllist.add(insertSQL.getSQL());
|
|
|
sqllist.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "新增", "销售出库单新增成功,来源配件核销"+rows.toJsonArray("billno").toJSONString()).getSQL());
|
|
|
@@ -634,9 +644,9 @@ public class tpartreimbursement extends Controller {
|
|
|
Stockbill.check(this, st_stockbillid, true);
|
|
|
} catch (YosException e) {
|
|
|
// Code to handle the exception
|
|
|
- dbConnect.runSqlUpdate("delete from st_stockbill where st_stockbillid="+st_stockbillid);
|
|
|
- dbConnect.runSqlUpdate("delete from st_stockbill_items where st_stockbillid="+st_stockbillid);
|
|
|
- dbConnect.runSqlUpdate("delete from sys_contrllog where ownerid="+st_stockbillid+" and ownertable='st_stockbill'");
|
|
|
+ dbConnect.runSqlUpdate("delete from st_stockbill where st_stockbillid="+st_stockbillid);
|
|
|
+ dbConnect.runSqlUpdate("delete from st_stockbill_items where st_stockbillid="+st_stockbillid);
|
|
|
+ dbConnect.runSqlUpdate("delete from sys_contrllog where ownerid="+st_stockbillid+" and ownertable='st_stockbill'");
|
|
|
for(Object object:sa_tpartreimbursementdetailids){
|
|
|
Integer sa_tpartreimbursementdetailid = (Integer) object;
|
|
|
dbConnect.runSqlUpdate("update sa_tpartreimbursementdetail set hongbillno='' where sa_tpartreimbursementdetailid="+sa_tpartreimbursementdetailid);
|