Commit 4ca10af5 authored by kshinde's avatar kshinde

Action stock button display only Near expiry stock if ordertype "NE".

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195643 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a834e0b1
......@@ -2550,7 +2550,8 @@ public class DispatchIC extends ValidatorEJB implements DispatchICLocal,Dispatch
//if (ld_exp_date >= ld_chk_date1 && ld_exp_date <= ld_chk_date2) then // added by ajit on date 30-Jan-2015 instructed by pravin
//if ((ld_exp_date.compareTo(ld_chk_date1) > -1) && (ld_exp_date .compareTo(ld_chk_date2) < 1 ))
System.out.println("minShelfDate ["+ld_chk_date1+"] maxShelfDate["+ld_chk_date2+"]");
if (!((ld_exp_date.compareTo(ld_chk_date1) > -1) && (ld_exp_date .compareTo(ld_chk_date2) < 1 )))
//changes done by kunal on 10/1/2019
if ((ld_exp_date.compareTo(ld_chk_date1) > -1))
{
errCode = "VTNEXPDT";
errList.add(errCode);
......
......@@ -690,13 +690,72 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
//stmt = conn.createStatement(); //Changed by Pavan R 22oct18[to handle open cursor issue]
//Getting values from dom (current form), dom1(form no 1)
itemCode = genericUtility.getColumnValue("item_code",dom);
locCode = genericUtility.getColumnValue("loc_code",dom);
quantity = genericUtility.getColumnValue("quantity",dom);
siteCode = genericUtility.getColumnValue("site_code",dom1);
saleOrder = genericUtility.getColumnValue("sord_no",dom1);
mexplev = (genericUtility.getColumnValue("exp_lev", dom));
mlineno = (genericUtility.getColumnValue("line_no__sord", dom));
mlineno = " "+mlineno;
mlineno = mlineno.substring(mlineno.length()-3,mlineno.length());
despDate = genericUtility.getColumnValue("desp_date", dom1);
if( despDate != null && despDate.trim().length() > 0 )
{
despTDate = Timestamp.valueOf(genericUtility.getValidDateString(despDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+" 00:00:00.0");
}
available = "Y";
sql = " select (case when track_shelf_life is null then 'N' else track_shelf_life end) " +
" from item where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
trackShelfLife = rs.getString(1);
}
//added by kunal on on 10/1/2019 to get check Near expiry order type
sql = "Select order_type from sorder where sale_order = '"+saleOrder+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
orderType = rs.getString(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if("Y".equalsIgnoreCase(trackShelfLife.trim()))
{
sql = " select min_shelf_life,max_shelf_life " +
" from sorditem where sale_order = ? " +
" and line_no = ? and exp_lev = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
pstmt.setString(2, mlineno);
pstmt.setString(3, mexplev);
rs = pstmt.executeQuery();
if (rs.next())
{
ll_min_shelf_life = rs.getInt("min_shelf_life");
ll_max_shelf_life = rs.getInt("max_shelf_life");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("despTDate:"+despTDate+":ll_min_shelf_life:"+ll_min_shelf_life);
ld_chk_date1 = distCommon.CalcExpiry(despTDate,ll_min_shelf_life + 1);
ld_chk_date2 = distCommon.CalcExpiry(despTDate,ll_max_shelf_life);
}
System.out.println("itemCode:"+itemCode+":locCode:"+locCode+":quantity:"+quantity+":siteCode:"+siteCode+":");
if(locCode == null || locCode.trim().length() == 0)
{
......@@ -707,15 +766,34 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
locCode = locCode.trim() + "%";
}//end if
sql="SELECT (CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END) "+
" FROM ITEM WHERE ITEM_CODE ='"+itemCode+"'" ;
rs = stmt.executeQuery(sql);
" FROM ITEM WHERE ITEM_CODE = ?"; //'"+itemCode+"'" ;
//Changed and added by Pavan R 22oct18[to handle open cursor issue]
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
trackShelfLife =rs.getString(1);
}
rs.close();rs = null;
pstmt.close(); pstmt = null;
//Changed and added by Pavan R 22oct18[to handle open cursor issue] Start
sql="SELECT STOCK.ITEM_CODE,STOCK.LOT_NO, STOCK.LOT_SL,STOCK.ALLOC_QTY, STOCK.MFG_DATE, "+
" STOCK.EXP_DATE, STOCK.QUANTITY,STOCK.QUANTITY - STOCK.ALLOC_QTY AS BALANCE_QTY, " +
" STOCK.LOC_CODE,STOCK.NO_ART,STOCK.RATE "+
" FROM STOCK,INVSTAT "+
" WHERE ( STOCK.INV_STAT = INVSTAT.INV_STAT ) AND " +
" ( ( STOCK.ITEM_CODE = ? ) AND " +
" ( STOCK.LOC_CODE LIKE ? ) AND " +
" ( STOCK.SITE_CODE = ? ) AND " +
" ( STOCK.QUANTITY > 0 ) AND " +
" ( INVSTAT.AVAILABLE = ? ) AND " +
" ( INVSTAT.STAT_TYPE = 'M' ) ) " ;
if(trackShelfLife.equalsIgnoreCase("N"))
{
sql="SELECT STOCK.ITEM_CODE,STOCK.LOT_NO, STOCK.LOT_SL,STOCK.ALLOC_QTY, STOCK.MFG_DATE, "+
/*sql="SELECT STOCK.ITEM_CODE,STOCK.LOT_NO, STOCK.LOT_SL,STOCK.ALLOC_QTY, STOCK.MFG_DATE, "+
" STOCK.EXP_DATE, STOCK.QUANTITY,STOCK.QUANTITY - STOCK.ALLOC_QTY AS BALANCE_QTY, " +
" STOCK.LOC_CODE,STOCK.NO_ART,STOCK.RATE "+
" FROM STOCK,INVSTAT "+
......@@ -725,11 +803,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
" ( STOCK.SITE_CODE = '"+siteCode+"' ) AND " +
" ( STOCK.QUANTITY > 0 ) AND " +
" ( INVSTAT.AVAILABLE = '"+available+"' ) AND " +
" ( INVSTAT.STAT_TYPE = 'M' ) ) " ;
" ( INVSTAT.STAT_TYPE = 'M' ) ) " ;*/
}
else
{
sql="SELECT STOCK.ITEM_CODE,STOCK.LOT_NO, STOCK.LOT_SL,STOCK.ALLOC_QTY, STOCK.MFG_DATE, "+
/*sql="SELECT STOCK.ITEM_CODE,STOCK.LOT_NO, STOCK.LOT_SL,STOCK.ALLOC_QTY, STOCK.MFG_DATE, "+
" STOCK.EXP_DATE, STOCK.QUANTITY,STOCK.QUANTITY - STOCK.ALLOC_QTY AS BALANCE_QTY, " +
" STOCK.LOC_CODE,STOCK.NO_ART,STOCK.RATE "+
" FROM STOCK,INVSTAT "+
......@@ -739,10 +817,18 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
" ( STOCK.SITE_CODE = '"+siteCode+"' ) AND " +
" ( STOCK.QUANTITY > 0 ) AND " +
" ( INVSTAT.AVAILABLE = '"+available+"' ) AND " +
" ( INVSTAT.STAT_TYPE = 'M' ) ) ORDER BY STOCK.EXP_DATE ASC ";
" ( INVSTAT.STAT_TYPE = 'M' ) ) ORDER BY STOCK.EXP_DATE ASC ";*/
sql = sql + " ORDER BY STOCK.EXP_DATE ASC ";
}
System.out.println("Despatch:actionStock:sql:"+sql);
rs = stmt.executeQuery(sql);
//System.out.println("Despatch:actionStock:sql:"+sql);
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, locCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, available);
rs = pstmt.executeQuery();
//Changed and added by Pavan R 22oct18[to handle open cursor issue] End
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
while(rs.next())
{
......@@ -768,6 +854,10 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
stkExpDate1 = "";
}
expDate = new Timestamp(stkExpDate.getTime());
System.out.println("Inside loop expDate ["+expDate+"]");
stkquantity = rs.getString("QUANTITY");
balanceQty = rs.getString("BALANCE_QTY");
stkLocCode = rs.getString("LOC_CODE");
......@@ -777,6 +867,29 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
stkNoArt = "1";
}
stkRate =rs.getString("RATE");
if("Y".equalsIgnoreCase(trackShelfLife.trim()))
{
//added by kunal on 10/1/2019 to skip lot if expired
if(expDate == null || expDate.before(despTDate))
{
continue;
}
//added by kunal on 10/1/2019 to skip if stock not near expiry for NE
if("NE".equalsIgnoreCase(orderType.trim()))
{
if ((expDate.compareTo(ld_chk_date1) > -1))
{
continue;
}
}
//added by kunal on 10/1/2019 to skip if stock is near expiry and order type not NE
else if(!(expDate.compareTo(ld_chk_date1) > -1))
{
continue;
}
}
// 20/03/12 manoharan
if(stkItemCode == null)
{
......@@ -832,6 +945,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
valueXmlString.append("</Detail>\r\n");
}
}//end While loop
//Added by Pavan R 22oct18[to handle open cursor issue]
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("</Root>\r\n");
String retXmlString = serializeDom(genericUtility.parseString(valueXmlString.toString()));
valueXmlString = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment