|
@@ -77,7 +77,7 @@ public class sendplandetail extends Controller {
|
|
|
"\t\t\tand DATE_FORMAT(billdate, '%Y-%m-%d')<='" + sendplanRows.get(0).getString("senddate") + "'\n" +
|
|
|
"\t\t\tgroup by itemid");
|
|
|
Rows invbalrows = dbConnect.runSqlQuery("select itemid,sum(qty) qty from st_invbal t1 group by itemid");
|
|
|
- Rows sendplandetails = dbConnect.runSqlQuery("select * from sa_sendplandetail where sa_sendplanid=" + sa_sendplanid + " and siteid='" + siteid + "'");
|
|
|
+ Rows sendplandetails = dbConnect.runSqlQuery("select t1.sa_sendplandetailid,t1.sa_orderid,t2.itemid,t1.sendqty from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sa_sendplanid + " and t1.siteid='" + siteid + "'");
|
|
|
RowsMap stockbillrowsMap = stockbillrows.toRowsMap("itemid");
|
|
|
RowsMap invbalrowsMap = invbalrows.toRowsMap("itemid");
|
|
|
for (Row row : sendplandetails) {
|
|
@@ -90,7 +90,7 @@ public class sendplandetail extends Controller {
|
|
|
willoutqty = stockbillrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
|
|
|
}
|
|
|
if (invbalrowsMap.containsKey(row.getString("itemid"))) {
|
|
|
- invbalqty = stockbillrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
|
|
|
+ invbalqty = invbalrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
|
|
|
}
|
|
|
canuseqty = invbalqty.subtract(willoutqty);
|
|
|
updateSQL.setValue("willoutqty", willoutqty);
|