|
@@ -285,21 +285,33 @@ public class dispatchItems extends Controller {
|
|
|
sqlFactory1.addParameter("siteid", siteid);
|
|
|
sqlFactory1.addParameter_in("itemno", rows.toArrayList("itemno", new ArrayList<>()));
|
|
|
Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
if(!siteid.equalsIgnoreCase("lsa")){
|
|
|
- for(Row row : sumQtyRows){
|
|
|
+ for(Row row : rows){
|
|
|
if(StringUtils.isNotBlank(row.getString("batchno"))){
|
|
|
JSONArray jsonArray1 =new JSONArray();
|
|
|
jsonArray1.add(row.getString("itemno"));
|
|
|
JSONArray jsonArrayBatch = erpDocking.getErpIcinvbalBatchRowsforbatchno(20000, 1, jsonArray1,row.getString("batchno"));
|
|
|
if(!jsonArrayBatch.isEmpty()){
|
|
|
- row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty").subtract(row.getBigDecimal("qty")));
|
|
|
+ if(sumQtyRowsMap.containsKey(row.getString("itemno"))){
|
|
|
+ for(Row row1 :sumQtyRowsMap.get(row.getString("itemno"))){
|
|
|
+ if(row.getString("batchno").equals(row1.getString("batchno"))){
|
|
|
+ row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty").subtract(row1.getBigDecimal("qty")));
|
|
|
+ row.put("invbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
|
|
|
+ row.put("invbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
|
|
|
+ }
|
|
|
}else{
|
|
|
row.put("delinvbalqty", row.getBigDecimal("qty").negate());
|
|
|
+ row.put("invbalqty", 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+
|
|
|
|
|
|
if (!jsonArray.isEmpty()) {
|
|
|
for (Object obj : jsonArray) {
|
|
@@ -341,7 +353,12 @@ public class dispatchItems extends Controller {
|
|
|
if(siteid.equalsIgnoreCase("lsa")){
|
|
|
rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("FQty"));
|
|
|
}else{
|
|
|
- rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
+ for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
|
|
|
+ if(StringUtils.isBlank(row.getString("batchno"))){
|
|
|
+ row.put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
}
|
|
|
|
|
|
}
|