Commit cf78d311 authored by cpatil's avatar cpatil

adding pickrate()


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91961 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1b280add
...@@ -1657,7 +1657,7 @@ public class DistCommon ...@@ -1657,7 +1657,7 @@ public class DistCommon
pstmt.close(); // 22/06/09 manoharan pstmt.close(); // 22/06/09 manoharan
rs3 = null; // 22/06/09 manoharan rs3 = null; // 22/06/09 manoharan
pstmt = null; // 22/06/09 manoharan pstmt = null; // 22/06/09 manoharan
} }
else else
{ {
rs3.close(); // 22/06/09 manoharan rs3.close(); // 22/06/09 manoharan
...@@ -2057,6 +2057,8 @@ public class DistCommon ...@@ -2057,6 +2057,8 @@ public class DistCommon
} }
return returnList; return returnList;
}//getTokenList() }//getTokenList()
public double pickRate(String priceList,String trDate,String itemCode,String aLotNo,String listType,double quantity,String aunit,Connection conn)throws ITMException public double pickRate(String priceList,String trDate,String itemCode,String aLotNo,String listType,double quantity,String aunit,Connection conn)throws ITMException
{ {
//System.out.println("--------------[pickRate]---------------------------------"); //System.out.println("--------------[pickRate]---------------------------------");
...@@ -6372,7 +6374,7 @@ public class DistCommon ...@@ -6372,7 +6374,7 @@ public class DistCommon
} // end getNoart() } // end getNoart()
//end added by alam on 020209 //end added by alam on 020209
/* /*
public int getNoArt(String siteCode,String custCode,String itemCode , String packCode, int acQty , char type , double acShipperQty , double acIntegralQty , Connection conn) // Added by Manazir public int getNoArt(String siteCode,String custCode,String itemCode , String packCode, int acQty , char type , double acShipperQty , double acIntegralQty , Connection conn) // Added by Manazir
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -7257,9 +7259,9 @@ public class DistCommon ...@@ -7257,9 +7259,9 @@ public class DistCommon
return ""; return "";
} }
// migration of method getTacClass on 07/05/09 // migration of method getTacClass on 07/05/09
public String getTaxClass(String supOrCust ,String suppCode, String itemCode, String siteCodeShip , Connection conn )throws ITMException public String getTaxClass(String supOrCust ,String suppCode, String itemCode, String siteCodeShip , Connection conn )throws ITMException
{ {
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs= null; ResultSet rs= null;
String sql="",taxClass=""; String sql="",taxClass="";
...@@ -7388,13 +7390,13 @@ public String getTaxClass(String supOrCust ,String suppCode, String itemCode, St ...@@ -7388,13 +7390,13 @@ public String getTaxClass(String supOrCust ,String suppCode, String itemCode, St
throw new ITMException(e); throw new ITMException(e);
} }
return taxClass ; return taxClass ;
} }
// end of code // end of code
//migration of method getTaxEnv() on 07/05/09 //migration of method getTaxEnv() on 07/05/09
// getTaxENV // getTaxENV
public String getTaxEnv(String stationFrom ,String stationTo, String taxChap, String taxClass,String siteCodeShip, Connection conn )throws ITMException public String getTaxEnv(String stationFrom ,String stationTo, String taxChap, String taxClass,String siteCodeShip, Connection conn )throws ITMException
{ {
SimpleDateFormat sdf=null; SimpleDateFormat sdf=null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs= null; ResultSet rs= null;
...@@ -7670,15 +7672,15 @@ public String getTaxEnv(String stationFrom ,String stationTo, String taxChap, St ...@@ -7670,15 +7672,15 @@ public String getTaxEnv(String stationFrom ,String stationTo, String taxChap, St
throw new ITMException(e); throw new ITMException(e);
} }
return taxEnv ; return taxEnv ;
} }
// end of code // end of code
// migration of method getCheckTaxEnvStatus() on 07/05/09 // migration of method getCheckTaxEnvStatus() on 07/05/09
public String getCheckTaxEnvStatus(String taxEnv,Timestamp currDateTs,Connection conn )throws ITMException public String getCheckTaxEnvStatus(String taxEnv,Timestamp currDateTs,Connection conn )throws ITMException
{ {
String errorResturn = "",status=""; String errorResturn = "",status="";
String sql=""; String sql="";
PreparedStatement pstmt =null; PreparedStatement pstmt =null;
...@@ -7714,14 +7716,14 @@ public String getCheckTaxEnvStatus(String taxEnv,Timestamp currDateTs,Connection ...@@ -7714,14 +7716,14 @@ public String getCheckTaxEnvStatus(String taxEnv,Timestamp currDateTs,Connection
throw new ITMException(e); throw new ITMException(e);
} }
return errorResturn ; return errorResturn ;
} }
// end of code // end of code
//migration of method getTaxChap() on 07/05/09 //migration of method getTaxChap() on 07/05/09
//get taxchap //get taxchap
public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,String custCode,String siteCodeShip ,Connection conn )throws ITMException public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,String custCode,String siteCodeShip ,Connection conn )throws ITMException
{ {
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs= null; ResultSet rs= null;
String sql="",taxClass="",taxChap=""; String sql="",taxClass="",taxChap="";
...@@ -7857,7 +7859,7 @@ public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,S ...@@ -7857,7 +7859,7 @@ public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,S
throw new ITMException(e); throw new ITMException(e);
} }
return taxChap ; return taxChap ;
} }
public java.sql.Timestamp CalcExpiry(java.sql.Timestamp date, double shelfLife) throws Exception public java.sql.Timestamp CalcExpiry(java.sql.Timestamp date, double shelfLife) throws Exception
{ {
UtilMethods utilMethods = UtilMethods.getInstance(); UtilMethods utilMethods = UtilMethods.getInstance();
...@@ -7876,4 +7878,1826 @@ public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,S ...@@ -7876,4 +7878,1826 @@ public String getTaxChap(String itemCode,String itemSer, String suppOrCustCode,S
return expDate; return expDate;
} }
// added by cpatil on 10/oct/12 start
public double pickRate(String priceList,String trDate,String itemCode,String aLotNo,Connection conn)throws ITMException,SQLException
{
System.out.println("@@@@@--------------[pickRate]--[(String priceList,String trDate,String itemCode,String aLotNo,Connection conn)]-called------------------------------");
//System.out.println("DP[priceList/trDate/itemCode/tranType/aLotNo/listType/conn]");
//if(priceList!=null)
System.out.println("Price List:-["+priceList+"]");
//if(trDate!=null)
//System.out.println("Tran Date:-["+trDate+"]");
//if(itemCode!=null)
//System.out.println("Item Code:-["+itemCode+"]");
//if(aLotNo!=null)
//System.out.println("Lot No:-["+aLotNo+"]");
//if(listType!=null)
//System.out.println("List Type:-["+listType+"]");
//if(conn!=null)
//System.out.println("Connection Found["+conn+"]");
//System.out.println("-----------------------------------------------");
PreparedStatement pstmt = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;
java.sql.Timestamp tranDate = null;
String sql = "";
String priceListParent = "";
String siteCode = "";
String locCode = "";
String lotNo = "";
String lotSl = "";
String listType = "";
double rate = 0.0;
//type = getPriceListType(priceList,conn);
//System.out.println("List Type From Price List:::["+type+"]");
try
{
sql = " select list_type from pricelist_mst where price_list = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList);
rs = pstmt.executeQuery();
if (rs.next())
{
listType = rs.getString("list_type");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
trDate = genericUtility.getValidDateString(trDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(trDate + " 00:00:00");
//System.out.println("Date in pickRate...."+tranDate);
if(listType.equalsIgnoreCase("I")) // replace listType instead of list by cpatil on 10-oct-12
{
if (aLotNo.indexOf("~t") > 0)
{
String MulStr[] = aLotNo.split("~t");
siteCode = MulStr[0];
locCode = MulStr[1];
lotNo = MulStr[2];
lotSl = MulStr[3];
//System.out.println("siteCode..**..*>"+siteCode);
//System.out.println("locCode..**..*>"+locCode);
//System.out.println("lotNo..**..*>"+lotNo);
//System.out.println("lotSl..**..*>"+lotSl);
}
}
else
{
lotNo = aLotNo;
//System.out.println("lotNo..**..*>"+lotNo);
}
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
}
if(listType.trim().equals("L")) // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
System.out.println("Inside type ::-<L>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
//System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (L) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1) == null ?"":rs.getString(1);
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 =null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 =null;
pstmt = null;
return -1;
}
if(rate > 0)
{
priceList = priceListParent ;
//break ;
}
else
{
priceList = priceListParent ;
priceListParent = "";
}
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
// end of code
}
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("L"))
if(listType.trim().equals("F")) // replace listType instead of list by cpatil on 10-oct-12
{
System.out.println("Inside type ::-<F>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
//System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
try
{//try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
//System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
return -1;
}
}//try 3
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("F"))
if(listType.trim().equals("D")) //DISPATCH // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (L) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{//else if 1
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)//1
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{//else if 2
try
{//try 4
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND LOT_NO__FROM <= '"+lotNo+"' "
+ "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
rate = rs2.getDouble(1);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{//else if 3
//rs2.close();
try
{//try 5
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'B'";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
priceListParent = rs2.getString(1);
//System.out.println("The priceListParent for <D> is .... "+priceListParent);
}
rs2.close();
pstmt.close(); // 22/06/09 manoharan
rs2 = null; // 22/06/09 manoharan
pstmt = null; // 22/06/09 manoharan
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)//2
{
try
{//try 6
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND LOT_NO__FROM <= '"+lotNo+"' "
+ "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs3 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs3.next())
{
rate = rs3.getDouble(1);
//System.out.println("The rate inside priceListParent for <D> is ..."+rate);
rs3.close();
pstmt.close();
rs3 = null;
pstmt = null;
}
else
{
rs3.close();
pstmt.close();
rs3 = null;
pstmt = null;
return -1;
}
}//try 6
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(priceListParent.trim().length() > 0)2
}//try 5
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 3
//rs2.close();
}//try 4
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 2
//rs2.close();
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(priceListParent.trim().length() > 0)//1
}//try 2
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 1
if(rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.clearParameters();
pstmt.close();
pstmt = null;
}
}//try 1
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("D"))
if(listType.trim().equals("B"))//BATCH PRICE // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND LOT_NO__FROM <= '"+lotNo+"' "
+ "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate inside priceListParent for <B> is ..."+rate);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
try
{ //try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'B'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//return -1;
}
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND LOT_NO__FROM <= '"+lotNo+"' "
+ "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
//System.out.println("The rate inside priceListParent for <B> is ..."+rate);
}
else
{
//rate = rs2.getDouble(1);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
return -1;
}
if(rate > 0)
{
priceList = priceListParent ;
//break ;
}
else
{
priceList = priceListParent ;
priceListParent = "";
}
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}// end of loop
//rs.close();
}//try 2
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
//rs.close();
}//try 1
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("B"))//BATCH PRICE
//type = listType; // replace listType instead of list by cpatil on 10-oct-12
if((listType.trim().equals("M")) || (listType.trim().equals("N"))) // Discount PRICE // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
System.out.println("Inside type ::-<M><N>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? " // replace listType instead of list by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (F) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = '"+type.trim()+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
//System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)
{
//type = getPriceListType(priceList,conn); // commented by cpatil on 10-oct-12
sql = "SELECT LIST_TYPE FROM PRICELIST_MST WHERE PRICE_LIST = '"+priceListParent+"' ";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
listType = rs2.getString(1);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? " // replace listType instead of list by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
return -1;
}
}//try 3
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
//rs.close();
//pstmt.clearParameters();
//pstmt.close();
//pstmt = null;
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if((type.trim().equals("M")) || (type.trim().equals("N")))
if(listType.trim().equals("I")) //Inventory // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
if ((lotSl == null) || (lotSl.trim().length() == 0))
{
System.out.println("Inside type ::-<I>-::");
try
{//try 1
sql = "SELECT RATE FROM STOCK "
+ "WHERE ITEM_CODE = '"+itemCode+"' "
+ "AND SITE_CODE = '"+siteCode+"' "
+ "AND LOC_CODE = '"+locCode+"' "
+ "AND LOT_NO = '"+lotNo+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
System.out.println("Rate is .*...."+rate);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
else
{
try
{//try 1
sql = "SELECT RATE FROM STOCK "
+ "WHERE ITEM_CODE = '"+itemCode+"' "
+ "AND SITE_CODE = '"+siteCode+"' "
+ "AND LOC_CODE = '"+locCode+"' "
+ "AND LOT_NO = '"+lotNo+"' "
+ "AND LOT_SL = '"+lotSl+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
//System.out.println("Rate is .*...."+rate);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
}//if(type.trim().equals("I")) //Inventory
//System.out.println("Rate From DisCommon***:::::["+rate+"]");
return(rate);
}
public double pickRate(String priceList,String trDate,String itemCode,Connection conn)throws ITMException,SQLException
{
System.out.println("@@@@@--------------[pickRate]--[(String priceList,String trDate,String itemCode,Connection conn)]-called------------------------------");
//System.out.println("DP[priceList/trDate/itemCode/tranType/aLotNo/listType/conn]");
//if(priceList!=null)
System.out.println("Price List:-["+priceList+"]");
//if(trDate!=null)
System.out.println("Tran Date:-["+trDate+"]");
//if(itemCode!=null)
System.out.println("Item Code:-["+itemCode+"]");
//if(conn!=null)
//System.out.println("Connection Found["+conn+"]");
//System.out.println("-----------------------------------------------");
PreparedStatement pstmt = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;
java.sql.Timestamp tranDate = null;
String sql = "";
String priceListParent = "";
String siteCode = "";
String locCode = "";
//String lotNo = "";
String lotSl = "";
String listType = "";
double rate = 0.0;
//type = getPriceListType(priceList,conn);
//System.out.println("List Type From Price List:::["+type+"]");
try
{
sql = " select list_type from pricelist_mst where price_list = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList);
rs = pstmt.executeQuery();
if (rs.next())
{
listType = rs.getString("list_type");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("List Type:-["+listType+"]");
trDate = genericUtility.getValidDateString(trDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(trDate + " 00:00:00");
//System.out.println("Date in pickRate...."+tranDate);
/*
if(listType.equalsIgnoreCase("I")) // replace listType instead of list by cpatil on 10-oct-12
{
if (aLotNo.indexOf("~t") > 0)
{
String MulStr[] = aLotNo.split("~t");
siteCode = MulStr[0];
locCode = MulStr[1];
lotNo = MulStr[2];
lotSl = MulStr[3];
//System.out.println("siteCode..**..*>"+siteCode);
//System.out.println("locCode..**..*>"+locCode);
//System.out.println("lotNo..**..*>"+lotNo);
//System.out.println("lotSl..**..*>"+lotSl);
}
}
else
{
lotNo = aLotNo;
//System.out.println("lotNo..**..*>"+lotNo);
}
*/
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
}
if(listType.trim().equals("L")) // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
System.out.println("Inside type ::-<L>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
//System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (L) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1) == null ?"":rs.getString(1);
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 =null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 =null;
pstmt = null;
return -1;
}
if(rate > 0)
{
priceList = priceListParent ;
//break ;
}
else
{
priceList = priceListParent ;
priceListParent = "";
}
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
// end of code
}
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
//pstmt.clearParameters();
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("L"))
if(listType.trim().equals("F")) // replace listType instead of list by cpatil on 10-oct-12
{
System.out.println("Inside type ::-<F>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
//System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (F) is.... "+rate);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
try
{//try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
//System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
return -1;
}
}//try 3
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
if (rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.close();
pstmt = null;
}
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("F"))
if(listType.trim().equals("D")) //DISPATCH // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
//System.out.println("Inside type ::-<D>-::");
//First selecting rate from pricelist for L,if not found
//picking up from batch
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (L) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{//else if 1
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)//1
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{//else if 2
try
{//try 4
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
// + "AND LOT_NO__FROM <= '"+lotNo+"' " //commented by cpatil on 10-oct-12
// + "AND LOT_NO__TO >= '"+lotNo+"' " //commented by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
rate = rs2.getDouble(1);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
//System.out.println("The rate inside priceListParent for <D> is ..."+rate);
}
else
{//else if 3
//rs2.close();
try
{//try 5
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'B'";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
priceListParent = rs2.getString(1);
//System.out.println("The priceListParent for <D> is .... "+priceListParent);
}
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)//2
{
try
{//try 6
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
//+ "AND LOT_NO__FROM <= '"+lotNo+"' " //commented by cpatil on 10-oct-12
//+ "AND LOT_NO__TO >= '"+lotNo+"' " //commented by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs3 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs3.next())
{
rate = rs3.getDouble(1);
//System.out.println("The rate inside priceListParent for <D> is ..."+rate);
rs3.close();
pstmt.close();
rs3 = null;
pstmt = null;
}
else
{
rs3.close();
pstmt.close();
rs3 = null;
pstmt = null;
return -1;
}
}//try 6
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(priceListParent.trim().length() > 0)2
}//try 5
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 3
//rs2.close();
}//try 4
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 2
//rs2.close();
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(priceListParent.trim().length() > 0)//1
}//try 2
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else if 1
if(rs != null && !rs.isClosed())
{
rs.close();
rs = null;
}
if (pstmt != null && !pstmt.isClosed())
{
pstmt.clearParameters();
pstmt.close();
pstmt = null;
}
}//try 1
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("D"))
if(listType.trim().equals("B"))//BATCH PRICE // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
//+ "AND LOT_NO__FROM <= '"+lotNo+"' " //commented by cpatil on 10-oct-12
//+ "AND LOT_NO__TO >= '"+lotNo+"' " //commented by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
rate = rs.getDouble(1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
try
{ //try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = 'B'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//return -1;
}
if(priceListParent.trim().length() > 0)
{
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? "
//+ "AND LOT_NO__FROM <= '"+lotNo+"' " //commented by cpatil on 10-oct-12
//+ "AND LOT_NO__TO >= '"+lotNo+"' " //commented by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
//System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
//System.out.println("The rate inside priceListParent for <B> is ..."+rate);
}
else
{
//rate = rs2.getDouble(1);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
return -1;
}
if(rate > 0)
{
priceList = priceListParent ;
//break ;
}
else
{
priceList = priceListParent ;
priceListParent = "";
}
}//try 3
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}// end of loop
//rs.close();
}//try 2
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
//rs.close();
}//try 1
catch(Exception e)
{
//System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if(type.trim().equals("B"))//BATCH PRICE
//type = listType; // replace listType instead of list by cpatil on 10-oct-12
if((listType.trim().equals("M")) || (listType.trim().equals("N"))) // Discount PRICE // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
System.out.println("Inside type ::-<M><N>-::");
try
{//try 1
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceList+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? " // replace listType instead of list by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs = pstmt.executeQuery();
System.out.println("Rate sql ..."+sql);
if(rs.next())
{
rate = rs.getDouble(1);
//System.out.println("The rate for type (F) is.... "+rate);
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
else
{
try
{//try 2
rs.close();
pstmt.close();
rs = null;
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"+priceList+"' ";
//+ "AND LIST_TYPE = '"+type.trim()+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
//System.out.println("The priceListParent is .... "+priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
//System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if(priceListParent.trim().length() > 0)
{
//type = getPriceListType(priceList,conn); // commented by cpatil on 10-oct-12
sql = "SELECT LIST_TYPE FROM PRICELIST_MST WHERE PRICE_LIST = '"+priceListParent+"' ";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if(rs2.next())
{
listType = rs2.getString(1);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
try
{//try 3
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"+priceListParent+"' "
+ "AND ITEM_CODE = '"+itemCode+"' "
+ "AND LIST_TYPE = ? " // replace listType instead of list by cpatil on 10-oct-12
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setTimestamp(2,tranDate);
pstmt.setTimestamp(3,tranDate);
rs2 = pstmt.executeQuery();
System.out.println("The priceListParent sql .. "+sql);
if(rs2.next())
{
rate = rs2.getDouble(1);
//System.out.println("The rate inside priceListParent is ..."+rate);
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
}
else
{
rs2.close();
pstmt.close();
rs2 = null;
pstmt = null;
return -1;
}
}//try 3
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
}//try 2
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
//rs.close();
//pstmt.clearParameters();
//pstmt.close();
//pstmt = null;
}//try 1
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if((type.trim().equals("M")) || (type.trim().equals("N")))
if(listType.trim().equals("I")) //Inventory // replace listType instead of list by cpatil on 10-oct-12
{
rate = 0;
if ((lotSl == null) || (lotSl.trim().length() == 0))
{
System.out.println("Inside type ::-<I>-::");
try
{//try 1
sql = "SELECT RATE FROM STOCK "
+ "WHERE ITEM_CODE = '"+itemCode+"' "
+ "AND SITE_CODE = '"+siteCode+"' "
+ "AND LOC_CODE = '"+locCode+"' ";
//+ "AND LOT_NO = '"+lotNo+"'"; //commented by cpatil on 10-oct-12
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
System.out.println("Rate is .*...."+rate);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//if
else
{
try
{//try 1
sql = "SELECT RATE FROM STOCK "
+ "WHERE ITEM_CODE = '"+itemCode+"' "
+ "AND SITE_CODE = '"+siteCode+"' "
+ "AND LOC_CODE = '"+locCode+"' "
//+ "AND LOT_NO = '"+lotNo+"' " //commented by cpatil on 10-oct-12
+ "AND LOT_SL = '"+lotSl+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
//System.out.println("Rate is .*...."+rate);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}//try
catch(Exception e)
{
System.out.println("Exception...[pickRate] "+sql+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}//else
}//if(type.trim().equals("I")) //Inventory
//System.out.println("Rate From DisCommon***:::::["+rate+"]");
return(rate);
}
// added by cpatil on 10/oct/12 end
}//class }//class
\ No newline at end of file
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