Commit 6f121437 authored by pshinde's avatar pshinde

Contract no added in Sales return Form,pricelist and rate should set from contract no


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98135 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d88b8dfb
......@@ -200,6 +200,11 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
SimpleDateFormat simpleDateFormat = null;
int months = 0;
java.util.Date defaultExpDate = null;
String contractNo="";//added by priyanka on 15/06/15
double contractRate = 0.0;
Timestamp trDate = null;
try
{
ITMDBAccessEJB dbEjb = new ITMDBAccessEJB();
......@@ -712,6 +717,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
} */
//reStr = itemChanged(dom, dom1, dom2, objContext, "ret_opt", editFlag, xtraParams);//comment added by sagar on 05/08/14
//Added by sagar on 05/08/14 start
valueXmlString.append("<cust_code__dlv>").append("<![CDATA[" + getAbsString( custCode ) + "]]>").append("</cust_code__dlv>");
setNodeValue( dom, "cust_code__dlv", getAbsString( custCode ) );
reStr = itemChanged(dom, dom1, dom2, objContext, "cust_code__dlv", editFlag, xtraParams);
......@@ -785,12 +791,15 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
}
else if (currentColumn.trim().equals("ret_opt") )
{
System.out.println("ret_opt itemchanged@@@@@@@@");
retOpt = genericUtility.getColumnValue("ret_opt",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
priceList = "";
sql = " select price_list from site_customer where cust_code = ? and site_code = ?";
//commented by priyanka on 23/06/15
/*sql = " select price_list from site_customer where cust_code = ? and site_code = ?";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, custCode );
pstmt.setString( 2, siteCode );
......@@ -818,7 +827,12 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
pstmt.close();
pstmt = null;
rs = null;
}
}*/ //commented end on 23/06/15
//pricelist should set from below function
//Added by priyanka on 23/06/15 as per manoj sharma instruction
priceList = getPriceLstVal(custCode, custCodeDlv, siteCode, contractNo, conn);
System.out.println("Getting Price List from ret_opt=====" + priceList);
retOpt = retOpt == null ?"" : retOpt.trim();
if ("R".equals(retOpt) || "D".equals(retOpt) )
{
......@@ -834,6 +848,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
}
else if (currentColumn.trim().equals("cust_code__dlv")) //condition added by sagar on 05/08/14
{
System.out.println("Cust Code Dlv itemChanged called********");
custCodeDlv = genericUtility.getColumnValue("cust_code__dlv",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
......@@ -854,8 +869,8 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
valueXmlString.append("<cust_name_dlv>").append("<![CDATA[" + getAbsString( custNameDlv ) + "]]>").append("</cust_name_dlv>");
setNodeValue( dom, "cust_name_dlv", getAbsString( custNameDlv ) );
priceList = "";
sql = " select price_list from site_customer where cust_code = ? and site_code = ?";
priceList = "";//comment start
/*sql = " select price_list from site_customer where cust_code = ? and site_code = ?";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, custCode);
pstmt.setString( 2, siteCode);
......@@ -917,7 +932,17 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
}
//check price list value for customer code delivery... on 14/08/14 end
}
valueXmlString.append("<price_list>").append("<![CDATA[" + getAbsString(priceList) + "]]>").append("</price_list>");*///comment end
//price list should set from contract no if contract no is entered else follow the existing hierachy
contractNo = genericUtility.getColumnValue("contract_no", dom);
System.out.println(">>>>>>>>>>>>>contract no===========" + contractNo);
priceList = getPriceLstVal(custCode, custCodeDlv, siteCode, contractNo, conn);
System.out.println("Getting Price List======" + priceList);
valueXmlString.append("<price_list>").append("<![CDATA[" + getAbsString(priceList) + "]]>").append("</price_list>");
//Price List Clg value set on cust_code_dlv item change instead of cust_code, added by sagar on 19/08/14....
priceListClg = distCommon.getDisparams("999999","PRICE_LIST__CLG",conn);
if((priceListClg == null) || (priceListClg.trim().length() == 0))
......@@ -992,6 +1017,26 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
setNodeValue( dom, "price_list__clg", getAbsString( priceListClg ) );
}
}
//added by priyanka on 15/06/15 for contract no
//price list should set from contract no if contract no is entered else follow the existing hierachy
else if (currentColumn.trim().equalsIgnoreCase("contract_no"))
{
custCode = genericUtility.getColumnValue("cust_code", dom);
siteCode = genericUtility.getColumnValue("site_code", dom);
contractNo = genericUtility.getColumnValue("contract_no", dom);
custCodeDlv = genericUtility.getColumnValue("cust_code__dlv", dom);
System.out.println("@@@@ custCode[" + custCode + "]");
System.out.println("@@@@ siteCode[" + siteCode + "]");
System.out.println("@@@@ contractNo[" + contractNo + "]");
System.out.println("@@@@ custCodeDlv[" + custCodeDlv + "]");
priceList = getPriceLstVal(custCode, custCodeDlv, siteCode, contractNo, conn);
System.out.println("Getting Price List from contract_number=====" + priceList);
valueXmlString.append("<price_list>").append("<![CDATA[" + priceList + "]]>").append("</price_list>");
}
valueXmlString.append("</Detail1>");
break;
......@@ -1232,7 +1277,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
custCode = genericUtility.getColumnValue("cust_code",dom1);
//priceList = genericUtility.getColumnValue("price_list",dom1); //comment added by sagar on 18/08/14..
sRate = genericUtility.getColumnValue( "rate", dom );
System.out.println("rate--==========="+rate);
itemSer = distCommon.getItemSer(itemCode,siteCode,Timestamp.valueOf(genericUtility.getValidDateString(tranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"),custCode,"C",conn);
valueXmlString.append("<item_ser>").append("<![CDATA[" + itemSer + "]]>").append("</item_ser>");
sql =" select descr, unit, unit__rate, item_stru, pack_instr from item where item_code = ?";
......@@ -1378,14 +1423,82 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
}
}
//added by priyanka
//if contract no is defined set rate based on contract no else follow existing hierachy
trDate= Timestamp.valueOf(genericUtility.getValidDateString(tranDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println(">>>>>>>>>Tran Date:"+trDate);
contractNo = genericUtility.getColumnValue("contract_no", dom1);
System.out.println("Getting Contract No======"+contractNo);
if (contractNo != null && contractNo.trim().length() > 0)
{
sql = "select rate from scontractdet where contract_no= ? and item_code=? and ? between eff_from and valid_upto";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, contractNo);
pstmt1.setString(2, itemCode);
pstmt1.setTimestamp(3, new java.sql.Timestamp(trDate.getTime()));
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
contractRate = rs1.getDouble("rate");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("contractRate====" + contractRate);
if(contractRate==0)
{
priceList=getPriceList(dom1,dom,conn);//Getting PriceList Value, method added by sagar on 19/08/14..
System.out.println(">>>>>>>>>>Check priceList in item_code:"+priceList);
if (priceList == null || priceList.trim().length() == 0)
}
else
{
valueXmlString.append("<rate protect =\"0\">").append("<![CDATA["+ (sRate == null || sRate.trim().length() == 0 ? "0" : sRate ) + "]]>").append("</rate>");
setNodeValue( dom, "rate", sRate );
mrate = Double.parseDouble( sRate );
rate=contractRate;
}
}
else
{
priceList=getPriceList(dom1,dom,conn);//Getting PriceList Value, method added by sagar on 19/08/14..
}
//priceList=getPriceList(dom1,dom,conn);//Getting PriceList Value, method added by sagar on 19/08/14..
System.out.println(">>>>>>>>>>Check contract rate=====:"+contractRate);
System.out.println(">>>>>>>>>>Check priceList >>>>>>>>"+priceList);
System.out.println("Setting rate===="+rate);
//if (priceList == null || priceList.trim().length() == 0)
//{
//added by priyanka on 23/06/15
//rate should set based on contract no,if rate define in scontractdet then set rate from scontractdet else set rate based on pricelist defined for entered contractno in scontract
System.out.println("Price List for pickrate==="+priceList);
if (contractNo != null && contractNo.trim().length() > 0)
{
System.out.println("Getting contractRate======="+contractRate);
if(contractRate!=0)
{
System.out.println("rate=====*****"+rate);
//valueXmlString.append("<rate protect =\"0\">").append("<![CDATA["+ (sRate == null || sRate.trim().length() == 0 ? "0" : sRate ) + "]]>").append("</rate>");
valueXmlString.append("<rate protect =\"0\">").append("<![CDATA["+ rate+ "]]>").append("</rate>");
}
else
{
System.out.println("Rate from contract pricelist");
rate = distCommon.pickRate(priceList,tranDate,itemCode," ","L",qtyStdUom, conn);
valueXmlString.append("<rate protect =\"0\">").append("<![CDATA["+ rate+ "]]>").append("</rate>");
}
//added now to test
System.out.println("Final Rate from contract====="+rate);
setNodeValue( dom, "rate", rate );
//mrate = Double.parseDouble( rate );
mrate=rate;
System.out.println("Mrate======="+mrate);
//added by kunal on 10/oct/13 set rate con. FOR issue tracker point 157-N
if (unitRate != null && !unitRate.trim().equals(unit.trim()))
......@@ -1423,11 +1536,17 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
pos = reStr.indexOf("</Detail2>");
reStr = reStr.substring(0,pos);
valueXmlString.append(reStr);
}
else
{
System.out.println("contract no is null");
tranDate = tranDate == null ? ( new Timestamp( System.currentTimeMillis() ) ).toString() : tranDate;
System.out.println("Getting rate if pricelist is not null===="+rate);
rate = distCommon.pickRate(priceList,tranDate,itemCode," ","L",qtyStdUom, conn);
System.out.println(">>>>>>>>>>Check rate in item_code:"+rate);
varValue = distCommon.getPriceListType(priceList,conn);
varValue = varValue == null ?"" : varValue.trim();
......@@ -1521,6 +1640,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
valueXmlString.append(reStr);
}
}
//}//added at 2.14
/* comment by kunal on 20/AUG/13
varValue = genericUtility.getColumnValue("conv__rtuom_stduom", dom);
varValue = varValue == null ?"0" : varValue.trim();
......@@ -6771,7 +6891,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
ResultSet rs2 = null, rs1 = null ;
String sql2="";
Timestamp trDate = null;
String custCode="",custCodeDlv="",tranDate="",siteCode="",itemCode="",priceList="";
String custCode="",custCodeDlv="",tranDate="",siteCode="",itemCode="",priceList="",contractNo="";
try
{
......@@ -6781,13 +6901,46 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
tranDate = genericUtility.getColumnValue("tran_date", dom1);
siteCode = genericUtility.getColumnValue("site_code",dom1);
itemCode = genericUtility.getColumnValue("item_code",dom);
contractNo = genericUtility.getColumnValue("contract_no",dom1);//added by priyanka
System.out.println(">>>>>>>>>>>custCode:"+custCode);
System.out.println(">>>>>>>>>>>custCodeDlv:"+custCodeDlv);
System.out.println(">>>>>>>>>>>tranDate:"+tranDate);
System.out.println(">>>>>>>>>>>siteCode:"+siteCode);
System.out.println(">>>>>>>>>>>itemCode:"+itemCode);
System.out.println(">>>>>>>>>>>contractNo:"+contractNo);
trDate= Timestamp.valueOf(genericUtility.getValidDateString(tranDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println(">>>>>>>>>Tran Date:"+tranDate);
System.out.println(">>>>>>>>>Tran Date:"+trDate);
//condition added by priyanka on 17/06/15
//if contract is entered and price list is defined against entered contract no then set pricelist based on contract no,else follow existing hierachy
if (contractNo != null && contractNo.trim().length() > 0)
{
System.out.println("Contract no is not null************");
sql2="select price_list from scontract where contract_no=?";
pstmt1 = conn.prepareStatement(sql2);
pstmt1.setString(1, contractNo);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
priceList = rs1.getString("price_list");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("priceList from contract no====="+priceList);
}
else
{
System.out.println("Contract no is null****************");
sql2 = " select g.price_list from group_pricelist g,pricelist p where " +
" g.cust_code = ? " +
......@@ -6803,6 +6956,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
{
priceList = rs2.getString("price_list");
}
pstmt2.close();
pstmt2 = null;
rs2.close();
......@@ -6895,6 +7049,7 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
}
}
}
}//added by priyanaka
if(priceList == null || priceList.trim().length() == 0)
{
priceList="";
......@@ -6909,4 +7064,182 @@ public class SReturnForm extends ValidatorEJB implements SReturnFormLocal, SRetu
System.out.println(">>>>return priceList:"+priceList);
return priceList;
}
private String getPriceLstVal(String custCd, String custCdDlv, String siteCd, String contrNo, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String priceLst = "", sql = "";
try
{
System.out.println(">>>>>>>>>Enter in getPriceLstVal method");
System.out.println(">>>>>>>>custCd===" + custCd);
System.out.println(">>>>>>>>custCdDlv===" + custCdDlv);
System.out.println(">>>>>>>>siteCd===" + siteCd);
System.out.println(">>>>>>>>contractNo===" + contrNo);
if (contrNo != null && contrNo.trim().length() > 0)
{
sql = "select price_list from scontract where contract_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, contrNo);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
System.out.println("Price list from contract no===========" + priceLst);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from site_customer where site_code = ? and cust_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCd);
pstmt.setString(2, custCd);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCd);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from site_customer where site_code = ? and cust_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCd);
pstmt.setString(2, custCdDlv);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCdDlv);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
}
}
}
}
else
{
sql = "select price_list from site_customer where site_code = ? and cust_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCd);
pstmt.setString(2, custCd);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCd);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from site_customer where site_code = ? and cust_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCd);
pstmt.setString(2, custCdDlv);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("Get Customer==="+custCdDlv);
System.out.println("Get priceLst lenght==="+priceLst.trim().length());
System.out.println("Get priceLst==="+priceLst);
if (priceLst == null || priceLst.trim().length() == 0)
{
sql = "select price_list from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCdDlv);
rs = pstmt.executeQuery();
if (rs.next())
{
priceLst = checkNull(rs.getString("price_list"));
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
}
}
}
System.out.println("Final Price List =======" + priceLst);
} catch (Exception e)
{
System.out.println("Exception ::" + e);
throw new ITMException(e);
}
return priceLst;
}
}
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