Commit 1a66b2d5 authored by rzore's avatar rzore

changes made for getting rate slab no wise

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@200252 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d9c2d530
......@@ -10922,16 +10922,31 @@ public class DistCommon {
{
rate = 0;
try {// try 1
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'B'" + " and ref_no ='" + lsRefNo
+ "' " + "AND MIN_QTY <= " + quantity + " "
+ "AND MAX_QTY >= " + quantity + " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
if(lsRefNo == null || lsRefNo.trim().length() == 0)
{
String slabNo = getMaxSlabNo(priceList, tempDate, itemCode, lsRefNo, listType,quantity, conn);
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'B'" + " and slab_no ='" + slabNo
+ "' " + "AND MIN_QTY <= " + quantity + " "
+ "AND MAX_QTY >= " + quantity + " "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
}
else
{
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'B'" + " and ref_no ='" + lsRefNo
+ "' " + "AND MIN_QTY <= " + quantity + " "
+ "AND MAX_QTY >= " + quantity + " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
}
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
......@@ -10970,28 +10985,55 @@ public class DistCommon {
}
if (priceListParent.trim().length() > 0) {
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and ref_no ='"
+ lsRefNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
if(lsRefNo == null || lsRefNo.trim().length() == 0)
{
String slabNo = getMaxSlabNo(priceList, tempDate, itemCode, lsRefNo, listType,quantity, conn);
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and slab_no ='"
+ slabNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
}
else
{
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and ref_no ='"
+ lsRefNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
}
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
......@@ -12252,4 +12294,61 @@ public class DistCommon {
}
//Added by Anjali R. on[13/04/2018][To parse string value into double][End]
private String getMaxSlabNo(String priceList, String trDate, String itemCode, String aRefNo, String listType, double quantity, Connection conn)
throws Exception
{
String slabNumber = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String lsUnit = "";
sql = "select unit from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
lsUnit = rs.getString("unit");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select max(slab_no) from pricelist where price_list = ? and item_code= ? and unit= ? and list_type= ? and eff_from <= ? and valid_upto >= ? and min_qty <= ? and max_qty >= ? and (slab_no is not null)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceList);
pstmt.setString(2, itemCode);
pstmt.setString(3, lsUnit);
pstmt.setString(4, listType);
pstmt.setTimestamp(5, Timestamp.valueOf(genericUtility.getValidDateTimeString(trDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())));
pstmt.setTimestamp(6, Timestamp.valueOf(genericUtility.getValidDateTimeString(trDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())));
pstmt.setDouble(7, quantity);
pstmt.setDouble(8, quantity);
rs = pstmt.executeQuery();
if (rs.next())
{
slabNumber = checkNull(rs.getString(1));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
System.out.println("PriceListGenEJB.getDoubleValue()[" + e.getMessage() + "]");
throw e;
}
return slabNumber;
}
}// class
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