Commit bd2e1ed6 authored by vvengurlekar's avatar vvengurlekar

PayarrToProc.java - functionality added to check period code lesser than...

PayarrToProc.java - functionality added to check period code lesser than joining date , process type is editable


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192660 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a63a94fd
......@@ -75,14 +75,14 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
String childNodeName = "";
String errString="";
String userId = "", errCode = "", errorType = "", loginCode = "";
String msgType = "";//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
String sql = "";
String empCode = "", status = "", prdCode = "", procType = "", paySite = "";
String msgType = "";//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]
int userLevel = 0;
Date fromDate = null, relieveDate = null;
Date fromDate = null, relieveDate = null, toDate = null, joinDate = null;
try
{
conn = getConnection();
......@@ -110,7 +110,21 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
if("emp_code".equalsIgnoreCase(childNodeName))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCode == null || empCode.trim().length() == 0)
{
errCode = "VTPAYARR04";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
else if("A".equalsIgnoreCase(editFlag))// added condition by varsha V to execute validation on add mode 02-11-18
{
if(empCode != null && empCode.trim().length() > 0)
{
cnt = 0;
......@@ -217,9 +231,16 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
}
}
else
}
}
else if("prd_code".equalsIgnoreCase(childNodeName))
{
errCode = "VTPAYARR04";
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
if(prdCode == null || prdCode.trim().length() == 0)
{
errCode = "VTPAYARR05";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
......@@ -230,21 +251,19 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
else if("prd_code".equalsIgnoreCase(childNodeName))
else if("A".equalsIgnoreCase(editFlag))
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
if(prdCode != null && prdCode.trim().length() > 0)
{
cnt = 0;
sql = "select fr_date from period where code = ?";
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
fromDate = rs.getDate("fr_date");
toDate = rs.getDate("to_date");
cnt++;
}
if(rs != null)
......@@ -272,13 +291,14 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
sql = "select RELIEVE_DATE from employee where EMP_CODE = ?";
sql = "select RELIEVE_DATE, DATE_JOIN from employee where EMP_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
relieveDate = rs.getDate("RELIEVE_DATE");
joinDate = rs.getDate("DATE_JOIN");
}
if(rs != null)
{
......@@ -297,14 +317,33 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
errCode = "VTPAYARR02";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
else
//Added below code by Varsha V to check whether period code is before joining date or not 02-11-18
if(toDate != null && joinDate != null)
{
errCode = "VTPAYARR05";
if(toDate.before(joinDate))
{
errCode = "VTPAYARR08";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
//Ended below code by Varsha V to check whether period code is before joining date or not 02-11-18
}
procType = checkNull(genericUtility.getColumnValue("proc_type", dom));
......@@ -335,6 +374,14 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
errCode = "VTPAYARR03";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
}
}
......@@ -478,7 +525,8 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
String descr="";
String procType="";
String tranId="";
String empName = "";
String empName = "", paySite = "", loginCode = "";
int userLevel = 0, cnt = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
......@@ -488,6 +536,7 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
{
conn = getConnection();
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userId"));
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = getValueFromXTRA_PARAMS(xtraParams, "termId");
java.util.Date currDate = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
......@@ -517,7 +566,7 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
xmlString.append("<status protect=\"1\"><![CDATA[").append("U").append("]]></status>\r\n");
xmlString.append("<prd_code__acc protect=\"1\"><![CDATA[").append("").append("]]></prd_code__acc>\r\n");
xmlString.append("<proc_date protect=\"1\"><![CDATA[").append("").append("]]></proc_date>\r\n");
xmlString.append("<proc_type protect=\"1\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<proc_type protect=\"0\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<tran_id protect=\"1\"><![CDATA[").append("").append("]]></tran_id>\r\n");
}//Ended itm_default itemchange by Varsha V on 24-08-18 [END]
......@@ -562,10 +611,10 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
else if (currentColumn.trim().equalsIgnoreCase("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
site = ""; empName = "";
site = ""; empName = ""; paySite = "";
if(empCode != null && empCode.trim().length() > 0)
{
sql = "SELECT EMP_SITE, FN_GET_EMP_NAME( EMP_CODE,'X')AS EMP_NAME FROM EMPLOYEE WHERE EMP_CODE= ?";
sql = "SELECT EMP_SITE, FN_GET_EMP_NAME( EMP_CODE,'X')AS EMP_NAME, PAY_SITE FROM EMPLOYEE WHERE EMP_CODE= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
......@@ -573,6 +622,26 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
{
site = checkNull(rs.getString("EMP_SITE"));
empName = checkNull(rs.getString("EMP_NAME"));
paySite = checkNull(rs.getString("PAY_SITE"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// addec below code by Varsha V to check user rights 02-11-18
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if(rs.next())
{
userLevel = rs.getInt("usr_lev");
}
if(rs != null)
{
......@@ -584,6 +653,8 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
pstmt.close();
pstmt = null;
}
// Ended below code by Varsha V to check user rights 02-11-18
siteDescr = "";
if(site.trim().length() > 0 && !"null".equalsIgnoreCase(site) )
{
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
......@@ -609,10 +680,50 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
}
}
// addec below code by Varsha V to check user rights on 02-11-18
if(userLevel > 1)
{
cnt = 0;
sql = "select count(*) as cnt from user_site where user_id = ? and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, paySite);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
xmlString.append("<name><![CDATA[").append(empName).append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append(site).append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append(siteDescr).append("]]></descr>\r\n");
}
else
{
xmlString.append("<name><![CDATA[").append("").append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append("").append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append("").append("]]></descr>\r\n");
}
}
else
{
xmlString.append("<name><![CDATA[").append(empName).append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append(site).append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append(siteDescr).append("]]></descr>\r\n");
}
// Ended below code by Varsha V to check user rights 02-11-18
}
//Ended emp_code itemchange by Varsha V on 24-08-18 [End]
xmlString.append("</Detail1>\r\n");
......
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