Commit af09d53a authored by tmahadi's avatar tmahadi

Validation for completion date to be between tran date and current date.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98392 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 87d21091
......@@ -10,12 +10,16 @@ package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.Stateless; // added for ejb3
......@@ -26,6 +30,8 @@ import org.w3c.dom.NodeList;
@Stateless // added for ejb3
public class PurMilstnValidatorEJB extends ValidatorEJB
implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
GenericUtility genericUtility = GenericUtility.getInstance();
public String wfValData() throws RemoteException,ITMException {
return "";
......@@ -105,6 +111,8 @@ implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
int childNodeListLength;
ConnDriver connDriver = new ConnDriver();
String compl_date ="";
String tran_date = "";
String date_format = "";
double amount=0;
String purcOrder="";
......@@ -129,10 +137,23 @@ implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("compl_date")) {
compl_date = getColumnValue("compl_date",dom);
tran_date = getColumnValue("tran_date",dom);
date_format = getColumnValue("date_format",dom);
date_format = date_format==null ? genericUtility.getApplDateFormat() : date_format.trim();
if (compl_date == null || compl_date.trim().length() == 0) {
errCode = "VTCPLDTINV";//This is a pre existing err code
errString = getErrorString("compl_date",errCode,userId);
break;
} else {
if(date_format.length() > 0){
boolean isBetweenDate = isBetweenDate(tran_date, compl_date, date_format);
if(!isBetweenDate){
errCode = "VTCPLDTGRT";//This is a pre existing err code
errString = getErrorString("compl_date",errCode,userId);
break;
}
}
}
}// end of compl_date
......@@ -216,4 +237,19 @@ implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
}
return errString;
}
private boolean isBetweenDate(String tran_date, String compl_date, String date_format) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(date_format);
Calendar cal = Calendar.getInstance();
Date currentDate = cal.getTime();
Date complDate = sdf.parse(compl_date);
Date tranDate = sdf.parse(tran_date);
System.out.println("futureDate["+complDate+"].before["+currentDate+"]:::"+complDate.before(currentDate)+":::");
if(complDate.before(currentDate) && complDate.after(tranDate)){
return true;
}
return false;
}
}
\ 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