Commit a14ff6c5 authored by smanohar's avatar smanohar

Utility methods form Sun source added

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213142 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a9d75714
...@@ -14943,4 +14943,310 @@ public class FinCommon { ...@@ -14943,4 +14943,310 @@ public class FinCommon {
} }
return adDueDate; return adDueDate;
} }
/**
* @param lsBank
* @param lsSite
* @param ldTranDate
* @param lcNet
* @param conn
* @return
* @throws ITMException
*/
public String gbfBalChk(String lsBank, String lsSite, Timestamp ldTranDate, double lcNet,Connection conn) throws ITMException
{
String errString="",ls_type="",ls_acctprd="",sql_bank="",sql_acctprd="",sql_sundrybal="";
Double lc_bal=0.0d;
PreparedStatement pstmt=null;
ResultSet rs=null;
try{
sql_bank="select bank_type from bank where bank_code =? ";
pstmt=conn.prepareStatement(sql_bank);
pstmt.setString(1,lsBank);
rs=pstmt.executeQuery();
if(rs.next())
{
ls_type=checkNull(rs.getString("bank_type"));
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
sql_acctprd="select code from acctprd where ? between fr_date and to_date";
pstmt=conn.prepareStatement(sql_acctprd);
pstmt.setTimestamp(1,ldTranDate);
rs=pstmt.executeQuery();
if(rs.next())
{
ls_acctprd=rs.getString("code");
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if("".equalsIgnoreCase(ls_type))
{
ls_type=" ";
}
else if("C".equalsIgnoreCase(ls_type))
{
sql_sundrybal="select sum(dr_amt - cr_amt) from sundrybal where acct_prd = ? and prd_code = 'zzzzzz' and site_code = ? and sundry_type = 'B' and sundry_code = ?";
pstmt=conn.prepareStatement(sql_sundrybal);
pstmt.setString(1,ls_acctprd);
pstmt.setString(2,lsSite);
pstmt.setString(3,lsBank);
rs=pstmt.executeQuery();
if(rs.next())
{
lc_bal=rs.getDouble(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if(lc_bal== null)
{
lc_bal=0.0;
}
else if(lcNet > 0 && lcNet > lc_bal)
{
errString = "VTPAYAMT";
return errString;
}
}
}catch(SQLException se)
{
System.out.println("SQLException :ITMDBAccessEJB :isCctrCode:" + se.getMessage() + ":");
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception :ITMDBAccessEJB :isCctrCode:" + e.getMessage() + ":");
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
System.out.println("errCode ::: " + errString);
return errString;
}
/**
* @param lsRefno
* @param userId
* @param termid
* @param conn
* @return
* @throws ITMException
* @throws SQLException
*/
public String gbf_loanchk(String lsRefno,String userId,String termid, Connection conn) throws ITMException, SQLException
{
String errString="",ls_errcode="", ls_empcode="", ls_scheme="", ls_adcode_dedn="",sql_loan_scheme="";
String sql_loans="",sql_allowdedn_bal="",sql_allow_bal="";
Double lc_diffamt=0.0d,lc_instamt=0.0d,lc_loanamt=0.0d;
int li_term=0;
int lc_num=0;
int cnt_update=0;
PreparedStatement pstmt=null;
PreparedStatement pstmt1=null;
PreparedStatement pstmt2=null;
ResultSet rs=null;
ResultSet rs1=null;
ResultSet rs2=null;
Timestamp toDayTsmp1=null;
Timestamp ld_start=null;
Timestamp req_date=null;
Timestamp ld_date=null;
UtilMethods util =new UtilMethods();
try{
java.util.Date toDay = new java.util.Date();
toDayTsmp1 =new java.sql.Timestamp(toDay.getTime());
sql_loans="select start_reco, emp_code, loan_amt, mon_inst, term, scheme_no from loans where loan_no =?";
pstmt=conn.prepareStatement(sql_loans);
pstmt.setString(1,lsRefno);
rs=pstmt.executeQuery();
while(rs.next())
{
ld_start=rs.getTimestamp("start_reco");
ls_empcode=rs.getString("emp_code");
lc_loanamt=rs.getDouble("loan_amt");
lc_instamt=rs.getDouble("mon_inst");
li_term=rs.getInt("term");
ls_scheme=rs.getString("scheme_no");
sql_loan_scheme="select ad_code__ded from loan_scheme where scheme_no =?";
pstmt1=conn.prepareStatement(sql_loan_scheme);
pstmt1.setString(1,ls_scheme);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
ls_adcode_dedn=rs.getString("ad_code__ded");
}
pstmt1.close();
pstmt1=null;
rs1.close();
rs1=null;
if(li_term>1)
{
req_date=util.AddMonths(ld_start, li_term-1);
System.out.println("Request Date::"+req_date);
req_date= lastDateCal(req_date);
}
else
{
req_date = lastDateCal(ld_start);
}
ld_date = req_date;
sql_allowdedn_bal="select count(*) as CNT from allowdedn_bal where emp_code =? and ad_code = ? and start_date =? and end_date =? ";
pstmt2=conn.prepareStatement(sql_allowdedn_bal);
pstmt2.setString(1,ls_empcode);
pstmt2.setString(2, ls_adcode_dedn);
pstmt2.setTimestamp(3, ld_start);
pstmt2.setTimestamp(4, ld_date);
rs2=pstmt2.executeQuery();
if(rs2.next())
{
lc_num=rs.getInt("CNT");
}
pstmt2.close();
pstmt2=null;
rs2.close();
rs2=null;
if(lc_num == 0)
{
sql_allow_bal="Insert into allowdedn_bal (emp_code, ad_code, start_date, end_date, amount, amt_adj,amt_bal, chg_date, chg_user, chg_term,ref_type,ref_no) " +
"values (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql_allow_bal);
pstmt.setString(1, ls_empcode);
pstmt.setString(2, ls_adcode_dedn);
pstmt.setTimestamp(3, ld_start);
pstmt.setTimestamp(4, ld_date);
pstmt.setDouble(5, lc_loanamt);
pstmt.setDouble(6,0);
pstmt.setDouble(7, lc_loanamt);
pstmt.setTimestamp(8, toDayTsmp1);
pstmt.setString(9, userId);
pstmt.setString(10, termid);
pstmt.setString(11,"L");
pstmt.setString(12,lsRefno);
cnt_update=pstmt.executeUpdate();
}
else{
errString="VTLNFND";
return errString;
}
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
}catch(Exception e)
{
System.out.println("Exception :ITMDBAccessEJB :gbf_loanchk:" + e.getMessage() + ":");
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
return errString;
}
/**
* @param tsDate
* @return
* @throws ITMException
* @throws SQLException
*/
public Timestamp lastDateCal(Timestamp tsDate)throws ITMException, SQLException
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(tsDate.getTime());
int lastDate = calendar.getActualMaximum(Calendar.DATE);
calendar.set(Calendar.DATE, lastDate);
System.out.println("Last Date: " + calendar.getTime());
java.util.Date date=(java.util.Date) calendar.getTime();
Timestamp ts_date= new Timestamp(date.getTime());
System.out.println("TimeStamp DATE::"+ts_date);
return ts_date;
}
} }
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