Commit 46a9cd22 authored by manohar's avatar manohar

This commit was generated by cvs2svn to compensate for changes in r251,

which included commits to RCS files with non-trunk default branches.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91316 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f643f368
/********************************************************
Title : DeprRev
Date : 28/06/10
Author: sAkhtar
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.system.config.ConnDriver;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Timestamp;
import org.w3c.dom.*;
import ibase.webitm.ejb.fin.DeprRevLocal;
import ibase.webitm.ejb.fin.DeprRevRemote;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.utility.CommonConstants;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class DeprRev extends ProcessEJB implements DeprRevLocal , DeprRevRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
UtilMethods utilMethods = UtilMethods.getInstance();
/* public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Xform :getData() function called");
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :Xform :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = e.getMessage();
throw new ITMException( e );
}
return rtrStr;
}//END OF GETDATA(1)
public String process(Document dom1, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String deprReversal ="";
String siteCode = "";
String assetCode = "";
String postDate = "";
String dateUpto = "";
try
{
//taking values from dataWindow...............
siteCode = genericUtility.getColumnValue("site_code", dom1);
assetCode = genericUtility.getColumnValue("asset_code", dom1);
postDate = genericUtility.getColumnValue("post_date", dom1);
dateUpto = genericUtility.getColumnValue("date_upto", dom1);
deprReversal = deprReversal(siteCode, assetCode, xtraParams, postDate, dateUpto);
System.out.println("Returning from deprReversal process >>>> " + deprReversal );
}
catch (Exception e)
{
System.out.println("Exception in DeprRev process>>>> " +e);
e.printStackTrace();
throw new ITMException( e );
}
return deprReversal ;
}
//method deprReversal
private String deprReversal(String siteCode, String assetCode, String xtraParams, String postDate, String dateUpto)throws ITMException
{
String sql = "";
String errString = " ";
ResultSet rs = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
boolean status = false;
boolean detExist = false;
boolean recordExist = false;
boolean dateNotFound = false;
String acctPrd = "";
java.util.ArrayList<Double> wdvAmt2MthDetList = new java.util.ArrayList<Double>();
java.util.ArrayList<Double> wdvAmt2MonthList = new java.util.ArrayList<Double>();
java.util.ArrayList<Double> deprAmt2MonthList = new java.util.ArrayList<Double>();
java.util.ArrayList<Double> deprAmt2MthDetList = new java.util.ArrayList<Double>();
java.util.ArrayList<String> confirmedMonthList = new java.util.ArrayList<String>();
java.util.ArrayList<String> revJvMonthList = new java.util.ArrayList<String>();
java.util.ArrayList<Integer> noDaysMonthList = new java.util.ArrayList<Integer>();
java.util.ArrayList<Integer> noDaysMthDetList = new java.util.ArrayList<Integer>();
java.util.ArrayList<java.util.Date> fromDateList = new java.util.ArrayList<java.util.Date>();
java.util.ArrayList<java.util.Date> toDateList = new java.util.ArrayList<java.util.Date>();
String acctCode = "";
String cctrCode = "";
String acctCctrCode = "";
String finEntity = "";
String currCode = "";
Double exchRate = 0.0;
int rowCountMonth = 0;
int i = 0;
int listIndex = -1;
int noDays = 0;
int daysAll = 0;
int noDaysMnthDet = 0;
int rowDel = 0;
Double totalValue = 0.0;
Double deprAmt2MthDet = 0.0;
Double wdvAmt2MthDet = 0.0;
Double wdvAmt2Month = 0.0;
StringBuffer xmlBuff = new StringBuffer();
String xmlString = null;
String tranId = "";
int lineNo = 1;
int accDays = 0;
Double newDepAmt2 = 0.0;
Double newDepAmt2Det = 0.0;
Double accDepr = 0.0;
Double accDeprNet = 0.0;
Double DeprAmt2Whole = 0.0;
Double wdvAmt2Incr = 0.0;
Double DepAmt2Hdr = 0.0;
Double amount = 0.0;
String itemCode= "";
String itemSer= "";
String purpose= "DEPR";
String tranType= "";
int pos = 0;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
int rowCnt = 0;
String prdCode = "";
int rCount = 0;
String assetPrdCode = "";
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
ibase.system.config.ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit( false );
connDriver = null;
FinCommon fn = new FinCommon();
errString = itmDBAccessEJB.getErrorString("","PROCFAILED","","",conn);
GenericUtility genericUtility = GenericUtility.getInstance();
java.util.Date date = null;
java.util.Date dateUptoValue = null;
java.util.Date dateAssetPrdCode = null;
java.util.Date frDateDummy = null;
java.util.Date toDateDummy = null;
java.util.Date frDate = null;
java.util.Date toDate = null;
java.util.Date toDateDet = null;
Timestamp timestamp = null;
Timestamp timestampFrDummy = null;
Timestamp timestampToDummy = null;
Timestamp timestampUpto = null;
Timestamp timestampAsset = null;
Timestamp timestampTo = null;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
if(true)
{
if ((isEmpty(postDate)) ||(isEmpty(dateUpto)))
{
errString = itmDBAccessEJB.getErrorString("","EPDVUD","","",conn);
}
else
{
// seting time stamp in database without time but time replaced by 00:00:00
date = sdf.parse(postDate);
dateUptoValue = sdf.parse(dateUpto);
//calculating days
java.util.Calendar c = java.util.Calendar.getInstance();
c.setTime(dateUptoValue);
noDays = c.get(java.util.Calendar.DATE);
System.out.println("noDays >" +noDays);
date = simpleDateFormat.parse(simpleDateFormat.format(date));
timestamp = Timestamp.valueOf(simpleDateFormat.format(date).toString() + " 00:00:00.0");
dateUptoValue = simpleDateFormat.parse(simpleDateFormat.format(dateUptoValue));
timestampUpto = Timestamp.valueOf(simpleDateFormat.format(dateUptoValue).toString() + " 00:00:00.0");
sql = "select acct_prd, fr_date, to_date, code from period where ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, timestampUpto);
rs = pstmt.executeQuery();
if(rs.next())
{
acctPrd = rs.getString("acct_prd");
frDate = sdf.parse(sdf.format(rs.getDate("fr_date")));
toDate = sdf.parse(sdf.format(rs.getDate("to_date")));
prdCode = rs.getString("code");
status = true;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// validation of date
// if(frDate.after(dateUptoValue)||dateUptoValue.after(toDate))
// {
// errString = itmDBAccessEJB.getErrorString("","IVUTD","","",conn);
//
// }else
// {
// status = true;
// }
//seting prd for parrent process but decresed by one
if(status)
{
c.setTime(frDate);
c.add(java.util.Calendar.DATE , -1 );
// c.getTime();
dateAssetPrdCode = simpleDateFormat.parse(simpleDateFormat.format(c.getTime()));
timestampAsset = Timestamp.valueOf(simpleDateFormat.format(dateAssetPrdCode).toString() + " 00:00:00.0");
//
sql ="select code from period where to_date = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, timestampAsset);
rs = pstmt.executeQuery();
if(rs.next())
{
assetPrdCode = rs.getString("code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
status = true;
}
}
}
if(status)
{
// taking other not null details >--> std_exrt, curr_code, fin_entity
sql ="select c.std_exrt ,b.curr_code, a.fin_entity from site a, finent b , currency c where a.fin_entity = b.fin_entity"
+ " and b.curr_code =c.curr_code and a.site_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
exchRate = rs.getDouble(1);
currCode= rs.getString(2);
finEntity = rs.getString(3);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select item_ser, item_code, grp_code from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, assetCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemSer = rs.getString("item_ser");
itemCode = rs.getString("item_code");
tranType = rs.getString("grp_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//added on 19 july
sql = "delete from asset_depr_month a where exists "
+ "(select code from period p where a.prd_code = p.code "
+ "and a.site_code = ? and a.asset_code = ? and a.acct_prd = ? and a.confirmed = ? and "
+ "p.fr_date >= (select i.fr_date from period i where i.code = ?))";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, assetCode);
pstmt.setString(3, acctPrd);
pstmt.setString(4, "N");
pstmt.setString(5, prdCode);
rowDel = pstmt.executeUpdate();
//REMOVED ON 17 JULY nullyfies amount which have Confirmed N
////nullyfies amount which have Confirmed N
// sql = "update asset_depr_month set depr_amt_2 = ?, wdv_amt_2 = ? , confirmed = ? , rev_jv = ? where site_code = ? and asset_code = ? and acct_prd = ? and prd_code >= ? and confirmed = ? ";
//
// pstmt = conn.prepareStatement(sql);
//// pstmt.setDouble(1, (totalValue - wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)));
// pstmt.setDouble(1, 0);
//// pstmt.setDouble(2, wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
// pstmt.setDouble(2, 0); //calculate
////optional added noDays by self remove if say..
//// pstmt.setInt(3, ( noDays -1));
// pstmt.setString(3, "Y");
// pstmt.setString(4, "P");
// pstmt.setString(5, siteCode);
// pstmt.setString(6, assetCode);
// pstmt.setString(7, acctPrd);
// pstmt.setString(8, prdCode);
// pstmt.setString(9, "N");
// pstmt.executeUpdate();
// Finding account Code & Cost center Code for Credit Amount
acctCctrCode = fn.getAcctDetrTtype(itemCode, itemSer, purpose, tranType, conn).trim() ;
System.out.println("acctCctrCode >>>> " + acctCctrCode);
pos = acctCctrCode.indexOf(",");
cctrCode = acctCctrCode.substring(pos+1);
System.out.println("cctrCode >>>> " + cctrCode);
acctCode = acctCctrCode.substring(0,pos).trim();
System.out.println("acctCode >>>> " + acctCode);
// sql = "select p.fr_date, a.wdv_amt_2, a.total_value, a.confirmed "
// + "from asset_depr_month a, period p "
// + "where a.prd_code = p.code "
// + "and a.site_code = ? "
// + "and a.asset_code = ? "
// + "and a.acct_prd = ? "
// + "and p.fr_date >= (select i.fr_date from period i where i.code = ? ) "
// + "order by p.fr_date desc" ;
sql = "select p.fr_date, a.no_days, a.depr_amt_2, a.wdv_amt_2, a.confirmed, a.rev_jv "
+ "from asset_depr_month a, period p "
+ "where a.prd_code = p.code "
+ "and a.site_code = ? "
+ "and a.asset_code = ? "
+ "and a.acct_prd = ? "
+ "and p.fr_date >= (select i.fr_date from period i where i.code = ? ) "
+ "order by p.fr_date desc" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, assetCode);
pstmt.setString(3, acctPrd);
// pstmt.setString(4, "Y");
pstmt.setString(4, prdCode);
rs = pstmt.executeQuery();
//may be redundent
status = false;
i = 0;
while(rs.next())
{
// recordExist = true; //on 17 july 5:30 pm
//on 14 july 4:50 pm comment start
/*
if((isEmpty(rs.getString("confirmed")))||!("Y".equalsIgnoreCase(rs.getString("confirmed").trim())))
{
System.out.println("Record is not confirmed, deprReversal process failed >>>> ");
errString = itmDBAccessEJB.getErrorString("","PFAILRNC","","",conn);
status = false;
break;
}
*/
//on 14 july 4:50 pm comment end
// wdvAmt2MonthList.add(i,rs.getDouble("wdv_amt_2"));
// deprAmt2MonthList
// System.out.println("wdvAmt2MonthList.get(i) >>>> " + wdvAmt2MonthList.get(i) + "i" +i);
// totalValue = rs.getDouble("total_value");
// System.out.println("totalValue " + totalValue);
//ADDED ON 17 JULY FOR EXECUTION FOR FIRST TIME REVERSAL
if((!isEmpty(rs.getString("confirmed")))&&("Y".equalsIgnoreCase(rs.getString("confirmed").trim())))
{
recordExist = true;
deprAmt2MonthList.add(i,rs.getDouble("depr_amt_2"));
// calculating wdv on 16 july
wdvAmt2MonthList.add(i,rs.getDouble("wdv_amt_2"));
// calculating wdv on 16 july
noDaysMonthList.add(i,rs.getInt("no_days"));
confirmedMonthList.add(i,rs.getString("confirmed"));
revJvMonthList.add(i,rs.getString("rev_jv"));
i++;
}
status = true;
// recordExist = true;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//added on 14 july 4:50 pm start
//record already confirmed or insufficient nos of days
// if(( noDaysMonthList.size()==1) && ("Y".equalsIgnoreCase(rs.getString("confirmed").trim())) && ( (isEmpty(rs.getString("rev_jv")))||("Y".equalsIgnoreCase(rs.getString("rev_jv").trim()))))
if(( noDaysMonthList.size()==1) && ("Y".equalsIgnoreCase(confirmedMonthList.get(0).trim())) && ( ("Y".equalsIgnoreCase(revJvMonthList.get(0) == null ? "":revJvMonthList.get(0).trim()))))
{
errString = itmDBAccessEJB.getErrorString("","ISMRAO","","",conn); // IN SAME MONTH REVERSAL ALLOWED ONCE
status = false ;
}
// if(( noDaysMonthList.size() > 0) &&("Y".equalsIgnoreCase(rs.getString("confirmed").trim())) && ( ("P".equalsIgnoreCase(rs.getString("rev_jv") == null ? "":rs.getString("rev_jv").trim()))))
// if(( noDaysMonthList.size() > 1) &&("Y".equalsIgnoreCase(confirmedMonthList.get(0).trim())) && ( ("P".equalsIgnoreCase(revJvMonthList.get(0) == null ? "":revJvMonthList.get(0).trim()))))
// {
//// errString = itmDBAccessEJB.getErrorString("","ISMRAO","","",conn); // PROCESS SUCESS dEFAULT
//// errString = itmDBAccessEJB.getErrorString("","PROCSUCC","","",conn);
// status = true ; //sucess msg will not display
// }
// if(( noDaysMonthList.size()==1) && ("Y".equalsIgnoreCase(confirmedMonthList.get(0).trim())) && ( ("P".equalsIgnoreCase(revJvMonthList.get(0) == null ? "":revJvMonthList.get(0).trim()))))
// {
// errString = itmDBAccessEJB.getErrorString("","ISMRAO","","",conn); // IN SAME MONTH REVERSAL ALLOWED ONCE
// status = false ;
// }
//
//added on 14 july 4:50 pm start
// if((noDaysMonthList.size() > 0) && (noDaysMonthList.get(noDaysMonthList.size()-1) > (noDays -1)))
//
// if((isEmpty(rs.getString("confirmed")))||!("Y".equalsIgnoreCase(rs.getString("confirmed").trim())))
// {
// System.out.println("Record is not confirmed, deprReversal process failed >>>> ");
// errString = itmDBAccessEJB.getErrorString("","PFAILRNC","","",conn);
// status = false;
// }
// sql = "select to_date ,no_days, depr_amt_2, wdv_amt_2, total_value "
// + "from asset_depr_mthdet "
// + "where ? between from_date and to_date "
// + "and site_code = ? "
// + "and asset_code = ? "
// + "and acct_prd = ? "
// + "order by from_date desc" ;
//
// pstmt = conn.prepareStatement(sql);
// pstmt.setTimestamp(1, timestampUpto);
// pstmt.setString(2, siteCode);
// pstmt.setString(3, assetCode);
// pstmt.setString(4, acctPrd);
// rs = pstmt.executeQuery();
////may be redundent
//// status = true;
////set a flage in while may be this does not exist
// if(rs.next())
// {
//// i = 0;
//
//// fromDateList.add(i, sdf.parse(sdf.format(rs.getDate("from_date"))));
//// toDateList.add(i, sdf.parse(sdf.format(rs.getDate("to_date"))));
// toDateDet = sdf.parse(sdf.format(rs.getDate("to_date")));
//// deprAmt2MthDetList.add(i,rs.getDouble("depr_amt_2"));
// deprAmt2MthDet = rs.getDouble("depr_amt_2");
// System.out.println("deprAmt2MthDet >>>> " + deprAmt2MthDet );
//// noDaysMonthList.add(rs.getInt("no_days"));
// noDaysMnthDet = rs.getInt("no_days");
// System.out.println("noDaysMnthDet >>" + noDaysMnthDet);
//// wdvAmt2MthDetList.add(i,rs.getDouble("wdv_amt_2"));
// wdvAmt2MthDet = rs.getDouble("wdv_amt_2");
// totalValue = rs.getDouble("total_value");
// detExist = true;
//// i++;
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// calculating splited DepAmt2 check wrong ???????????
// calculating splited DepAmt2 check wrong ???????????amt sum wdv amt ? val data jv date mthdet first hdr del parent key vilation
//............ARRAY INDEX OUT OF BOND SO ALL LIST CALCULATION AFTER ROWCOUNT >0
// newDepAmt2Det = -((((deprAmt2MthDet)/(noDaysMnthDet)) * (noDaysMnthDet -noDays)));
////calculating splited DepAmt2 check wrong ???????????
//// calculating splited DepAmt2 check wrong ???????????amt sum wdv amt ? val data jv date mthdet first hdr del parent key vilation
////clculating accumulated depAmt
//
// accDeprNet = accDepr + deprAmt2MonthList.get(deprAmt2MonthList.size()-1) + newDepAmt2Det;
// wdvAmt2MthDet = wdvAmt2MthDet - newDepAmt2Det;
//new calculation
sql = "select from_date, to_date ,no_days, depr_amt_2, wdv_amt_2, total_value "
+ "from asset_depr_mthdet "
+ "where prd_code = ? "
+ "and site_code = ? "
+ "and asset_code = ? "
+ "and acct_prd = ? and depr_amt_2 > ? "
+ "order by from_date desc" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, assetCode);
pstmt.setString(4, acctPrd);
pstmt.setInt(5, 0);
rs = pstmt.executeQuery();
// may be redundent
// status = true;
// set a flage in while may be this does not exist
i = 0;
while(rs.next())
{
fromDateList.add(i, sdf.parse(sdf.format(rs.getDate("from_date"))));
toDateList.add(i, sdf.parse(sdf.format(rs.getDate("to_date"))));
deprAmt2MthDetList.add(i,rs.getDouble("depr_amt_2"));
noDaysMthDetList.add(i,rs.getInt("no_days"));
wdvAmt2MthDetList.add(i,rs.getDouble("wdv_amt_2"));
totalValue = rs.getDouble("total_value");
// status = true;
detExist = true;
i++;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// new calculation end
}
//Updation of Database
// if(status || (!recordExist))
if(status)
{
status = false;
//Delete Rows from asset_depr_month
sql = "delete from asset_depr_month a where exists "
+ "(select code from period p where a.prd_code = p.code "
+ "and a.site_code = ? and a.asset_code = ? and a.acct_prd = ? and "
+ "p.fr_date > (select i.fr_date from period i where i.code = ?))";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, assetCode);
pstmt.setString(3, acctPrd);
pstmt.setString(4, prdCode);
rowCnt = pstmt.executeUpdate();
//updation of asset_depr
// if(rowCnt > 0)
if(recordExist)
{
//Genrating xml for tran_id
// System.out.println(" wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)>> " + wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
// System.out.println("wdvAmt2MonthList.get(0) >>>>" + wdvAmt2MonthList.get(0));
// amount = wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1) - wdvAmt2MonthList.get(0) ;
// ............ARRAY INDEX OUT OF BOND SO ALL LIST CALCULATION AFTER ROWCOUNT >0
newDepAmt2 = (((deprAmt2MonthList.get(deprAmt2MonthList.size()-1))/(noDaysMonthList.get(noDaysMonthList.size()-1))) * (noDays -1));
DepAmt2Hdr = newDepAmt2; //actualy set it direct, it is not dec itia value to be set
wdvAmt2Incr = (deprAmt2MonthList.get(deprAmt2MonthList.size()-1)) - newDepAmt2;
// clculating accumulated depAmt
for(i=0; i < (deprAmt2MonthList.size()-1); i++)
{
accDepr += deprAmt2MonthList.get(i);
}
// either this
accDeprNet = accDepr +((deprAmt2MonthList.get(deprAmt2MonthList.size()-1) - newDepAmt2));
//calculating nos of days
for(i=0; i < (deprAmt2MonthList.size()-1); i++)
{
accDays += noDaysMonthList.get(i);
}
accDays += (noDaysMonthList.get(noDaysMonthList.size()-1) -noDays +1);
if(detExist)
{
// finding row coresponding up_to_date
for( i = 0; i< fromDateList.size(); i++)
{
if(!(fromDateList.get(i).after(dateUptoValue)||dateUptoValue.after(toDateList.get(i))))
{
listIndex = i;
break;
}
}
if(listIndex == -1)
{
detExist = false;
dateNotFound = true;
}
}
if(detExist)
{
//added new calculation
//.........................................................
//fractional negative depAmt
//ON 12 JULY newDepAmt2Det = -((((deprAmt2MthDetList.get(listIndex))/(noDaysMthDetList.get(listIndex))) * (noDays)));
java.util.Calendar calc = java.util.Calendar.getInstance();
calc.setTime(toDateList.get(listIndex));
newDepAmt2Det = -((((deprAmt2MthDetList.get(listIndex))/(noDaysMthDetList.get(listIndex))) * ((((calc.get(java.util.Calendar.DATE)) - noDays) +1))));
//whole negative depAmt DeprAmt2Whole
if(listIndex >0)
{
for(i=0; i < listIndex; i++)
{
DeprAmt2Whole += deprAmt2MthDetList.get(i);
}
//calculating nos of day according to last period in detail noDaysMthDetList
for(i=0; i < listIndex; i++)
{
daysAll += noDaysMthDetList.get(i);
}
}
newDepAmt2Det = newDepAmt2Det - DeprAmt2Whole;
accDeprNet = accDepr - newDepAmt2Det;
wdvAmt2MthDet = wdvAmt2MthDetList.get(listIndex) - newDepAmt2Det;
//added on 17 july for preventing update when Record N
/* if(DepAmt2Hdr != 0)
{
*/ DepAmt2Hdr = deprAmt2MonthList.get(deprAmt2MonthList.size()-1) + newDepAmt2Det;
/*
}
*/
// DepAmt2Hdr = deprAmt2MonthList.get(deprAmt2MonthList.size()-1) + newDepAmt2;
wdvAmt2Incr = - newDepAmt2Det;
//end new calculation
// newDepAmt2Det = -((((deprAmt2MthDet)/(noDaysMnthDet)) * (noDaysMnthDet -noDays)));
//newDepAmt2Det = -((((deprAmt2MthDet)/(noDaysMnthDet)) * (noDays)));
// calculating splited DepAmt2 check wrong ???????????
// calculating splited DepAmt2 check wrong ???????????amt sum wdv amt ? val data jv date mthdet first hdr del parent key vilation
// clculating accumulated depAmt
//accDeprNet = accDepr + deprAmt2MonthList.get(deprAmt2MonthList.size()-1) + newDepAmt2Det;
//wdvAmt2MthDet = wdvAmt2MthDet - newDepAmt2Det;
//DepAmt2Hdr = deprAmt2MonthList.get(deprAmt2MonthList.size()-1) + newDepAmt2;
//wdvAmt2Incr = - newDepAmt2Det;
//updation of asset_depr_mthdet
// sql = "insert into asset_depr_mthdet (tran_id, line_no, acct_code, cctr_code,drcr_flag, amount, sundry_type) "
// + "values(?, ?, ?, ?, ?, ?, ?)";
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("deprtrace").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\"").append(" objName=\"deprtrace\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[").append(postDate).append("]]></tran_date>");
xmlBuff.append("<site_code><![CDATA[").append(siteCode).append("]]></site_code>");
xmlBuff.append("</Detail1>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
tranId = getUniqueKey(xmlString, xtraParams, "t_deprtrace", conn) ;
toDateDet = simpleDateFormat.parse(simpleDateFormat.format(toDateList.get(0)));
timestampTo = Timestamp.valueOf(simpleDateFormat.format(toDateDet).toString() + " 00:00:00.0");
// java.util.Calendar calc = java.util.Calendar.getInstance();
calc.setTime(toDateList.get(listIndex));
// noDays = calc.get(java.util.Calendar.DATE);
sql = "insert into asset_depr_mthdet (tran_id, from_date, to_date, asset_code, acct_prd, prd_code, no_days, total_value, item_ser, grp_code, site_code, depr_amt_2, wdv_amt_2) "
+ "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//start genrating XML for tranId
//End genrating XML for tranId
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId); //calc
pstmt.setTimestamp(2,timestampUpto);
pstmt.setTimestamp(3,timestampTo);
pstmt.setString(4,assetCode);
pstmt.setString(5,acctPrd);
pstmt.setString(6,prdCode);
pstmt.setInt(7,(((calc.get(java.util.Calendar.DATE)) - noDays) +1)+ daysAll);
pstmt.setDouble(8,totalValue);
pstmt.setString(9,itemSer);
pstmt.setString(10,tranType);
pstmt.setString(11,siteCode);
//added for exject trace 17 july for record N
/* if(DepAmt2Hdr != 0)
{
*/ pstmt.setDouble(12,newDepAmt2Det);
pstmt.setDouble(13,(-newDepAmt2Det));
/*
}else
{
pstmt.setDouble(12,0.0);
pstmt.setDouble(13,0.0);
}
*/ pstmt.executeUpdate();
//sop since tranid not known
// System.out.println(" tranId " + tranId);
// System.out.println(" timestampUpto " + timestampUpto);
// System.out.println(" timestampTo " + timestampTo);
// System.out.println(" assetCode " + assetCode);
// System.out.println(" acctPrd " + acctPrd);
// System.out.println(" prdCode " + prdCode);
// System.out.println(" (noDaysMnthDet - noDays) " + (noDaysMnthDet - noDays));
// System.out.println(" totalValue " + totalValue);
// System.out.println(" itemSer " + itemSer);
// System.out.println(" tranType " + tranType);
// System.out.println(" siteCode " + siteCode);
// System.out.println(" newDepAmt2Det " + newDepAmt2Det);
// System.out.println(" wdvAmt2MthDet " + wdvAmt2MthDet);
//start finding and reversing amount etc....
//removed on 16 july due to loss
/* sql = "select from_date, to_date ,no_days, depr_amt_2, wdv_amt_2, total_value "
+ "from asset_depr_mthdet "
+ "where prd_code > ? "
+ "and site_code = ? "
+ "and asset_code = ? "
+ "and acct_prd = ? and depr_amt_2 > ? "
+ "order by from_date desc" ;
*/// removed on 16 july due to loss
sql = "select from_date, to_date ,no_days, depr_amt_2, wdv_amt_2, total_value "
+ "from asset_depr_mthdet "
+ "where prd_code > ? "
+ "and site_code = ? "
+ "and asset_code = ? "
+ "and acct_prd = ? "
+ "order by from_date desc" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, assetCode);
pstmt.setString(4, acctPrd);
// pstmt.setInt(5, 0); //balancing loss
rs = pstmt.executeQuery();
while(rs.next())
{
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("deprtrace").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\"").append(" objName=\"deprtrace\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[").append(postDate).append("]]></tran_date>");
xmlBuff.append("<site_code><![CDATA[").append(siteCode).append("]]></site_code>");
xmlBuff.append("</Detail1>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
tranId = getUniqueKey(xmlString, xtraParams, "t_deprtrace", conn) ;
System.out.println("tranId >>>> " + tranId);
sql = "insert into asset_depr_mthdet (tran_id, from_date, to_date, asset_code, acct_prd, prd_code, no_days, total_value, item_ser, grp_code, site_code, depr_amt_2, wdv_amt_2) "
+ "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,tranId); ///each time diffrent calc
//this should be like that because next tran_id will genrate when perivous get
// insert in db
frDateDummy = sdf.parse(sdf.format(rs.getDate("from_date")));
frDateDummy = simpleDateFormat.parse(simpleDateFormat.format(frDateDummy));
timestampFrDummy = Timestamp.valueOf(simpleDateFormat.format(frDateDummy).toString() + " 00:00:00.0");
pstmt1.setTimestamp(2,timestampFrDummy);
toDateDummy = sdf.parse(sdf.format(rs.getDate("to_date")));
toDateDummy = simpleDateFormat.parse(simpleDateFormat.format(toDateDummy));
timestampToDummy = Timestamp.valueOf(simpleDateFormat.format(toDateDummy).toString() + " 00:00:00.0");
pstmt1.setTimestamp(3,timestampToDummy);
pstmt1.setString(4,assetCode);
pstmt1.setString(5,acctPrd);
pstmt1.setString(6,prdCode);
pstmt1.setInt(7,rs.getInt("no_days"));
pstmt1.setDouble(8,rs.getDouble("total_value"));
pstmt1.setString(9,itemSer);
pstmt1.setString(10,tranType);
pstmt1.setString(11,siteCode);
pstmt1.setDouble(12,(-rs.getDouble("depr_amt_2")));
pstmt1.setDouble(13,(+rs.getDouble("depr_amt_2")));
pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//end finding and reversing amount etc....
}
//added for Record N
/* if( DepAmt2Hdr != 0)
{
*/ amount = accDeprNet;
/*
}else
{
amount = 0.0;
}
*/ System.out.println(" amount " + amount);
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("journal").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\"").append(" objName=\"journal\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[").append(postDate).append("]]></tran_date>");
xmlBuff.append("<site_code><![CDATA[").append(siteCode).append("]]></site_code>");
xmlBuff.append("<line_no><![CDATA[").append(lineNo).append("]]></line_no>");
xmlBuff.append("<acct_code><![CDATA[").append(acctCode).append("]]></acct_code>");
xmlBuff.append("<cctr_code><![CDATA[").append(cctrCode).append("]]></cctr_code>");
xmlBuff.append("<drcr_flag><![CDATA[").append("C").append("]]></drcr_flag>");
xmlBuff.append("<amount><![CDATA[").append(amount).append("]]></amount>");
xmlBuff.append("</Detail1>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
//End of Genrating xml for tran_id
xmlString = xmlBuff.toString();
tranId = getUniqueKey(xmlString, xtraParams, "w_journal", conn) ;
sql = "update asset_depr set depr_amt_2 = depr_amt_2 + ? , wdv_amt_2 = wdv_amt_2 + ?, no_days = no_days + ?, prd_code__upto = ? where site_code = ? and asset_code = ? and acct_prd = ?";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1, (totalValue - wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)));
pstmt.setDouble(1, (-amount));
// pstmt.setDouble(2, wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
pstmt.setDouble(2, amount);
pstmt.setInt(3, (- accDays));
pstmt.setString(4, assetPrdCode);
pstmt.setString(5, siteCode);
pstmt.setString(6, assetCode);
pstmt.setString(7, acctPrd);
pstmt.executeUpdate();
//updation of asset_depr_month
// sql = "update asset_depr_month set depr_amt_2 = ?, wdv_amt_2 = wdv_amt_2 + ?, no_days = ?, rev_jv = ? where site_code = ? and asset_code = ? and acct_prd = ? and prd_code = ?";
//calculation of wdv amt on 16 july
for(int j = 0; j< wdvAmt2MonthList.size()-1 ; j++ )
{
wdvAmt2Month += deprAmt2MonthList.get(j);
}
wdvAmt2Month += deprAmt2MonthList.get(deprAmt2MonthList.size()-1)- DepAmt2Hdr;
System.out.println("final wdvAmt2Month" + wdvAmt2Month);
sql = "update asset_depr_month set depr_amt_2 = ?, wdv_amt_2 = wdv_amt_2 + ?, no_days = ?, rev_jv = ? where site_code = ? and asset_code = ? and acct_prd = ? and prd_code = ?";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1, (totalValue - wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)));
pstmt.setDouble(1, DepAmt2Hdr);
// pstmt.setDouble(2, wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
// pstmt.setDouble(2, amount); //calculate
//added for Record not confirm
/* if(DepAmt2Hdr != 0)
{
*/ pstmt.setDouble(2, wdvAmt2Month); //added on 16 july
/* }else
{
pstmt.setDouble(2, 0.0); //added on 16 july
}
*/
//optional added noDays by self remove if say..
pstmt.setInt(3, ( noDays -1));
pstmt.setString(4, "Y");
pstmt.setString(5, siteCode);
pstmt.setString(6, assetCode);
pstmt.setString(7, acctPrd);
pstmt.setString(8, prdCode);
rowCountMonth = pstmt.executeUpdate();
//updation of ASSET_REGISTER
sql = "update asset_register set depr_amt_2 = depr_amt_2 + ?, wdv_amt_2 = wdv_amt_2 + ? where site_code = ? and asset_code = ? ";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1, (totalValue - wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)));
// pstmt.setDouble(1, newDepAmt2);
pstmt.setDouble(1, (-amount));
// pstmt.setDouble(2, wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
// pstmt.setDouble(2, accDeprNet);
pstmt.setDouble(2, amount);
pstmt.setString(3, siteCode);
pstmt.setString(4, assetCode);
pstmt.executeUpdate();
// updation of journal
sql = "insert into journal (tran_id, tran_date, eff_date, fin_entity, curr_code, exch_rate, dr_amt, cr_amt, remarks, reversible, rev_date, status, confirmed, emp_code__aprv, site_code) "
+ "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setTimestamp(2,timestamp);
pstmt.setTimestamp(3,timestamp);
pstmt.setString(4,finEntity);
pstmt.setString(5,currCode);
pstmt.setDouble(6,exchRate);
pstmt.setDouble(7,amount);
pstmt.setDouble(8,amount);
pstmt.setString(9," ");
pstmt.setString(10,"N");
pstmt.setTimestamp(11,timestamp);
pstmt.setString(12,"A");
pstmt.setString(13,"N");
pstmt.setString(14,genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
pstmt.setString(15,siteCode);
pstmt.executeUpdate();
// updation of jourdet for line_no=1
sql = "insert into jourdet (tran_id, line_no, acct_code, cctr_code,drcr_flag, amount, sundry_type) "
+ "values(?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,lineNo);
pstmt.setString(3,acctCode);
pstmt.setString(4,cctrCode);
pstmt.setString(5,"C");
pstmt.setDouble(6,amount);
pstmt.setString(7,"O");
pstmt.executeUpdate();
// Finding account Code & Cost center Code for Debit Amount
acctCctrCode = fn.getAcctDetrTtype(itemCode, itemSer, "ACCDEPR", tranType, conn).trim() ;
System.out.println("acctCctrCode >>>> " + acctCctrCode);
pos = acctCctrCode.indexOf(",");
cctrCode = acctCctrCode.substring(pos+1);
System.out.println("cctrCode >>>> " + cctrCode);
acctCode = acctCctrCode.substring(0,pos).trim();
System.out.println("acctCode >>>> " + acctCode);
// updation of jourdet for line_no = 2
lineNo = 2;
sql = "insert into jourdet (tran_id, line_no, acct_code, cctr_code,drcr_flag, amount, sundry_type) "
+ "values(?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,lineNo);
pstmt.setString(3,acctCode);
pstmt.setString(4,cctrCode);
pstmt.setString(5,"D");
pstmt.setDouble(6,amount);
pstmt.setString(7,"O");
pstmt.executeUpdate();
//ON 17 JULY
status = true;
}
// else
// {
// System.out.println("No Such Record Found >>>>>>>>>>>>>>>>> ");
// errString = itmDBAccessEJB.getErrorString("","NDF","","",conn);
//
// }
}
// nullyfies amount which have Confirmed N
if(!(rowCountMonth > 0))
{
sql = "update asset_depr_month set depr_amt_2 = ?, wdv_amt_2 = ? , confirmed = ? , rev_jv = ? , no_days = ? where site_code = ? and asset_code = ? and acct_prd = ? and prd_code >= ? and confirmed = ? ";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1, (totalValue - wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1)));
pstmt.setDouble(1, 0);
// pstmt.setDouble(2, wdvAmt2MonthList.get(wdvAmt2MonthList.size()-1));
pstmt.setDouble(2, 0); //calculate
// optional added noDays by self remove if say..
// pstmt.setInt(3, ( noDays -1));
pstmt.setString(3, "Y");
pstmt.setString(4, "P");
pstmt.setInt(5, 0);
pstmt.setString(6, siteCode);
pstmt.setString(7, assetCode);
pstmt.setString(8, acctPrd);
pstmt.setString(9, prdCode);
pstmt.setString(10, "N");
rCount = pstmt.executeUpdate();
if(rCount > 0)
{
status = true;
}
}
if(rowDel > 0)
{
status = true;
}
if(!recordExist && (!(rowDel > 0)))
{
System.out.println("No Such Record Found for confirmed Y >>>>>>>>>>>>>>>>> ");
errString = itmDBAccessEJB.getErrorString("","NDF","","",conn);
}
if(status && !dateNotFound)
{
System.out.println("committing>>>>>>>>>>>>>>>>> " + status);
conn.commit();
// conn.rollback();
conn.close();
conn = null;
System.out.println("Connection has been closed >>>>>>>>>>>>>>>>>>>>>>>>> ");
errString = itmDBAccessEJB.getErrorString("","PROCSUCC","","",conn);
System.out.println("deprReversal process sucessfully completed >>>> ");
}else
{
System.out.println("rollbacking >>>>>>>>>>>>>>>>> " + status);
conn.rollback();
conn.close();
conn = null;
}
if(dateNotFound)
{
errString = itmDBAccessEJB.getErrorString("","NDF","","",conn);
//change if say
}
}
catch (SQLException se)
{
System.out.println("SQL Exception in deprReversal method >>>> " + se.getMessage());
throw new ITMException( se );
}
catch (ITMException itm)
{
System.out.println("ITM Exception in deprReversal method >>>> " + itm.getMessage());
throw new ITMException( itm );
}
catch (Exception e)
{
System.out.println("Exception in deprReversal method >>>> " + e.getMessage());
throw new ITMException( e );
}
finally
{
try{
if(conn != null)
{
if(rs != null )
{
rs.close();
}
rs = null;
if(pstmt != null )
{
pstmt.close();
}
pstmt = null;
System.out.println("InSide finallly.. rollbacking >>>>>>>>>>>>>>>>> ");
conn.rollback();
conn.close();
System.out.println("InSide finallly.. Connection has been closed >>>>>>>>>>>>>>>>>>>>>>>>> ");
}
conn = null;
}catch(SQLException se)
{
System.out.println("SQL Exception in finaly >>>> " + se.getMessage());
throw new ITMException( se );
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
return errString;
}
//method to Genrate tran_id
private String getUniqueKey(String xmlValues,String xtraParams ,String tranWindow,Connection conn)throws ITMException
{
String uniqueKey = null;
String sql = "";
java.sql.ResultSet rs = null;
java.sql.PreparedStatement pstmt = null;
String keyString = "";
String keyColumn = "";
String refSeries = "";
String userId = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
sql = "select key_string, tran_id_col, ref_ser from transetup where tran_window = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranWindow);
rs = pstmt.executeQuery();
if(rs.next())
{
keyString = rs.getString("key_String");
keyColumn = rs.getString("tran_id_col");
refSeries = rs.getString("ref_ser");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
TransIDGenerator tg = new TransIDGenerator(xmlValues,userId, CommonConstants.DB_NAME);
uniqueKey = tg.generateTranSeqID(refSeries, keyColumn, keyString, conn);
}
catch(Exception e)
{
System.out.println("Exception :In DeprRev: getUniqueKey :==>\n" + e.getMessage());
e.printStackTrace();
uniqueKey = null;
throw new ITMException(e);
}
return uniqueKey;
}
//method to check if an entered string is empty
private boolean isEmpty(String enteredVal)
{
boolean isEmpty = false;
if(enteredVal == null)
{
isEmpty = true;
}
else if(enteredVal.trim().length() == 0)
{
isEmpty = true;
}
return isEmpty;
}
}
\ No newline at end of file
/********************************************************
Title : DeprRev
Date : 28/06/10
Author: sAkhtar
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface DeprRevLocal extends ProcessLocal
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : DeprRev
Date : 28/06/10
Author: sAkhtar
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DeprRevRemote extends ProcessRemote //,EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ 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