Commit 135aa5a9 authored by dpawar's avatar dpawar

update validation for bond recovery


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92338 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f531d44c
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm.adv;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
...@@ -116,7 +116,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -116,7 +116,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{ {
System.out.println("in wfValData........");
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
...@@ -132,18 +131,16 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -132,18 +131,16 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
String userId = ""; String userId = "";
int currentFormNo=0; int currentFormNo=0;
int childNodeListLength; int childNodeListLength;
String empCode="",siteCode = "",recAmtAct=""; String empCode="",siteCode = "",recAmtAct="",bondAmt="",recAmtDone="";
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
System.out.println("in try.....");
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
//ccStatus=genericUtility.getColumnValue("status",dom);
if(objContext != null && objContext.trim().length() > 0) if(objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
...@@ -164,12 +161,10 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -164,12 +161,10 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
if (childNodeName.equalsIgnoreCase("emp_code")) if (childNodeName.equalsIgnoreCase("emp_code"))
{ {
empCode = genericUtility.getColumnValue("emp_code",dom); empCode = genericUtility.getColumnValue("emp_code",dom);
System.out.println(" eMP CODE -->>"+empCode);
if (empCode == null || empCode.trim().length() == 0 ) if (empCode == null || empCode.trim().length() == 0 )
{ {
errCode = "VNULEMPC"; errCode = "VNULEMPC";
errString = getErrorString("emp_code",errCode,userId); errString = getErrorString("emp_code",errCode,userId);
System.out.println("in message error code 1....");
break; break;
} }
...@@ -234,28 +229,73 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -234,28 +229,73 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
recAmtAct = genericUtility.getColumnValue("recovery_amt__act",dom); recAmtAct = genericUtility.getColumnValue("recovery_amt__act",dom);
String recAmtDue = genericUtility.getColumnValue("amt__due",dom); String recAmtDue = genericUtility.getColumnValue("amt__due",dom);
System.out.println("Actual amt :"+recAmtAct+" recAmtDue :"+recAmtDue); bondAmt = genericUtility.getColumnValue("bond_amt",dom);
recAmtDone= genericUtility.getColumnValue("recovery_amt__done",dom);
double recAmountAct=0.0,recAmountDue=0.0,bondAmount=0.0,recAmountDone=0.0;
if (recAmtAct == null || recAmtAct.trim().length() == 0 ) if (recAmtAct == null || recAmtAct.trim().length() == 0 )
{ {
errCode = "VBACTAMT"; errCode = "VBACTAMT";
errString = getErrorString("recovery_amt__act",errCode,userId); errString = getErrorString("recovery_amt__act",errCode,userId);
break; break;
} }
double recAmountAct=0.0,recAmountDue=0.0;
if( bondAmt !=null && bondAmt.trim().length() > 0 )
if( recAmtDue !=null || recAmtDue.trim().length() == 0 ) {
bondAmount=Double.parseDouble(bondAmt);
recAmountDone=Double.parseDouble(recAmtDone);
System.out.println("bondAmount :-->>"+bondAmount+" recAmountDone : "+recAmountDone);
if(bondAmount == recAmountDone)
{
errCode="VRECAMTGRT";
errString = getErrorString("recovery_amt__done",errCode,userId);
break;
}
}
if( recAmtDue !=null && recAmtDue.trim().length() > 0 )
{ {
recAmountAct=Double.parseDouble(recAmtAct); recAmountAct=Double.parseDouble(recAmtAct);
recAmountDue=Double.parseDouble(recAmtDue); recAmountDue=Double.parseDouble(recAmtDue);
System.out.println("recAmountAct :-->>"+bondAmount+" recAmountDone : "+recAmountDone);
if (recAmountAct > recAmountDue) if (recAmountAct > recAmountDue)
{ {
System.out.println("greater than condition true -------");
errCode="RECAMTNUL"; errCode="RECAMTNUL";
errString = getErrorString("amt__due",errCode,userId); errString = getErrorString("amt__due",errCode,userId);
break; break;
} }
} }
/*if( bondAmt !=null && bondAmt.trim().length() > 0 )
{
if(bondAmount == recAmountDone)
{
errCode="VRECAMTGRT";
errString = getErrorString("recovery_amt__done",errCode,userId);
break;
}
}*/
}
else if (childNodeName.equalsIgnoreCase("bond_amt"))
{
bondAmt = genericUtility.getColumnValue("bond_amt",dom);
if (bondAmt == null || bondAmt.trim().length() == 0 )
{
errCode = "VBAMTNOTF";
errString = getErrorString("recovery_amt__act",errCode,userId);
break;
}
} }
}// for loop end }// for loop end
} //end switch } //end switch
...@@ -332,23 +372,20 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -332,23 +372,20 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
int currentFormNo = 0; int currentFormNo = 0;
String deptCode="", empCode=""; String deptCode="", empCode="";
String deptDescr = "",dateRelieve="",dateJoin="",loginEmpCode = null; String dateRelieve="",dateJoin="",loginEmpCode = null;
String sql = "",descr = "",empfname = "", empmname = "", emplname = ""; String sql = "",descr = "",empfname = "", empmname = "", emplname = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String acct_code="", cctr_code=""; String acct_code="", cctr_code="";
int bondPrd=0; int bondPrd=0;
double bondAmt=0.0,bondAmtDone=0.0,bondAmtDue=0.0; double bondAmt=0.0,bondAmtDone=0.0,bondAmtDue=0.0;
String tranDate="",loginEmpCode=""; String tranDate="";
String [] datearrayJ=new String[3]; String [] datearrayJ=new String[3];
String [] datearrayR=new String[3]; String [] datearrayR=new String[3];
String splitdateJ="",splitmonthJ="",splityearJ="",splitdateR="",splitmonthR="",splityearR=""; String splitdateJ="",splitmonthJ="",splityearJ="",splitdateR="",splitmonthR="",splityearR="";
Timestamp timestampDateJ = null,timestampDateR=null; Timestamp timestampDateJ = null,timestampDateR=null;
try try
...@@ -448,7 +485,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -448,7 +485,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
cctr_code = rs.getString(7) == null ? getCctrCodeFromDept(conn,pstmt,rs,empCode) : rs.getString(7); cctr_code = rs.getString(7) == null ? getCctrCodeFromDept(conn,pstmt,rs,empCode) : rs.getString(7);
timestampDateJ = rs.getTimestamp(8); timestampDateJ = rs.getTimestamp(8);
timestampDateR = rs.getTimestamp(9); timestampDateR = rs.getTimestamp(9);
//bondAmtDone=rs.getDouble(10);
if(timestampDateJ != null) dateJoin = sdf.format(timestampDateJ).toString(); if(timestampDateJ != null) dateJoin = sdf.format(timestampDateJ).toString();
if(timestampDateR != null) dateRelieve = sdf.format(timestampDateR).toString(); if(timestampDateR != null) dateRelieve = sdf.format(timestampDateR).toString();
...@@ -474,9 +510,8 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -474,9 +510,8 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
pstmt = null; pstmt = null;
rs = null; rs = null;
//*********************************************************************************************
if (dateRelieve !=null && dateJoin !=null&& dateRelieve.length()>0 && dateJoin.length()>0) if (dateRelieve !=null && dateJoin !=null&& dateRelieve.length()>0 && dateJoin.length()>0)
{ {
StringTokenizer st = new StringTokenizer(dateJoin, "/"); StringTokenizer st = new StringTokenizer(dateJoin, "/");
StringTokenizer st1 = new StringTokenizer(dateRelieve, "/"); StringTokenizer st1 = new StringTokenizer(dateRelieve, "/");
int i=0; int i=0;
...@@ -551,7 +586,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -551,7 +586,6 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
{ {
bondAmtDue= bondAmtDue+rs.getDouble(1); bondAmtDue= bondAmtDue+rs.getDouble(1);
} }
System.out.println("After while bond amt due------->>>>"+bondAmtDue);
bondAmtDone=bondAmtDue; bondAmtDone=bondAmtDue;
bondAmtDue=bondAmt-bondAmtDue; bondAmtDue=bondAmt-bondAmtDue;
...@@ -652,11 +686,9 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -652,11 +686,9 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
{ {
//new GregorianCalendar(yyyy, mm, dd) here month 0 is for January //new GregorianCalendar(yyyy, mm, dd) here month 0 is for January
double monthsBetween = 0; double monthsBetween = 0;
//difference in month for years
monthsBetween = (date1.get(Calendar.YEAR)-date2.get(Calendar.YEAR))*12; monthsBetween = (date1.get(Calendar.YEAR)-date2.get(Calendar.YEAR))*12;
//difference in month for months
monthsBetween += date1.get(Calendar.MONTH)-date2.get(Calendar.MONTH); monthsBetween += date1.get(Calendar.MONTH)-date2.get(Calendar.MONTH);
//difference in month for days
if(date1.get(Calendar.DAY_OF_MONTH)!=date1.getActualMaximum(Calendar.DAY_OF_MONTH) if(date1.get(Calendar.DAY_OF_MONTH)!=date1.getActualMaximum(Calendar.DAY_OF_MONTH)
&& date1.get(Calendar.DAY_OF_MONTH)!=date1.getActualMaximum(Calendar.DAY_OF_MONTH) ){ && date1.get(Calendar.DAY_OF_MONTH)!=date1.getActualMaximum(Calendar.DAY_OF_MONTH) ){
monthsBetween += ((date1.get(Calendar.DAY_OF_MONTH)-date2.get(Calendar.DAY_OF_MONTH))/31d); monthsBetween += ((date1.get(Calendar.DAY_OF_MONTH)-date2.get(Calendar.DAY_OF_MONTH))/31d);
...@@ -664,39 +696,4 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -664,39 +696,4 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
return monthsBetween; return monthsBetween;
} }
}
/*public int getBondPeriod(Connection conn,PreparedStatement pstmt,ResultSet rs,String EmpCode,int monthsBetween)
{
ArrayList<Integer> bondprdList=new ArrayList<Integer>();
try
{
String sql1 = "SELECT bond_prd where emp_code= ?";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,EmpCode);
rs = pstmt.executeQuery();
if(rs.next())
{
bondprdList.add(rs.getInt(1));
}
System.out.println("in Bond list --->> :"+bondprdList);
Iterator itr = bondprdList.iterator();
while(itr.hasNext())
{
int i=Integer.parseInt(itr.next().toString());
if (i==monthsBetween)
return i;
}
}
catch(Exception e)
{
e.printStackTrace();
}
//return bondprdList;
}*/
}
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