Commit af502c33 authored by cpatil's avatar cpatil

added for amount validation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98389 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c8349a8d
......@@ -4,7 +4,7 @@
Date : 24/07/2015
Author: Aniket D. Bibave
********************************************************/
********************************************************/
package ibase.webitm.ejb.dis;
......@@ -25,8 +25,8 @@ import org.w3c.dom.NodeList;
@Stateless // added for ejb3
public class PurMilstnValidatorEJB extends ValidatorEJB
implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
public String wfValData() throws RemoteException,ITMException {
return "";
}
......@@ -45,7 +45,7 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
try {
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
......@@ -77,16 +77,16 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
}
return (errString);
}
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException {
return "";
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag) throws RemoteException,ITMException {
return "";
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException {
System.out.println(":::IN wfValData():::"+this.getClass().getSimpleName());
NodeList parentNodeList = null;
......@@ -103,26 +103,29 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
String userId = "";
int currentFormNo=0;
int childNodeListLength;
ConnDriver connDriver = new ConnDriver();
ConnDriver connDriver = new ConnDriver();
String compl_date ="";
double amount=0;
String purcOrder="";
try
{
conn = connDriver.getConnectDB("DriverITM");
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if(objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo) {
case 1 :
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
for(ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("compl_date")) {
compl_date = getColumnValue("compl_date",dom);
......@@ -132,8 +135,63 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
break;
}
}// end of compl_date
}
if (childNodeName.equalsIgnoreCase("amount"))
{
System.out.println("@@@@@@ voucher amount Validate ............");
amount = Double.parseDouble(getColumnValue("amount",dom)==null?"0":getColumnValue("amount",dom));
purcOrder = getColumnValue("purc_order",dom);
System.out.println("purcOrder["+purcOrder+"]amount["+amount+"]");
String sql="" ; // tranIdForVoucher="",
double vouchTotAmt=0;
double ordAmt=0 ;
sql = " select sum(net_amt) from voucher where purc_order = ? " ;
// "and confirmed = 'Y' " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next())
{
vouchTotAmt = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select ord_amt from porder where purc_order= ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next())
{
ordAmt = rs.getDouble("ord_amt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
double differenceAmt = ordAmt - vouchTotAmt ;
System.out.println("ordAmt["+ordAmt+"]-vouchNetAmt["+vouchTotAmt+"]=amount["+amount+"]>differenceAmt["+differenceAmt+"]");
if(amount > differenceAmt)
{
errCode = "RELAMTGRT";//This is a pre existing err code
errString = getErrorString("amount",errCode,userId);
break;
}
}// end of compl_date
}
break;
}
} catch(Exception e) {
......@@ -158,4 +216,4 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
}
return errString;
}
}
\ No newline at end of file
}
\ 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