Commit 285a1273 authored by vvengurlekar's avatar vvengurlekar

MiscPayablesHld.java - all commented part removed

MiscPayablesRls.java, MiscPayablesRlsLocal.java, MiscPayablesRlsRemote.java - new component added for release


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@181890 ce508802-f39f-4f6c-b175-0d175dae99d5
parent fb84ed46
/* /*
Window Name : w_misc_voucher Window Name : w_misc_payables_hold
Button Name : Hold Button Name : Hold
Action : Put Voucher on hold i.e it will update MISC_PAYABLES Table. Action : Put Voucher on hold i.e it will update MISC_PAYABLES Table.
*/ */
package ibase.webitm.ejb.fin.adv; package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException; import ibase.webitm.ejb.ActionHandlerEJB;
import java.sql.*; import ibase.webitm.ejb.ITMDBAccessEJB;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.util.Calendar;
import javax.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.system.config.*;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import javax.ejb.Stateless; // added for ejb3 import java.rmi.RemoteException;
import javax.naming.InitialContext; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.w3c.dom.Document; import javax.ejb.Stateless;
// added for ejb3
@Stateless // added for ejb3 @Stateless // added for ejb3
public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldLocal,MiscVoucherHldRemote //SessionBean public class MiscPayablesHld extends ActionHandlerEJB implements MiscPayablesHldLocal,MiscPayablesHldRemote
{ {
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException public String actionHandler() throws RemoteException,ITMException
{ {
return ""; return "";
...@@ -72,7 +47,7 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL ...@@ -72,7 +47,7 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL
private String actionHold(String tranID, String xtraParams)throws ITMException private String actionHold(String tranID, String xtraParams)throws ITMException
{ {
Connection conn = null; Connection conn = null;
Statement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
String errCode=""; String errCode="";
String errString=""; String errString="";
...@@ -85,43 +60,45 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL ...@@ -85,43 +60,45 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL
float balAmt=0; float balAmt=0;
try try
{ {
//Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
sql="SELECT TOT_AMT,ADJ_AMT,CASE WHEN HOLD_AMT IS NULL THEN 0 ELSE HOLD_AMT END HOLD_AMT FROM MISC_PAYABLES WHERE TRAN_ID = '"+tranID+"'"; sql="SELECT TOT_AMT,ADJ_AMT,CASE WHEN HOLD_AMT IS NULL THEN 0 ELSE HOLD_AMT END HOLD_AMT FROM MISC_PAYABLES WHERE TRAN_ID = ?";
rs = stmt.executeQuery(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, tranID);
rs = stmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
totAmt=rs.getFloat("TOT_AMT"); totAmt=rs.getFloat("TOT_AMT");
adjAmt=rs.getFloat("ADJ_AMT"); adjAmt=rs.getFloat("ADJ_AMT");
holdAmt=rs.getFloat("HOLD_AMT"); holdAmt=rs.getFloat("HOLD_AMT");
} }
rs.close();
rs = null;
stmt.close();
stmt = null;
balAmt = totAmt-adjAmt; balAmt = totAmt-adjAmt;
if(balAmt == 0) if(balAmt == 0)
{ {
errCode = "VTBAL2"; // already paid off errCode = "VTBAL2";
} }
//else if(adjAmt != 0 && adjAmt != totAmt)
//{
// errCode = "VTBAL2"; // partly paid off
//}
else if (holdAmt == 0) else if (holdAmt == 0)
{ {
//Put Voucher on hold updSql = "UPDATE MISC_PAYABLES SET HOLD_AMT = TOT_AMT - ADJ_AMT WHERE TRAN_ID = ?";
//updSql = "UPDATE MISC_PAYABLES SET HOLD_AMT = TOT_AMT WHERE TRAN_SER = 'M-VOUC' AND REF_NO = '"+tranID+"'";
updSql = "UPDATE MISC_PAYABLES SET HOLD_AMT = TOT_AMT - ADJ_AMT WHERE TRAN_ID = '"+tranID+"'";
System.out.println("Updating SQL :: "+updSql); System.out.println("Updating SQL :: "+updSql);
rows=stmt.executeUpdate(updSql); stmt = conn.prepareStatement(updSql);
stmt.setString(1, tranID);
rows=stmt.executeUpdate();
stmt.close();
stmt = null;
} }
else else
{ {
errCode="VTHOLD3"; errCode="VTHOLD3";
} }
if(errCode.trim().length() == 0 && rows > 0) if((errCode != null && errCode.trim().length() == 0) && rows > 0)
{ {
errCode = "VTHOLD2"; errCode = "VTHOLD2";
conn.commit(); conn.commit();
...@@ -131,8 +108,7 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL ...@@ -131,8 +108,7 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL
if (errCode != null && errCode.trim().length() > 0) if (errCode != null && errCode.trim().length() > 0)
{ {
System.out.println("MiscPayablesHld:errCode:"+errCode); System.out.println("MiscPayablesHld:errCode:"+errCode);
//errString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);//Gulzar 30-12-06 errString = itmDBAccessEJB.getErrorString("", errCode, "");
errString = itmDBAccessEJB.getErrorString("", errCode, "");//Gulzar 30-12-06
} }
} }
...@@ -145,16 +121,26 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL ...@@ -145,16 +121,26 @@ public class MiscPayablesHld extends ActionHandlerEJB implements MiscVoucherHldL
{ {
try try
{ {
System.out.println("Connection Closing......"); if (conn != null)
conn.close(); {
if (rs != null)
rs.close();
rs = null;
if (stmt != null)
stmt.close();
stmt = null;
conn.close();
conn = null;
}
conn = null; conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in MiscPayablesHld:actionHold()" + d.getMessage());
throw new ITMException(d);
} }
catch(Exception e){}
} }
return errString; return errString;
} }
} }
\ No newline at end of file
/*
Window Name : w_misc_payables_hold
Button Name : Release
Action : Hold on voucher will be released .e it will update MISC_PAYABLES Table.
*/
package ibase.webitm.ejb.fin.adv;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
// added for ejb3
@Stateless // added for ejb3
public class MiscPayablesRls extends ActionHandlerEJB implements MiscPayablesRlsLocal,MiscPayablesRlsRemote
{
public String actionHandler() throws RemoteException,ITMException
{
return "";
}
public String actionHandler(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("MiscPayablesRls:actionHandler called");
String retString = null;
try
{
System.out.println("Transaction ID ::"+tranID);
retString = actionRelease(tranID,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :MiscPayablesRls :actionHandler:" + e.getMessage() + ":");
throw new ITMException(e);
}
System.out.println("returning from MiscPayablesRls actionHandler"+retString);
return retString;
}
private String actionRelease(String tranID,String xtraParams)throws ITMException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
String errCode="";
String errString="";
String sql = "";
String updSql = "";
int rows=0;
float totAmt=0;
float adjAmt=0;
float holdAmt=0;
float balAmt=0;
try
{
conn = getConnection();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
sql="SELECT TOT_AMT,ADJ_AMT,CASE WHEN HOLD_AMT IS NULL THEN 0 ELSE HOLD_AMT END HOLD_AMT FROM MISC_PAYABLES WHERE TRAN_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, tranID);
rs = stmt.executeQuery();
if(rs.next())
{
totAmt=rs.getFloat("TOT_AMT");
adjAmt=rs.getFloat("ADJ_AMT");
holdAmt=rs.getFloat("HOLD_AMT");
}
rs.close();
rs = null;
stmt.close();
stmt = null;
balAmt = totAmt-adjAmt;
if(balAmt == 0)
{
errCode = "VTBAL2";
}
else if (holdAmt != 0)
{
updSql="UPDATE MISC_PAYABLES SET HOLD_AMT = 0 WHERE TRAN_ID = ?";
System.out.println("Updating SQL :: "+updSql);
stmt = conn.prepareStatement(updSql);
stmt.setString(1, tranID);
rows=stmt.executeUpdate();
stmt.close();
stmt = null;
}
else
{
errCode="VTHOLD3";
}
if((errCode != null && errCode.trim().length() == 0) && rows > 0)
{
errCode = "VTHOLD1";
conn.commit();
System.out.println("\n <==== Transaction Updated Successfully ====>");
}
if (errCode != null && errCode.trim().length() > 0)
{
System.out.println("MiscPayablesRls:errCode:"+errCode);
errString = itmDBAccessEJB.getErrorString("", errCode, "");
}
}
catch(Exception e)
{
System.out.println("Exception :MiscPayablesRls :" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (stmt != null)
stmt.close();
stmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in MiscPayablesRls:actionHold()" + d.getMessage());
throw new ITMException(d);
}
}
return errString;
}
}
\ No newline at end of file
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface MiscPayablesRlsLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface MiscPayablesRlsRemote extends ActionHandlerRemote//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String tranID, String xtraParams, String forcedFlag) 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