Commit 0d7e2115 authored by arawankar's avatar arawankar

FinCommon.java

PayableOpenings.java
-Added validation of sundry code in payableOpening component



git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191485 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1209727a
......@@ -1786,7 +1786,7 @@ public class FinCommon
String ls_fin_entity ="",ls_curr_code__to = "",var_value = "",type = "";
double lc_exch_rate = 0.00;
String sql = "";
Statement stmt;
Statement stmt = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
java.sql.Timestamp tranDate = null;
......@@ -1828,8 +1828,11 @@ public class FinCommon
ls_curr_code__to = rs.getString(1);
}
}
stmt.close(); stmt = null;
//Modified by Anjali R. on[21/09/2018][Start]
//stmt.close(); stmt = null;
rs.close(); rs = null;
stmt.close(); stmt = null;
//Modified by Anjali R. on[21/09/2018][End]
}
catch(Exception e)
{
......@@ -1895,7 +1898,8 @@ public class FinCommon
{
try
{
if (pstmt != null)
//Modified by Anjali R. on[21/09/2018][ResultSet must be closed first before prepared statement][Start]
/*if (pstmt != null)
{
pstmt.close(); pstmt = null;
}
......@@ -1910,7 +1914,25 @@ public class FinCommon
if (rs1 != null)
{
rs1.close(); rs1 = null;
}*/
if (rs != null)
{
rs.close(); rs = null;
}
if (rs1 != null)
{
rs1.close(); rs1 = null;
}
if (pstmt != null)
{
pstmt.close(); pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close(); pstmt1 = null;
}
//Modified by Anjali R. on[21/09/2018][ResultSet must be closed first before prepared statement][End]
}
catch (Exception e)
{
......@@ -1965,7 +1987,9 @@ public class FinCommon
{
try
{
if (pstmt != null)
//Modified by Anjali R. on[21/09/2018][Start]
/*if (pstmt != null)
{
pstmt.close(); pstmt = null;
}
......@@ -1973,14 +1997,27 @@ public class FinCommon
{
rs.close(); rs = null;
}
if (pstmt1 != null)
if (rs1 != null)
{
pstmt1.close(); pstmt1 = null;
rs1.close(); rs1 = null;
}*/
if (rs != null)
{
rs.close(); rs = null;
}
if (rs1 != null)
{
rs1.close(); rs1 = null;
}
if (pstmt != null)
{
pstmt.close(); pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close(); pstmt1 = null;
}
//Modified by Anjali R. on[21/09/2018][End]
}
catch (Exception e)
{
......@@ -1997,7 +2034,27 @@ public class FinCommon
rs = stmt.executeQuery(sql);
if (rs.next())
{
var_value = rs.getString(1);
//Modified by Anjali R. on[21/09/2018][Start]
//var_value = rs.getString(1);
var_value = checkNull(rs.getString(1));
//Modified by Anjali R. on[21/09/2018][End]
}
//Modified by Anjali R. on[21/09/2018][Start]
else
{
var_value = "NULLFOUND";
}
if(rs != null)
{
rs.close();
rs = null;
}
if(!"NULLFOUND".equalsIgnoreCase(var_value))
{
//Modified by Anjali R. on[21/09/2018][End]
if(var_value.equals("Y"))
{
sql ="SELECT STD_EXRT FROM CURRENCY WHERE CURR_CODE = '"+as_curr_code.trim()+"'";
......@@ -2017,6 +2074,13 @@ public class FinCommon
}
else
{
//Modified by Anjali R. on[21/09/2018][Start]
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
//Modified by Anjali R. on[21/09/2018][End]
sql ="SELECT STD_EXRT FROM CURRENCY WHERE CURR_CODE = '"+as_curr_code.trim()+"'";
rs1 = stmt.executeQuery(sql);
if (rs1.next())
......@@ -2027,7 +2091,8 @@ public class FinCommon
rs1.close(); rs1 = null;
}
stmt.close(); stmt = null;
rs.close(); rs = null;
//rs.close(); rs = null;//Modified by Anjali R. on[21/09/2018]
}
catch(SQLException e)
{
......@@ -2039,6 +2104,36 @@ public class FinCommon
ex.printStackTrace();
throw new ITMException(ex);
}
//Modified by Anjali R. on[21/09/2018][Start]
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception [][getDailyExchRateSellBuy]--["+ e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
//Modified by Anjali R. on[21/09/2018][End]
}
// try
// {
......@@ -15538,6 +15633,28 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception from getCalcDiscountDate--["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return dueDate;
}
//Added by Anjali R. on[30/04/2018][Migrated method gbf_calc_discountdate][End]
......@@ -15888,7 +16005,7 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
//Added by Anjali R. on[02/05/2018][Migrated method gbf_payable_at from nvo_business_object_fin component][End]
//Added by Anjali R. on[02/05/2018][Migrated method gbf_stan_drawn from nvo_business_object_fin component][Start]
public String getStanDrawn(String sundryType, String sundryCode,Connection conn)
public String getStanDrawn(String sundryType, String sundryCode,Connection conn) throws ITMException
{
String stanCode = "";
String empCode = "";
......@@ -16061,6 +16178,7 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
{
System.out.println("Exception from getStanDrawn--[ "+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -16085,5 +16203,211 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
return stanCode;
}
//Added by Anjali R. on[02/05/2018][Migrated method gbf_stan_drawn from nvo_business_object_fin component][End]
//Added by Anjali R. on[21/09/2018][Validate sundry code ][Start]
public int getSundryCode(String sundryCode,String sundryType,Connection conn) throws ITMException, SQLException
{
System.out.println("-----------------Inside getSundryCode----------------------");
System.out.println("Parameters ---\n sundryCode--["+sundryCode+"]---\n sundryType--["+sundryType+"]");
int count = 0;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
if("S".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from supplier---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("C".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from customer---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("P".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from sales_pers WHERE sales_pers = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from sales_pers---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("T".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from transporter WHERE tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from transporter---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("E".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from employee---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("L".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from loanparty WHERE party_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from loanparty---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("B".equalsIgnoreCase(sundryType))
{
count = 0;
sql = "select count(1) as cnt from bank WHERE bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
System.out.println("Count from bank---["+count+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
catch(Exception e)
{
System.out.println("Exception in getSundryCode --["+e.getMessage()+"]");
e.printStackTrace();
conn.rollback();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e1)
{
System.out.println("Inside catch of finally block--["+e1.getMessage()+"]");
e1.printStackTrace();
throw new ITMException(e1);
}
}
System.out.println("count---["+count+"]");
return count;
}
//Added by Anjali R. on[21/09/2018][Validate sundry code ][eND]
}
......@@ -682,8 +682,34 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
//Modified by Anjali R. on[21/09/2018][Start]
if(rs != null)
{
rs.close();
rs = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
//Modified by Anjali R. on[21/09/2018][End]
}
catch(Exception s){}
}
......@@ -739,10 +765,16 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
int childNodeListLength;
int cnt;
SimpleDateFormat simpleDateFormat = null;
//Modified by Anjali R. on[21/09/2018][Start]
String sundryCode ="";
int sundryCnt = 0;
String sundryType = "";
FinCommon finCommon = null;
//Modified by Anjali R. on[21/09/2018][End]
try
{
conn = getConnection();
finCommon = new FinCommon();//Modified by Anjali R. on[21/09/2018]
//stmt = conn.createStatement();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("userId = "+userId);
......@@ -821,15 +853,39 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
hm.put("line_no",childNodeValue);
}
if(childNodeName.equals("tran_ser"))
{
//Modified by Anjali R. on[21/09/2018][If tran_ser is null then null pointer exception occure][Start]
/*childNodeValue= childNode.getFirstChild().getNodeValue();
hm.put("tran_ser",childNodeValue);*/
if(childNode.getFirstChild() != null)
{
childNodeValue= childNode.getFirstChild().getNodeValue();
hm.put("tran_ser",childNodeValue);
}
else
{
hm.put("tran_ser","");
}
//Modified by Anjali R. on[21/09/2018][If tran_ser is null then null pointer exception occure][End]
}
if(childNodeName.equals("ref_no"))
{
//Modified by Anjali R. on[21/09/2018][If ref_no is null then null pointer exception occure][Start]
/*childNodeValue= childNode.getFirstChild().getNodeValue();
hm.put("ref_no",childNodeValue);*/
if(childNode.getFirstChild() != null)
{
childNodeValue= childNode.getFirstChild().getNodeValue();
hm.put("ref_no",childNodeValue);
}
else
{
hm.put("ref_no","");
}
//Modified by Anjali R. on[21/09/2018][If ref_no is null then null pointer exception occure][End]
}
}
arList.add(hm);
}
......@@ -853,6 +909,25 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
errString = getErrorString("sundry_code",errCode,userId);
break;
}
//Modified by Anjali R. on [21/09/2018][If sundry code is not blank then system should validate the sundry code from sundry master][Start]
else
{
sundryCode = checkNull(genericUtility.getColumnValue("sundry_code", dom));
sundryType = checkNull(genericUtility.getColumnValue("sundry_type", dom));
System.out.println("sundryCode--["+sundryCode+"]---sundryType---["+sundryType+"]");
if(sundryCode != null && sundryCode.trim().length() > 0)
{
sundryCnt = finCommon.getSundryCode(sundryCode, sundryType, conn);
System.out.println("sundryCnt---["+sundryCnt+"]");
if(sundryCnt == 0 )
{
errCode = "VMSUND1";
errString = getErrorString("sundry_code",errCode,userId);
break;
}
}
}
//Modified by Anjali R. on [21/09/2018][If sundry code is not blank then system should validate the sundry code from sundry master][Start]
}
else if(childNodeName.equals("tran_ser"))
{
......@@ -971,7 +1046,7 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
break;
}
System.out.println("acct_code ................."+acctCode);
FinCommon finCommon = new FinCommon();
//FinCommon finCommon = new FinCommon();//Commented by Anjali R. on[21/09/2018]
errCode = finCommon.isAcctCode(getColumnValue("site_code",dom1),acctCode,"fin",conn);
if(errCode != "")
{
......@@ -1142,17 +1217,47 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
}//try
catch(Exception e)
{
System.out.println("Exception ::"+e);
System.out.println("Exception ::"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Connection.....");
conn.close();
conn = null;
}catch(Exception se){}
if(conn != null)
{
conn.close();
conn = null;
}
//Modified by Anjali R. on[21/09/2018][Start]
if(rs != null)
{
rs.close();
rs = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
//Modified by Anjali R. on[21/09/2018][End]
}
catch(Exception se)
{
}
}
System.out.println("ErrString ::"+errString);
return errString;
......@@ -1367,4 +1472,18 @@ public class PayableOpenings extends ValidatorEJB implements PayableOpeningsLoca
}//outer if
return arrList;
}//sundryDesc
//Modified by Anjali R. on[20/09/2018][Added new method to check null][Start]
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
//Modified by Anjali R. on[20/09/2018][Added new method to check null][End]
}//class
\ 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