Commit 01009240 authored by Ketan Patil's avatar Ketan Patil

Replace CashVoucherCreateMisc.java

parent 579fe390
......@@ -42,7 +42,7 @@ public class CashVoucherCreateMisc extends ActionHandlerEJB implements CashVouch
UserInfoBean userInfoBean = null;
CommonFunctions commonFunctions = commonFunctions = new CommonFunctions();//added by bipin on 22/03/2010 [reason: To allow error & warning]
E12GenericUtility e12GenericUtilityObj = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String confirm() throws RemoteException,ITMException
{
return "";
......@@ -58,13 +58,21 @@ public class CashVoucherCreateMisc extends ActionHandlerEJB implements CashVouch
{
System.out.println("Confirm CashVoucherCreateMisc");
result =confirmCashVoucher(tranId, xtraParams,userinfo.toString(),conn);
System.out.println("result111==>"+result);
if(result.indexOf("CONFIRMED") == -1) {
System.out.println("IN IF");
return result;
}else {
System.out.println("IN ELSE");
return itmDBAccessEJB.getErrorString("tran_id", "VMVOUCNF", "BASE");
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
return result;
//return result;
}
public String confirm(String tranId,String xtraParams, String forcedFlag,String userInfo) throws RemoteException,ITMException //added by Ramagya On 10/08/2020[added userInfo parameter]
......@@ -106,13 +114,22 @@ public class CashVoucherCreateMisc extends ActionHandlerEJB implements CashVouch
result =confirmCashVoucher(tranId, xtraParams, userInfo , conn);
System.out.println("result==>"+result);
if(result.indexOf("CONFIRMED") == -1) {
System.out.println("IN IF");
return result;
}else {
System.out.println("IN ELSE");
return itmDBAccessEJB.getErrorString("tran_id", "VMVOUCNF", "BASE");
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
return result;
//return result;
}
private String confirmCashVoucher(String tranId, String xtraParams,String userInfo,Connection conn)throws RemoteException,Exception,ITMException
......@@ -250,6 +267,19 @@ public class CashVoucherCreateMisc extends ActionHandlerEJB implements CashVouch
}
rs.close();
rs=null;
sql="select emp_code as ecode from obj_sign_trans where ref_id= '"+tranId+"' and sign_status='S' ORDER by sign_date desc";
System.out.println("sql:::::::"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
empCodeAprv=rs.getString("ecode");
}
rs.close();
rs=null;
//=========pradeeep ==15/12/2008
if (netAmount > 20000)
{
......@@ -279,56 +309,106 @@ public class CashVoucherCreateMisc extends ActionHandlerEJB implements CashVouch
//conn.commit();
//end - bipin on 11/03/2010
//added by pravin nevage 20/9/22
retString = createHashmapForMiscVoucher(tranId,xtraParams,userId,bw,conn);
String vouchMiscId="";
String sql2 = "select tran_id__mvouch as mvouch from cash_voucher where tran_id=?";
PreparedStatement pstmt1 = conn.prepareStatement(sql2);
String sql22 = "select misc_voucher.tran_id as mvouch from misc_voucher,misc_vouchdet where misc_voucher.tran_id=misc_vouchdet.tran_id and misc_voucher.tran_type='CVH' and misc_voucher.order_ref= ? ";
PreparedStatement pstmt1 = conn.prepareStatement(sql22);
pstmt1.setString(1,tranId);
ResultSet rs2 = pstmt1.executeQuery();
if(rs2.next())
{
vouchMiscId=rs2.getString("mvouch");
}
System.out.println("vouchMiscId>>>>"+ vouchMiscId);
if(vouchMiscId!=null && vouchMiscId.trim().length() > 0) {
int updateCashVoucher=updateCashVoucher(tranId,vouchMiscId,empCodeAprv,conn);
System.out.println("updateCashVoucher : ["+updateCashVoucher+"]");
System.out.println("IN THIS");
return itmDBAccessEJB.getErrorString("tran_id", "VMVOUCNF", "BASE");
}else {
retString = createHashmapForMiscVoucher(tranId,xtraParams,userId,bw,conn);
System.out.println("retString==>"+retString);
String vouchMiscId1="";
String sql2 = "select misc_voucher.tran_id as mvouch from misc_voucher,misc_vouchdet where misc_voucher.tran_id=misc_vouchdet.tran_id and misc_voucher.tran_type='CVH' and misc_voucher.order_ref= ? ";
PreparedStatement pstmt11 = conn.prepareStatement(sql2);
pstmt11.setString(1,tranId);
ResultSet rs22 = pstmt11.executeQuery();
if(rs22.next())
{
vouchMiscId1=rs22.getString("mvouch");
System.out.println("vouchMiscId1>>>>"+ vouchMiscId1);
}
if(vouchMiscId!=null && vouchMiscId.trim().length() > 0)
if(vouchMiscId1!=null && vouchMiscId1.trim().length() > 0)
{
int updateCashVoucher=updateCashVoucher(tranId,empCode,conn);
int updateCashVoucher=updateCashVoucher(tranId,vouchMiscId1,empCodeAprv,conn);
System.out.println("updateCashVoucher : ["+updateCashVoucher+"]");
}else {
String sql11= "UPDATE CASH_VOUCHER SET CONFIRMED =?,CONF_DATE = ?,EMP_CODE__APRV = ? WHERE TRAN_ID =? ";
pstmt = conn.prepareStatement(sql11);
pstmt.setString(1,"N");
pstmt.setDate(2,null);
pstmt.setString(3,"");
pstmt.setString(3,empCodeAprv);
pstmt.setString(4,tranId);
System.out.println("Sql to confirm cash voucher"+sql1);
pstmt.executeUpdate();
System.out.println("IN ELSE 1");
}
pstmt11.close();
pstmt11=null;
rs22.close();
rs22=null;
}
pstmt1.close();
pstmt1=null;
rs2.close();
rs2=null;
//retString = createHashmapForMiscVoucher(tranId,xtraParams,userId,bw,conn);
/*
* String vouchMiscId=""; String sql2 =
* "select tran_id__mvouch as mvouch from cash_voucher where tran_id=?";
* PreparedStatement pstmt1 = conn.prepareStatement(sql2);
* pstmt1.setString(1,tranId); ResultSet rs2 = pstmt1.executeQuery();
* if(rs2.next()) { vouchMiscId=rs2.getString("mvouch");
* System.out.println("vouchMiscId>>>>"+ vouchMiscId); }
*
* if(vouchMiscId!=null && vouchMiscId.trim().length() > 0) { int
* updateCashVoucher=updateCashVoucher(tranId,empCodeAprv,conn);
* System.out.println("updateCashVoucher : ["+updateCashVoucher+"]"); }else {
* String sql11=
* "UPDATE CASH_VOUCHER SET CONFIRMED =?,CONF_DATE = ?,EMP_CODE__APRV = ? WHERE TRAN_ID =? "
* ; pstmt = conn.prepareStatement(sql11); pstmt.setString(1,"N");
* pstmt.setDate(2,null); pstmt.setString(3,empCodeAprv);
* pstmt.setString(4,tranId);
* System.out.println("Sql to confirm cash voucher"+sql1);
* pstmt.executeUpdate(); System.out.println("IN ELSE 1");
*
* } pstmt1.close(); pstmt1=null; rs2.close(); rs2=null;
*/
conn.commit();
}else {
String sql11= "UPDATE CASH_VOUCHER SET CONFIRMED =?,CONF_DATE = ?,EMP_CODE__APRV = ? WHERE TRAN_ID =? ";
pstmt = conn.prepareStatement(sql11);
pstmt.setString(1,"N");
pstmt.setDate(2,null);
pstmt.setString(3,"");
pstmt.setString(4,tranId);
System.out.println("Sql to confirm cash voucher"+sql1);
pstmt.executeUpdate();
System.out.println("IN ELSE");
conn.commit();
/*
* String sql11=
* "UPDATE CASH_VOUCHER SET CONFIRMED =?,CONF_DATE = ?,EMP_CODE__APRV = ? WHERE TRAN_ID =? "
* ; pstmt = conn.prepareStatement(sql11); pstmt.setString(1,"N");
* pstmt.setDate(2,null); pstmt.setString(3,empCodeAprv);
* pstmt.setString(4,tranId);
* System.out.println("Sql to confirm cash voucher"+sql1);
* pstmt.executeUpdate(); System.out.println("IN ELSE"); conn.commit();
*/
return itmDBAccessEJB.getErrorString("confirmed", "VMSIGN", userId);
return itmDBAccessEJB.getErrorString("status", "VMSIGN", userId);
}
//end by pravin nevage 20/9/22
......@@ -858,11 +938,21 @@ public String createHashmapForMiscVoucher(String tranID, String xtraParams, Stri
//throw new ITMException(new SQLException(retString) );
// }
}
String empCodeAprv1="";
sql="select emp_code as ecode from obj_sign_trans where ref_id= '"+tranID+"' ORDER by sign_date desc";
System.out.println("sql22:::::::"+sql);
rs2 = stmt2.executeQuery(sql);
if (rs2.next())
{
empCodeAprv1=rs2.getString("ecode");
}
rs2.close();
rs2=null;
headerMap.put("confirmed","N");
headerMap.put("conf_date",dtf.format(new java.sql.Date(new java.util.Date().getTime())));
headerMap.put("emp_code__aprv","");
headerMap.put("emp_code__aprv",empCodeAprv1);
//headerMap.put("sundry_type__pay","E"); //Commented by Ahmed on 28/08/2015 [already added above]
headerMap.put("cr_term",CR_TERM);
//start - bipin on 16/02/2010 [reason: commented by bipin on 16/02/2010]
......@@ -1192,7 +1282,7 @@ closeStatement(stmt);
java.text.SimpleDateFormat dtf= new SimpleDateFormat(format);
//Haneesh 02/11/09 end
Statement stmt1,stmt2=null;
ResultSet rs1,rs2=null;
ResultSet rs1,rs2=null,rs22=null;
String sql1=null;
String columnName = "";
......@@ -1456,7 +1546,7 @@ closeStatement(stmt);
return advAcctCode;
}
private int updateCashVoucher(String tranID,String emploginCode,Connection conn) throws Exception
private int updateCashVoucher(String tranID,String empCodeAprv,Connection conn) throws Exception
{
PreparedStatement pstmt=null;
int confirmCashVoucher=0;
......@@ -1466,7 +1556,7 @@ closeStatement(stmt);
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,"Y");
pstmt.setDate(2,new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(3,emploginCode);
pstmt.setString(3,empCodeAprv);
pstmt.setString(4,tranID);
System.out.println("Sql to confirm cash voucher"+sql1);
confirmCashVoucher = pstmt.executeUpdate();
......@@ -1483,6 +1573,35 @@ closeStatement(stmt);
}
return confirmCashVoucher;
}
private int updateCashVoucher(String tranID,String miscVouchId,String empCodeAprv,Connection conn) throws Exception
{
PreparedStatement pstmt=null;
int confirmCashVoucher=0;
try
{
String sql1= "UPDATE CASH_VOUCHER SET CONFIRMED =?,CONF_DATE = ?,EMP_CODE__APRV = ?,tran_id__mvouch=? WHERE TRAN_ID =? ";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,"Y");
pstmt.setDate(2,new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(3,empCodeAprv);
pstmt.setString(4,miscVouchId);
pstmt.setString(5,tranID);
System.out.println("Sql to confirm cash voucher"+sql1);
confirmCashVoucher = pstmt.executeUpdate();
System.out.println("confirmCashVoucher : ["+confirmCashVoucher+"]");
}
catch(Exception e)
{
System.out.println("Exception in updateCashVoucher :"+e.getMessage());
}
finally
{
if(pstmt != null){pstmt.close();pstmt=null;}
System.out.println("finally in updateCashVoucher :");
}
return confirmCashVoucher;
}
//end - bipin on 08/03/2010
//start - bipin on 15/10/2010
......
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