Commit b6eee852 authored by ngadkari's avatar ngadkari

scheme balance changes on offer button in sales order done by kaustube D

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195110 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2340bb81
......@@ -216,19 +216,19 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
{
System.out.println("getFreeSchemeAction is calling.............");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String sql = "",newDomXml = "";
String sql = "",newDomXml = "", tranID ="",outSql="";
String detCnt = "0";
int noOfDetails = 0,domID1=0;
Timestamp TranDateDet = null;
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null;
ResultSet rs = null ,rs1 = null,rs2 = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null, pstmtOut=null,pstmtIn=null;
ResultSet rs = null ,rs1 = null,rs2 = null,rs3 = null,rs4=null;
int count = 0 , domID = 0;
String itemCode = "",schemeCode = "",itemDescription="",updateFlag="";
NodeList detailList = null;
Node currDetail = null, headerNode = null;
String itmCode="",s = "",s1 = "",quantity="",schemeType="",schAllowence="",siteCode="",s12="",schemeDescr="",dsp_date="";
double qty = 0.0;
String itmCode="",s = "",s1 = "",quantity="",schemeType="",schAllowence="",siteCode="",s12="",schemeDescr="",dsp_date="",nature="";
double qty = 0.0, freeQuantity=0.0;
double purcBase=0.0;
double schAllowence1=0.0,discount=0.0,purRate=0.0;
Iterator<String> itr = null;
......@@ -530,6 +530,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
else
{
System.out.println("Scheme is NOT applicable for ::"+itemCodeSchm + "Purchased Item quantity::"+xmlQty +"is NOT greater than or equal to applicable quantity"+purcBase+"for scheme "+schemeCode);
}
}
}//end of if block for type0
......@@ -606,6 +607,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
}
else
{
System.out.println("Scheme is NOT applicable for ::"+itemCodeSchm + "Purchased Item quantity::"+xmlQty +"is NOT greater than or equal to applicable quantity"+purcBase+"for scheme "+schemeCode);
}
}
......@@ -694,6 +697,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
{
System.out.println("Scheme is NOT applicable for ::"+itemCodeSchm + "Purchased Item quantity::"+xmlQty +"is NOT greater than or equal to applicable quantity"+purcBase+"for scheme "+schemeCode);
}
}
}
}
......@@ -711,9 +715,89 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
}
//valueXmlString.append(s12);
}//end of if block for list
//valueXmlString.append("</Root>\r\n");
/**
* New code added by kaustubh on 31 Dec 2018 regarding fetching scheme details from scheme_balance table -------------start
* **/
System.out.println("inside Scheme balance Changes");
TranDateDet = getTimeStamp(dsp_date);
System.out.println("cust_code "+custCode+"TranDate "+ TranDateDet);
outSql = " select TRAN_ID from SCHEME_BALANCE where EFF_FROM <= ? AND VALID_UPTO >= ? AND CUST_CODE = ? " ;
pstmtOut = conn.prepareStatement(outSql);
pstmtOut.setTimestamp(1, TranDateDet);
pstmtOut.setTimestamp(2, TranDateDet);
pstmtOut.setString(3,custCode);
rs3 = pstmtOut.executeQuery();
while(rs3.next())
{
tranID = rs3.getString("TRAN_ID");
sql = " SELECT tran_id,"
+ "CASE WHEN item_code = 'X' THEN 'X' "
+" ELSE item_code end as item_code , SCHEME_CODE,SCHEME_TYPE, "
+" CASE WHEN item_code = 'X' THEN 'V' "
+" when item_code <> 'X' THEN 'I' END AS nature,"
+" CASE WHEN (BALANCE_FREE_VALUE - USED_FREE_VALUE > 0) THEN (BALANCE_FREE_VALUE - USED_FREE_VALUE ) "
+" WHEN ( balance_free_qty - USED_FREE_qty > 0 ) THEN ( balance_free_qty - USED_FREE_qty )"
+" END AS free_qty "
+" FROM SCHEME_BALANCE "
+" WHERE (BALANCE_FREE_VALUE - USED_FREE_VALUE > 0 or balance_free_qty - USED_FREE_qty > 0 ) "
+" and EFF_FROM <= ? AND VALID_UPTO >= ? "
+" AND CUST_CODE = ? and TRAN_ID = ? ";
pstmtIn = conn.prepareStatement(sql);
pstmtIn.setTimestamp(1, TranDateDet);
pstmtIn.setTimestamp(2, TranDateDet);
pstmtIn.setString(3,custCode);
pstmtIn.setString(4, tranID);
rs4 = pstmtIn.executeQuery();
while(rs4.next())
{
domID++;
System.out.println("DomId"+domID);
itemCode = rs4.getString("item_code");
schemeCode = rs4.getString("SCHEME_CODE");
schemeType = rs4.getString("SCHEME_TYPE");
nature = rs4.getString("nature");
freeQuantity =rs4.getDouble("free_qty");
valueXmlString.append("<Detail domId='"+(domID)+"'>\r\n");
System.out.println("Free Items "+itemCode);
itemDescription = getItemDescr(itemCode,conn);
valueXmlString.append("<scheme_type>").append("<![CDATA[").append(schemeType).append("]]>").append("</scheme_type>\r\n");
valueXmlString.append("<applicable_scheme>").append("<![CDATA[").append(schemeCode).append("]]>").append("</applicable_scheme>\r\n");
valueXmlString.append("<purchase_item_code>").append("<![CDATA[").append(itemValues).append("]]>").append("</purchase_item_code>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescription).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<scheme_descr>").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_descr>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(freeQuantity).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<discount>").append("<![CDATA[").append(discount).append("]]>").append("</discount>\r\n");
valueXmlString.append("<nature>").append("<![CDATA[").append(nature).append("]]>").append("</nature>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(0).append("]]>").append("</rate>\r\n");
valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code__ord>\r\n");
valueXmlString.append("</Detail>\r\n");
}
}
valueXmlString.append("</Root>\r\n");
/**
* New code added by kaustubh on 31 Dec 2018 regarding fetching scheme details from scheme_balance table --------------- End
***/
/* Added by kaustubh on 30 jan 2018 start */
/* to resolved issue of improper domID */
System.out.println("@@xmlString For Scheme :: "+valueXmlString.toString());
......@@ -762,6 +846,17 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
pstmt.close();
pstmt = null;
}
if(pstmtOut != null)
{
pstmtOut.close();
pstmtOut = null;
}
if(pstmtIn != null)
{
pstmtIn.close();
pstmtIn = null;
}
}
catch(Exception ex)
{
......
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