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 @@ ...@@ -4,7 +4,7 @@
Date : 24/07/2015 Date : 24/07/2015
Author: Aniket D. Bibave Author: Aniket D. Bibave
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
...@@ -25,8 +25,8 @@ import org.w3c.dom.NodeList; ...@@ -25,8 +25,8 @@ import org.w3c.dom.NodeList;
@Stateless // added for ejb3 @Stateless // added for ejb3
public class PurMilstnValidatorEJB extends ValidatorEJB public class PurMilstnValidatorEJB extends ValidatorEJB
implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote { implements PurMilstnValidatorEJBLocal,PurMilstnValidatorEJBRemote {
public String wfValData() throws RemoteException,ITMException { public String wfValData() throws RemoteException,ITMException {
return ""; return "";
} }
...@@ -45,7 +45,7 @@ public class PurMilstnValidatorEJB extends ValidatorEJB ...@@ -45,7 +45,7 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName = ""; String childNodeName = "";
try { try {
dom = parseString(xmlString); dom = parseString(xmlString);
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
...@@ -77,16 +77,16 @@ public class PurMilstnValidatorEJB extends ValidatorEJB ...@@ -77,16 +77,16 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
} }
return (errString); return (errString);
} }
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException { public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException {
return ""; return "";
} }
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag) throws RemoteException,ITMException { public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag) throws RemoteException,ITMException {
return ""; return "";
} }
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():::"+this.getClass().getSimpleName()); System.out.println(":::IN wfValData():::"+this.getClass().getSimpleName());
NodeList parentNodeList = null; NodeList parentNodeList = null;
...@@ -103,26 +103,29 @@ public class PurMilstnValidatorEJB extends ValidatorEJB ...@@ -103,26 +103,29 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
String userId = ""; String userId = "";
int currentFormNo=0; int currentFormNo=0;
int childNodeListLength; int childNodeListLength;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String compl_date =""; String compl_date ="";
double amount=0;
String purcOrder="";
try try
{ {
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");
if(objContext != null && objContext.trim().length() > 0) { if(objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) { switch(currentFormNo) {
case 1 : case 1 :
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) { for(ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("compl_date")) { if (childNodeName.equalsIgnoreCase("compl_date")) {
compl_date = getColumnValue("compl_date",dom); compl_date = getColumnValue("compl_date",dom);
...@@ -132,8 +135,63 @@ public class PurMilstnValidatorEJB extends ValidatorEJB ...@@ -132,8 +135,63 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
break; break;
} }
}// end of compl_date }// 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; break;
} }
} catch(Exception e) { } catch(Exception e) {
...@@ -158,4 +216,4 @@ public class PurMilstnValidatorEJB extends ValidatorEJB ...@@ -158,4 +216,4 @@ public class PurMilstnValidatorEJB extends ValidatorEJB
} }
return errString; 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