Commit 1a1a4ae8 authored by pgole's avatar pgole

Updated ejb component for SRC


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104181 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 126aa8e3
...@@ -971,15 +971,17 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -971,15 +971,17 @@ public class CustStock extends ValidatorEJB //implements SessionBean
String opValue = ""; String opValue = "";
String purValue = ""; String purValue = "";
String clValue = ""; String clValue = "";
String salesValue = ""; String salesValue = "", plistDisc = "",status = "",purcRcpSale = "" ,sql = "" ,replPeriod = "";
String dbPattern=null; String dbPattern=null;
String invStat = ""; String invStat = "";
String itemCode = "", purcRcp = null, purcRet = null, prdCode, transitFlg = null; String itemCode = "", purcRcp = null, purcRet = null, prdCode, transitFlg = null;
double retQty = 0, replQty = 0, quantity = 0, transitQty = 0; double retQty = 0, replQty = 0, quantity = 0, transitQty = 0 ,creditLmt = 0,osAmt = 0 ,custDeposit = 0 ,custRate = 0 ,custDiscount = 0 ,netAmount = 0 ,
purcReturn = 0 ,purcRcpDob = 0 ,salesRet = 0;
//Changed by Dayanand on 01/01/08 [Declare transQty] //Changed by Dayanand on 01/01/08 [Declare transQty]
String transQty ="", purcQty = null; String transQty ="", purcQty = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null; PreparedStatement pstmt1 = null;
int replPrd = 0 ;
ResultSet rs1 = null; ResultSet rs1 = null;
String custCode = null,rSiteCode = null, locCode = null, lotNo = null, lotSl = null, retRepFlag = null; String custCode = null,rSiteCode = null, locCode = null, lotNo = null, lotSl = null, retRepFlag = null;
java.sql.Timestamp preFromDate = null, preToDate = null; java.sql.Timestamp preFromDate = null, preToDate = null;
...@@ -987,7 +989,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -987,7 +989,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
try try
{ {
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
DistDiscount distDiscount = new DistDiscount();
DistCommon distCommon = new DistCommon();
conn = getConnection(); conn = getConnection();
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
...@@ -1013,6 +1016,93 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1013,6 +1016,93 @@ public class CustStock extends ValidatorEJB //implements SessionBean
columnValue = getColumnValue(currentColumn, dom, formNo); columnValue = getColumnValue(currentColumn, dom, formNo);
}*/ }*/
System.out.println("columnValue :"+columnValue+":"); System.out.println("columnValue :"+columnValue+":");
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
java.sql.Date currentDate = new java.sql.Date( System.currentTimeMillis() );
//Added by Poonam on 09-12-2016 for GET REPL_PERIOD FROM DATABASE :Start[D16HVHB005]
custCode = getColumnValue("cust_code",dom1);
itemCode = getColumnValue("item_code",dom1);
System.out.println("custCode... :"+custCode+":itemCode...:"+itemCode+":");
System.out.println("In S astype....");
sql = "select repl_period from customeritem where cust_code = ? and item_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, custCode );
pstmt.setString( 2, itemCode );
rs = pstmt.executeQuery();
if(rs.next())
{
replPeriod = rs.getString("repl_period");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
sql = "Select item_ser from item where item_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, itemCode );
rs = pstmt.executeQuery();
if(rs.next())
{
itemSer = checkNull(rs.getString("item_ser"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("mvarValue["+replPeriod+"][itemSer"+itemSer+"]");
if(replPeriod == null || replPeriod.trim().length() == 0)
{
sql = "select repl_period from customer_series where cust_code = ? and item_ser = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, custCode );
pstmt.setString( 2, itemSer );
rs = pstmt.executeQuery();
if(rs.next())
{
replPeriod = rs.getString("repl_period");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
}
if(replPeriod == null || replPeriod.trim().length() == 0)
{
sql = "select repl_period from customer where cust_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, custCode );
rs = pstmt.executeQuery();
if(rs.next())
{
replPeriod = rs.getString("repl_period");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
}
if(replPeriod == null || replPeriod.trim().length() == 0)
{
replPeriod = distCommon.getDisparams("999999", "REPL_PERIOD", conn);
if(replPeriod == null || replPeriod.trim().length() == 0)
{
replPeriod = "1";
}
if("NULLFOUND".equalsIgnoreCase(replPeriod))
{
replPeriod = "0";
}
}
System.out.println("replPeriod["+replPeriod +"]");
if(replPeriod != null && replPeriod.trim().length() > 0)
{
replPrd = Integer.parseInt(replPeriod);
}
System.out.println("replPrd["+replPrd +"]");
//Added by Poonam on 09-12-2016 for GET REPL_PERIOD FROM DATABASE :Start[D16HVHB005]
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
if (columnValue != null) if (columnValue != null)
...@@ -1054,11 +1144,39 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1054,11 +1144,39 @@ public class CustStock extends ValidatorEJB //implements SessionBean
/* dw_edit.setitem (1, "tran_date", ldt_today) /* dw_edit.setitem (1, "tran_date", ldt_today)
dw_edit.setitem (1, "from_date", ldt_today) dw_edit.setitem (1, "from_date", ldt_today)
dw_edit.setitem ( 1, "to_date", ldt_today) */ dw_edit.setitem ( 1, "to_date", ldt_today) */
java.sql.Date currentDate = new java.sql.Date( System.currentTimeMillis() );
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() ); java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append( "<tran_date>" ).append( dtf.format( currentDate ) ).append( "</tran_date>\r\n" ); currentDate = new java.sql.Date( System.currentTimeMillis());
//Added by Poonam on 09-12-2016 for GET REPL_PERIOD FROM DATABASE :Start[D16HVHB005]
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);
cal.add(Calendar.DATE, -(replPrd * 30)); //minus number would decrement the days
System.out.println("Date before "+ replPrd +" Months ::::"+cal.getTime());
Date prdDate = cal.getTime();
Calendar GCal = new GregorianCalendar();
GCal.setTime(prdDate);
GCal.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat());
Date gcalFrdt = GCal.getTime();
if(replPeriod != null && replPeriod.trim().length() > 0 && replPrd > 1)
{
System.out.println("fromDt::::::"+ dtf.format( gcalFrdt ));
valueXmlString.append( "<from_date>" ).append( dtf.format( gcalFrdt ) ).append( "</from_date>\r\n" );
} //Added by Poonam on 09-12-2016 for GET REPL_PERIOD FROM DATABASE :End[D16HVHB005]
else
{
currentDate = new java.sql.Date( System.currentTimeMillis() );
valueXmlString.append( "<from_date>" ).append( dtf.format( currentDate ) ).append( "</from_date>\r\n" ); valueXmlString.append( "<from_date>" ).append( dtf.format( currentDate ) ).append( "</from_date>\r\n" );
}
valueXmlString.append( "<to_date>" ).append( dtf.format( currentDate ) ).append( "</to_date>\r\n" ); valueXmlString.append( "<to_date>" ).append( dtf.format( currentDate ) ).append( "</to_date>\r\n" );
valueXmlString.append( "<tran_date>" ).append( dtf.format( currentDate ) ).append( "</tran_date>\r\n" );
//valueXmlString.append( "<from_date>" ).append( dtf.format( currentDate ) ).append( "</from_date>\r\n" ); //Commented by Poonam for set 3 months back date.
selQuery = "SELECT DESCR FROM ITEMSER WHERE ITEM_SER = '" + getColumnValue("item_ser",dom1) + "'"; selQuery = "SELECT DESCR FROM ITEMSER WHERE ITEM_SER = '" + getColumnValue("item_ser",dom1) + "'";
stmt = conn.createStatement(); stmt = conn.createStatement();
...@@ -1112,12 +1230,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1112,12 +1230,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{ {
frdate1 = getColumnValue("from_date",dom1); frdate1 = getColumnValue("from_date",dom1);
siteCode = getColumnValue("site_code",dom1); siteCode = getColumnValue("site_code",dom1);
selQuery = "SELECT CUST_NAME FROM CUSTOMER WHERE CUST_CODE = '" + columnValue + "'"; selQuery = "SELECT CUST_NAME,CREDIT_LMT FROM CUSTOMER WHERE CUST_CODE = '" + columnValue + "'";//Changed for getting credit_limit
stmt = conn.createStatement(); stmt = conn.createStatement();
rs = stmt.executeQuery(selQuery); rs = stmt.executeQuery(selQuery);
if (rs.next()) if (rs.next())
{ {
custName = rs.getString(1); custName = rs.getString("CUST_NAME");
creditLmt = rs.getDouble("CREDIT_LMT");
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -1212,7 +1331,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1212,7 +1331,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
System.out.println("tran_id__last :"+tranIdLast+":"); System.out.println("tran_id__last :"+tranIdLast+":");
if (tranIdLast == null || tranIdLast.equalsIgnoreCase("null") || tranIdLast.length() == 0) if (tranIdLast == null || tranIdLast.equalsIgnoreCase("null") || tranIdLast.length() == 0)
{ {
if (itemSer.trim().length() > 0 ) if (itemSer != null && itemSer.trim().length() > 0 )
{ {
selQueryBuff = new StringBuffer(); selQueryBuff = new StringBuffer();
selQueryBuff.append("SELECT MAX(TRAN_ID) FROM CUST_STOCK WHERE CUST_CODE = '"); selQueryBuff.append("SELECT MAX(TRAN_ID) FROM CUST_STOCK WHERE CUST_CODE = '");
...@@ -1255,6 +1374,35 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1255,6 +1374,35 @@ public class CustStock extends ValidatorEJB //implements SessionBean
itemSer = itemSer + "%"; itemSer = itemSer + "%";
} }
}*/ }*/
//Added by Poonam on 09-12-2016 for display credit_limit ,deposit and Outstanding :Start[D16HVHB005]
selQuery = "select fn_get_cust_deposit(?,?) ,fn_get_custos(?,?,'T') from dual";
pstmt = conn.prepareStatement(selQuery);
pstmt.setString(1, siteCode.toUpperCase());
pstmt.setString(2, columnValue.toUpperCase());
pstmt.setString(3, columnValue.toUpperCase());
pstmt.setString(4, siteCode.toUpperCase());
rs = pstmt.executeQuery();
if (rs.next())
{
custDeposit = rs.getDouble(1);
osAmt = rs.getDouble(2);
}
rs.close();
rs = null;
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("TestMig case1 os_amt["+osAmt+"]creditLmt["+creditLmt+"]custDeposit["+custDeposit+"]");
valueXmlString.append("<os_amt>").append(osAmt).append("</os_amt>\r\n");
valueXmlString.append("<customer_credit_lmt>").append(creditLmt).append("</customer_credit_lmt>\r\n");
valueXmlString.append("<deposit>").append(custDeposit).append("</deposit>\r\n");
//Added by Poonam on 09-12-2016 for display credit_limit ,deposit and Outstanding :End[D16HVHB005]
} }
else if (currentColumn.trim().equals("site_code")) else if (currentColumn.trim().equals("site_code"))
{ {
...@@ -1363,11 +1511,16 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1363,11 +1511,16 @@ public class CustStock extends ValidatorEJB //implements SessionBean
valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n"); valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n");
Comment Ended*/ Comment Ended*/
//Added by chandni 19-Apr-2012 //Added by chandni 19-Apr-2012
calendar.setTime(trnDate); calendar.setTime(trnDate);
calendar.add(Calendar.DATE,( -( replPrd *30) )); //added by Poonam for set from date and to date
calendar.set(Calendar.DAY_OF_MONTH,1); calendar.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat()); System.out.println("getApplDateFormat()----"+getApplDateFormat());
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() ); java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n"); valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n");
calendar.setTime(trnDate);
calendar.set(Calendar.DAY_OF_MONTH,1);
int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH,ld); calendar.set(Calendar.DAY_OF_MONTH,ld);
System.out.println("Date : " + calendar.getTime()); System.out.println("Date : " + calendar.getTime());
...@@ -1521,21 +1674,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1521,21 +1674,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
adjQty = "0"; adjQty = "0";
purReturn = "0"; purReturn = "0";
//ibase.utility.GenericUtility gu = new ibase.utility.GenericUtility();
//Changed by Dayanand on 8/25/2008 [Comment The SOP For speed reason]START
//System.out.println(" dom " + genericUtility.serializeDom( dom ) );
//System.out.println(" dom1 " + genericUtility.serializeDom( dom1 ) );
//System.out.println(" dom2 " + genericUtility.serializeDom( dom2 ) );
//Changed by Dayanand on 8/25/2008 [Comment The SOP For speed reason]END
//purReceipt = getColumnValue("purc_rcp",dom, formNo, domID);
//adjQty = getColumnValue("adj_qty",dom, formNo, domID);
//purReturn = getColumnValue("purc_ret",dom, formNo, domID);
purReceipt = getColumnValue("purc_rcp",dom, formNo); purReceipt = getColumnValue("purc_rcp",dom, formNo);
adjQty = getColumnValue("adj_qty",dom, formNo); adjQty = getColumnValue("adj_qty",dom, formNo);
purReturn = getColumnValue("purc_ret",dom, formNo); purReturn = getColumnValue("purc_ret",dom, formNo);
System.out.println("Values at end purReceipt["+purReceipt+"]purReturn["+purReturn+"]adjQty["+adjQty+"]");
//rateValue = getRate( getColumnValue("cust_code", dom), getColumnValue("tran_date", dom), getColumnValue("item_code",dom, formNo, domID)); //rateValue = getRate( getColumnValue("cust_code", dom), getColumnValue("tran_date", dom), getColumnValue("item_code",dom, formNo, domID));
System.out.println("Calculating rate for cust_code :"+getColumnValue("cust_code", dom1)+": tran_date :"+getColumnValue("tran_date", dom1)+": item_code :"+genericUtility.getColumnValue("item_code",dom)+":"); System.out.println("Calculating rate for cust_code :"+getColumnValue("cust_code", dom1)+": tran_date :"+getColumnValue("tran_date", dom1)+": item_code :"+genericUtility.getColumnValue("item_code",dom)+":");
...@@ -1817,6 +1961,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1817,6 +1961,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
custCode = getColumnValue("cust_code" , dom1); custCode = getColumnValue("cust_code" , dom1);
siteCode = getColumnValue("site_code" , dom1); siteCode = getColumnValue("site_code" , dom1);
tranDate = getColumnValue("tran_date" , dom1 ); tranDate = getColumnValue("tran_date" , dom1 );
Date tranDT = sdf1.parse(tranDate);
tranIdLast = getColumnValue("tran_id__last" ,dom1); tranIdLast = getColumnValue("tran_id__last" ,dom1);
prdCode = getColumnValue("prd_code" , dom1 ); prdCode = getColumnValue("prd_code" , dom1 );
itemCode = columnValue; itemCode = columnValue;
...@@ -1874,14 +2020,44 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1874,14 +2020,44 @@ public class CustStock extends ValidatorEJB //implements SessionBean
rs = null; rs = null;
pstmt = null; pstmt = null;
java.sql.Timestamp tsprevDate1 = null;
String fromDate = getColumnValue("from_date" , dom1 ); String fromDate = getColumnValue("from_date" , dom1 );
System.out.println("fromDate... [" +fromDate+ "]");
java.sql.Timestamp tsfromDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( fromDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ); java.sql.Timestamp tsfromDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( fromDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
String toDate = getColumnValue("to_date" , dom1 ); //Added By poonam for set to date
String tranDte = getColumnValue("tran_date" , dom1 ); //Added By poonam
java.sql.Timestamp tstoDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( toDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
java.sql.Timestamp tstranDte = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( tranDte , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
System.out.println("tsfromDate... [" +tsfromDate+ "]");
java.sql.Timestamp tsprevDate = utilMethods.RelativeDate(tsfromDate, -1); java.sql.Timestamp tsprevDate = utilMethods.RelativeDate(tsfromDate, -1);
System.out.println("tsprevDate... [" +tsprevDate+ "]");
SimpleDateFormat sdtApplDate = new SimpleDateFormat(getApplDateFormat()); SimpleDateFormat sdtApplDate = new SimpleDateFormat(getApplDateFormat());
String prevDate = sdtApplDate.format(tsprevDate); String prevDate = sdtApplDate.format(tsprevDate);
selQuery = "SELECT FR_DATE, TO_DATE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE" ;
pstmt = conn.prepareStatement(selQuery);
//pstmt.setTimestamp(1,tsprevDate);
pstmt.setTimestamp(1,tstranDte);
rs = pstmt.executeQuery();
if (rs.next())
{
preFromDate = rs.getTimestamp("FR_DATE");
preToDate = rs.getTimestamp("TO_DATE");
tsprevDate1 = utilMethods.RelativeDate(preFromDate, -1);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
System.out.println("tsprevDate1["+tsprevDate1+"]");
selQuery = "SELECT SUM(DET.CL_STOCK)AS OP_STOCK FROM CUST_STOCK HDR, CUST_STOCK_DET DET " selQuery = "SELECT SUM(DET.CL_STOCK)AS OP_STOCK FROM CUST_STOCK HDR, CUST_STOCK_DET DET "
+ " WHERE HDR.TRAN_ID = DET.TRAN_ID " + " WHERE HDR.TRAN_ID = DET.TRAN_ID "
+ " AND HDR.CUST_CODE = ? " + " AND HDR.CUST_CODE = ? "
...@@ -1893,7 +2069,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1893,7 +2069,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
pstmt.setString(1,custCode); pstmt.setString(1,custCode);
// pstmt.setString(2,siteCode); // pstmt.setString(2,siteCode);
pstmt.setString(2,siteCodeCh); //Added by Chandni 11/Apr/2012 pstmt.setString(2,siteCodeCh); //Added by Chandni 11/Apr/2012
pstmt.setTimestamp(3,tsprevDate); pstmt.setTimestamp(3,tsprevDate1);
pstmt.setString(4,itemCode); pstmt.setString(4,itemCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
...@@ -1914,22 +2090,26 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1914,22 +2090,26 @@ public class CustStock extends ValidatorEJB //implements SessionBean
String invListString = ""; String invListString = "";
selQuery = "SELECT FR_DATE, TO_DATE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE" ; selQuery = "SELECT FR_DATE, TO_DATE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE" ;
pstmt = conn.prepareStatement(selQuery); pstmt = conn.prepareStatement(selQuery);
pstmt.setTimestamp(1,tsprevDate); //pstmt.setTimestamp(1,tsprevDate);
pstmt.setTimestamp(1,tstranDte);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
preFromDate = rs.getTimestamp("FR_DATE"); preFromDate = rs.getTimestamp("FR_DATE");
preToDate = rs.getTimestamp("TO_DATE"); preToDate = rs.getTimestamp("TO_DATE");
invListString = GetInvList(dom2, preFromDate, preToDate); //invListString = GetInvList(dom2, preFromDate, preToDate); //Commented by poonam
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
rs = null; rs = null;
pstmt = null; pstmt = null;
invListString = GetInvList(dom2, tsfromDate, preToDate); //Added by Poonam for get 3 months invoice
System.out.println("invListString::::["+invListString+"]");
fromDate = getColumnValue("from_date" , dom1 ); fromDate = getColumnValue("from_date" , dom1 );
java.sql.Timestamp tsFromDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( fromDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ); java.sql.Timestamp tsFromDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( fromDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
String toDate = getColumnValue("to_date" , dom1 );
java.sql.Timestamp tsToDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( toDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ); java.sql.Timestamp tsToDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( toDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
// commented by chandni 21-mar-2012 // commented by chandni 21-mar-2012
/* /*
...@@ -1970,7 +2150,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1970,7 +2150,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
pstmt.setString(2,itemCode); pstmt.setString(2,itemCode);
pstmt.setString(3,siteCode); pstmt.setString(3,siteCode);
pstmt.setTimestamp(4,tsFromDate); pstmt.setTimestamp(4,tsFromDate);
pstmt.setTimestamp(5,tsToDate); pstmt.setTimestamp(5,preToDate);
// ended by chandni // ended by chandni
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
...@@ -1980,33 +2160,33 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -1980,33 +2160,33 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{ {
purcRcp = "0"; purcRcp = "0";
} }
purReceipt = purcRcp; //purReceipt = purcRcp; //Commented By poonam for get avarage of sales
valueXmlString.append("<purc_rcp>").append(purcRcp).append("</purc_rcp>\r\n");
if(purcRcp != null && purcRcp.trim().length() > 0)
{
purcRcpDob = Double.parseDouble(purcRcp);
System.out.println("purcRcpDob:["+purcRcpDob+"]replPrd["+replPrd+"]");
purcRcpDob = purcRcpDob/replPrd ;
System.out.println("purcRcpDob divide:["+purcRcpDob+"]");
}
//purReceipt = Double.toString(purcRcpDob);
purReceipt = Double.toString(Math.round(purcRcpDob));
System.out.println("purReceipt parse:["+purReceipt+"]");
//valueXmlString.append("<purc_rcp>").append(purcRcp).append("</purc_rcp>\r\n");
valueXmlString.append("<purc_rcp>").append( Math.round(purcRcpDob)).append("</purc_rcp>\r\n");
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
rs = null; rs = null;
pstmt = null; pstmt = null;
System.out.println("purcRcp [" +purcRcp+ "]"); System.out.println("purcRcp [" +purcRcp+ "]");
// commented by chandni 21-mar-2012
/*
selQuery = "SELECT B.QUANTITY__STDUOM QUANTITY, B.ITEM_CODE ITEM_CODE, "
+ " A.SITE_CODE SITE_CODE, B.LOC_CODE LOC_CODE, "
+ " B.LOT_NO LOT_NO, B.LOT_SL LOT_SL, B.RET_REP_FLAG RET_REP_FLAG "
+ " FROM SRETURN A, SRETURNDET B "
+ " WHERE A.TRAN_ID = B.TRAN_ID "
+ " AND A.CUST_CODE = ? "
+ " AND A.TRAN_DATE >= ? "
+ " AND A.TRAN_DATE <= ? "
+ " AND B.ITEM_CODE = ? ";
pstmt = conn.prepareStatement(selQuery);
pstmt.setString(1,custCode);
pstmt.setTimestamp(2,preFromDate);
pstmt.setTimestamp(3,preToDate);
pstmt.setString(4,itemCode);
*/
// added site_code condition by chandni 21-mar-2012
selQuery = "SELECT B.QUANTITY__STDUOM QUANTITY, B.ITEM_CODE ITEM_CODE, " selQuery = "SELECT B.QUANTITY__STDUOM QUANTITY, B.ITEM_CODE ITEM_CODE, "
+ " A.SITE_CODE SITE_CODE, B.LOC_CODE LOC_CODE, " + " A.SITE_CODE SITE_CODE, B.LOC_CODE LOC_CODE, "
+ " B.LOT_NO LOT_NO, B.LOT_SL LOT_SL, B.RET_REP_FLAG RET_REP_FLAG " + " B.LOT_NO LOT_NO, B.LOT_SL LOT_SL, B.RET_REP_FLAG RET_REP_FLAG "
...@@ -2020,7 +2200,9 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2020,7 +2200,9 @@ public class CustStock extends ValidatorEJB //implements SessionBean
pstmt = conn.prepareStatement(selQuery); pstmt = conn.prepareStatement(selQuery);
pstmt.setString(1,custCode); pstmt.setString(1,custCode);
pstmt.setTimestamp(2,preFromDate); //pstmt.setTimestamp(2,preFromDate);
//pstmt.setTimestamp(3,preToDate);
pstmt.setTimestamp(2,tsFromDate);
pstmt.setTimestamp(3,preToDate); pstmt.setTimestamp(3,preToDate);
pstmt.setString(4,itemCode); pstmt.setString(4,itemCode);
pstmt.setString(5,siteCode); pstmt.setString(5,siteCode);
...@@ -2074,8 +2256,16 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2074,8 +2256,16 @@ public class CustStock extends ValidatorEJB //implements SessionBean
pstmt = null; pstmt = null;
System.out.println("quantity:"+quantity+":retQty:"+retQty+":replQty:"+replQty); System.out.println("quantity:"+quantity+":retQty:"+retQty+":replQty:"+replQty);
quantity = retQty - replQty ; quantity = retQty - replQty ;
valueXmlString.append("<purc_ret>").append(quantity).append("</purc_ret>\r\n");
salesRet = quantity / replPrd;
purReturn = Double.toString(salesRet) ; //Added by Poonam
System.out.println("quantity sql [" +quantity+ "]replPrd["+replPrd+"]purReturn["+purReturn+"]");
//valueXmlString.append("<purc_ret>").append(quantity).append("</purc_ret>\r\n");
valueXmlString.append("<purc_ret>").append(Math.round(salesRet)).append("</purc_ret>\r\n"); //Added by poonam
System.out.println("purc_ret [" +quantity+ "]"); System.out.println("purc_ret [" +quantity+ "]");
transitQty = 0; transitQty = 0;
transitFlg = getColumnValue("transit_flag" , dom1); transitFlg = getColumnValue("transit_flag" , dom1);
...@@ -2132,11 +2322,33 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2132,11 +2322,33 @@ public class CustStock extends ValidatorEJB //implements SessionBean
rs = null; rs = null;
pstmt = null; pstmt = null;
/////End 31/01/09 manoharan /////////////////////////////////////////////////////////// /////End 31/01/09 manoharan ///////////////////////////////////////////////////////////
//Added by Poonam on 09-12-2016 for discount, latest rate and net amount :Start[D16HVHB005]
double purcRcpSales = Double.parseDouble(purcRcp);
System.out.println("purcRcpSales["+purcRcpSales+"]purcReturn["+purcReturn);
custRate = getRate(custCode, tranDate, itemCode);
plistDisc = distDiscount.priceListDiscount(siteCode, custCode, conn);
System.out.println("TestMig Case3 custRate["+custRate+"]plistDisc["+plistDisc+"]");
if(plistDisc == null || plistDisc.trim().length() == 0)
{
plistDisc = "";
}
custDiscount = distDiscount.getDiscount(plistDisc, tranDT, custCode, siteCode, itemCode, unit, 0, tranDT, purcRcpSales, conn);
System.out.println("TestMig custDiscount["+custDiscount+"]");
System.out.println("TestMig netAmount["+netAmount+"]custRate["+custRate+"]custDiscount["+custDiscount+"]");
valueXmlString.append("<rate>").append(custRate).append("</rate>\r\n");
valueXmlString.append("<discount>").append(custDiscount).append("</discount>\r\n");
//Added by Poonam on 09-12-2016 for discount, latest rate and net amount :End[D16HVHB005]
} }
else if (currentColumn.trim().equals("op_stock")) else if (currentColumn.trim().equals("op_stock"))
{ {
opStock = columnValue; opStock = columnValue;
System.out.println(" op_stock currentColumn ["+currentColumn+"]"); System.out.println("op_stock currentColumn ["+currentColumn+"]");
System.out.println("line 1295 opStock["+opStock+"]"); System.out.println("line 1295 opStock["+opStock+"]");
if (stockMode.trim().equals("S")) if (stockMode.trim().equals("S"))
{ {
...@@ -2181,12 +2393,22 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2181,12 +2393,22 @@ public class CustStock extends ValidatorEJB //implements SessionBean
opStock = genericUtility.getColumnValue("op_stock", dom,formNo); opStock = genericUtility.getColumnValue("op_stock", dom,formNo);
//Changed by Dayanand on 8/25/2008 [Change the transit quantity calculation]start (reqId DI89SUN082) //Changed by Dayanand on 8/25/2008 [Change the transit quantity calculation]start (reqId DI89SUN082)
purReceipt = genericUtility.getColumnValue("purc_rcp", dom); purReceipt = genericUtility.getColumnValue("purc_rcp", dom,formNo);
System.out.println( "Inside item_code [" + purReceipt + "]opStock"+opStock +"]formNo["+formNo +"]");
//purReceipt = genericUtility.getColumnValue("cust_purc_rcp", dom); //purReceipt = genericUtility.getColumnValue("cust_purc_rcp", dom);
} }
sales = genericUtility.getColumnValue("sales", dom,formNo); sales = genericUtility.getColumnValue("sales", dom,formNo);
clStks = genericUtility.getColumnValue("cl_stock", dom,formNo); clStks = genericUtility.getColumnValue("cl_stock", dom,formNo);
System.out.println( "opStock BEFORE [" + opStock + "]" );
System.out.println( "clStks [" + clStks + "]" );
System.out.println( "sales [" + sales + "]" );
System.out.println( "adjQty ["+adjQty+ "]" );
System.out.println( "purReceipt ["+purReceipt+ "]" );
System.out.println( "purReturn ["+purReturn+ "]" );
if (opStock == null || opStock == "null" || opStock.trim().length() == 0 ) if (opStock == null || opStock == "null" || opStock.trim().length() == 0 )
{ {
opStock = "0"; opStock = "0";
...@@ -2229,6 +2451,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2229,6 +2451,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{ {
clStks = "0"; clStks = "0";
} }
System.out.println( "opStock [" + opStock + "]purReceipt["+purReceipt+"]clStks["+clStks+"]adjQty["+adjQty+"]purReturn["+purReturn+"]");
saless = Double.parseDouble(opStock) + Double.parseDouble(purReceipt) - Double.parseDouble(clStks) + Double.parseDouble(adjQty) - Double.parseDouble(purReturn); saless = Double.parseDouble(opStock) + Double.parseDouble(purReceipt) - Double.parseDouble(clStks) + Double.parseDouble(adjQty) - Double.parseDouble(purReturn);
valueXmlString.append("<sales>").append(saless).append("</sales>\r\n"); valueXmlString.append("<sales>").append(saless).append("</sales>\r\n");
sales = saless + ""; sales = saless + "";
...@@ -2237,6 +2460,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2237,6 +2460,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
System.out.println( "clStks [" + clStks + "]" ); System.out.println( "clStks [" + clStks + "]" );
System.out.println( "sales [" + sales + "]" ); System.out.println( "sales [" + sales + "]" );
System.out.println( "cust_purc_rcp ["+purReceipt+ "]" ); System.out.println( "cust_purc_rcp ["+purReceipt+ "]" );
System.out.println( "saless ["+saless+ "]" );
/* 09/02/09 commented by manoharan /* 09/02/09 commented by manoharan
//Changed by Dayanand on 01/01/08 [ Calculate transQty] start (reqId DI78SUN073) //Changed by Dayanand on 01/01/08 [ Calculate transQty] start (reqId DI78SUN073)
...@@ -2403,6 +2627,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2403,6 +2627,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
//System.out.println("Exception ::" + exception.getMessage()); //System.out.println("Exception ::" + exception.getMessage());
throw new ITMException( exception ); throw new ITMException( exception );
} }
System.out.println("invoiceListString ................["+invoiceListString+"]");
return invoiceListString ; return invoiceListString ;
} }
private double GetTransitQty(Document dom, String itemCode, Connection conn) throws Exception private double GetTransitQty(Document dom, String itemCode, Connection conn) throws Exception
...@@ -2461,4 +2686,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean ...@@ -2461,4 +2686,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
} }
return transitQty ; return transitQty ;
} }
private String checkNull(String input)
{
if (input == null)
{
input="";
}
return input.trim();
}
} }
\ No newline at end of file
...@@ -1740,11 +1740,12 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo ...@@ -1740,11 +1740,12 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
else else
{ {
perc = (mclStock/integralQty) + 1; perc = (mclStock/integralQty) + 1;
System.out.println("perc:::"+perc+"]mclStock:::["+mclStock+"]");
} }
} }
else else
{ {
perc = (mclStock/integralQty) ; perc = (mclStock/integralQty) + 1 ;
} }
} }
else else
...@@ -2482,7 +2483,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo ...@@ -2482,7 +2483,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
xmlBuff.append("<curr_code__ins><![CDATA["+ currCode +"]]></curr_code__ins>"); xmlBuff.append("<curr_code__ins><![CDATA["+ currCode +"]]></curr_code__ins>");
xmlBuff.append("<exch_rate><![CDATA["+ exchRate +"]]></exch_rate>"); xmlBuff.append("<exch_rate><![CDATA["+ exchRate +"]]></exch_rate>");
xmlBuff.append("<status><![CDATA["+ "P" +"]]></status>"); xmlBuff.append("<status><![CDATA["+ "P" +"]]></status>");
xmlBuff.append("<confirmed><![CDATA["+ "N" +"]]></confirmed>"); xmlBuff.append("<confirmed><![CDATA["+ "Y" +"]]></confirmed>");
xmlBuff.append("<tax_date><![CDATA["+morderDtApp +"]]></tax_date>"); xmlBuff.append("<tax_date><![CDATA["+morderDtApp +"]]></tax_date>");
xmlBuff.append("<pl_date><![CDATA["+morderDtApp +"]]></pl_date>"); xmlBuff.append("<pl_date><![CDATA["+morderDtApp +"]]></pl_date>");
......
/********************************************************
Title : CustStockOrder[D16HVHB005]
Date : 07/12/16
********************************************************/
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.dis.DistDiscount;
import ibase.webitm.ejb.sys.UtilMethods;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
@Stateless
public class CustStockSubmit extends ActionHandlerEJB implements CustStockSubmitLocal, CustStockSubmitRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
FinCommon finCommon = new FinCommon();
DistCommon distCommon= new DistCommon();
ValidatorEJB validatorEJB = new ValidatorEJB();
UtilMethods utilMethods = new UtilMethods();
DistDiscount distDiscount = new DistDiscount();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>CustStockSubmit called>>>>>>>>>>>>>>>>>>>");
String sql = "" ;
Connection conn = null;
PreparedStatement pstmt = null ;
String errString = null;
ResultSet rs = null;
String confirm = "", custCode = "",emailId = "",name = "",msgText= "",subText = "", mailRetStr = "";
try
{
ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
conn.setAutoCommit(false);
sql = " select confirmed,cust_code from cust_stock where tran_id = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, tranId.trim());
rs = pstmt.executeQuery();
if( rs.next() )
{
confirm = rs.getString("confirmed");
custCode = rs.getString("cust_code");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( "Y".equalsIgnoreCase(confirm))
{
errString = itmDBAccessEJB.getErrorString("","VTCONFMDSM","","",conn);
}
else
{
sql = " select sh_name,email_addr from customer where cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
name = checkNull(rs.getString("sh_name"));
emailId = checkNull(rs.getString("email_addr"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
Calendar cal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
String displayDate = df.format(cal.getTime());
System.out.println("fmt: " + displayDate);
System.out.println("@V@ Format Code :- emailAddr["+emailId+"]reportTo["+custCode+"]name["+name+"]");
subText = "Auto stock Replenishment generation["+tranId+"]" ;
msgText = "Dear " + name +",\n\n "+ "\t\t Please be inform that Auto stock Replenishment is generated for tran_id : "+tranId +".\n"+
"You can check and verify/edit the respected transation."+
"\n\n"+ "Thanks and Regards,\n"+ "Development Department.";
System.out.println("msgText loop" + msgText);
String mailDomStr = "<ROOT>"+
"<MAIL><EMAIL_TYPE>page</EMAIL_TYPE><ENTITY_CODE>Base</ENTITY_CODE>"+
"<ENTITY_TYPE>"+"E"+"</ENTITY_TYPE><SUBJECT>"+subText+"</SUBJECT>"+
"<BODY_TEXT>"+msgText+"</BODY_TEXT><TO_ADD>"+emailId+"</TO_ADD><CC_ADD></CC_ADD>"+
"</MAIL></ROOT>";
EMail email = new EMail();
if(emailId != null && emailId.trim().length() > 0)
{
mailRetStr = email.sendMail(mailDomStr, "ITM");
}
System.out.println("@V@ Mail return String :- ["+mailRetStr+"]");
if("S".equalsIgnoreCase(mailRetStr))
{
errString = itmDBAccessEJB.getErrorString("","VTSUBM1","","",conn);
}
}
} catch (Exception e)
{
if(conn!=null)
{
try
{
conn.rollback();
}
catch (SQLException ex)
{
e.printStackTrace();
throw new ITMException(e);
}
}
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (errString.contains("VTSUBM1"))
{
conn.commit();
System.out.println("@@@@ Transaction commit... ");
conn.close();
conn = null;
}
} catch (Exception e)
{
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("Last errString ["+errString+"]");
return errString;
}
private String checkNull(String input)
{
if (input == null)
{
input="";
}
return input.trim();
}
}
\ 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