Commit da1c8747 authored by pdas's avatar pdas

Changes made for budget validation of project code in Purchase Order Amendment


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99175 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 23e42fda
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon; import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.mfg.MfgCommon; import ibase.webitm.ejb.mfg.MfgCommon;
...@@ -10,6 +11,7 @@ import ibase.webitm.utility.ITMException; ...@@ -10,6 +11,7 @@ import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.math.BigDecimal;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -131,8 +133,9 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -131,8 +133,9 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
Timestamp pordDate = null; Timestamp pordDate = null;
double indBalance=0; double indBalance=0;
double totAmtIndent =0; double totAmtIndent =0;
double totAmtDetpordertemp =0; double totAmtDetpordertemp =0, totAmtDetpordertot =0.0;
double totAmtDetPoamdDetbrow = 0, totAmtDetIndent = 0, totAmtDetporder = 0, approxCost = 0, totAmtProj = 0; double totAmtDetPoamdDetbrow = 0, totAmtDetIndent = 0, totAmtDetporder = 0, approxCost = 0, totAmtProj = 0;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try { try {
System.out.println("@@@@@@@@ wfvaldata called"); System.out.println("@@@@@@@@ wfvaldata called");
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
...@@ -1041,7 +1044,9 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1041,7 +1044,9 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
//Added by Priyanka Das Request ID -D15ESUN002 //Added by Priyanka Das Request ID -D15ESUN002
pordNo = checkNull(genericUtility.getColumnValue("purc_order", dom)); pordNo = checkNull(genericUtility.getColumnValue("purc_order", dom));
lineNoOrd = checkNull(genericUtility.getColumnValue("line_no__ord", dom)); lineNoOrd = genericUtility.getColumnValue("line_no__ord", dom);
lineNoOrd = lineNoOrd == null|| lineNoOrd.trim().length()==0 ?" ":lineNoOrd;
amdNo = checkNull(genericUtility.getColumnValue("amd_no",dom )); amdNo = checkNull(genericUtility.getColumnValue("amd_no",dom ));
purcOrder = checkNull(genericUtility.getColumnValue("purc_order", dom)); purcOrder = checkNull(genericUtility.getColumnValue("purc_order", dom));
indNo =checkNull(genericUtility.getColumnValue("ind_no", dom)); indNo =checkNull(genericUtility.getColumnValue("ind_no", dom));
...@@ -1186,6 +1191,7 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1186,6 +1191,7 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
} }
/*CODE FOR INDENT AND INDENT REQ VALIDATION COUNT*/ /*CODE FOR INDENT AND INDENT REQ VALIDATION COUNT*/
int cntindamdhdr =0;
sql="select count(*) from indent where status = 'U' and proj_code = ?"; sql="select count(*) from indent where status = 'U' and proj_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,projCode); pstmt.setString(1,projCode);
...@@ -1230,9 +1236,32 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1230,9 +1236,32 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
break; break;
} }
sql1 = "select count(*) from indent_amd where confirmed = 'N' and proj_code = ? ";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,projCode);
rs = pstmt.executeQuery();
while (rs.next())
{
cntindamdhdr = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql1 =" select sum(quantity * purc_rate) " + System.out.println("Count for indent where unconfirmed indent>>>> + "+ cntindhdr);
if (cntindamdhdr >= 1)
{
errCode = "VTDUPROJ3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
/*sql1 =" select sum(quantity * purc_rate) " +
"from indent where proj_code = ? " + "from indent where proj_code = ? " +
"and status NOT IN ('C','X')"; "and status NOT IN ('C','X')";
projCode =checkNull(genericUtility.getColumnValue("proj_code",dom )); projCode =checkNull(genericUtility.getColumnValue("proj_code",dom ));
...@@ -1269,11 +1298,11 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1269,11 +1298,11 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
totAmtDetIndent =totAmtIndent - indBalance; totAmtDetIndent =totAmtIndent - indBalance;
System.out.println("totAmtDet for Indent with quant* rate>>>>>>>> "+ totAmtIndent); System.out.println("totAmtDet for Indent with quant* rate>>>>>>>> "+ totAmtIndent);
System.out.println("totAmtDet for Indent with ordqty * purcrate>>>>>>>> "+indBalance); System.out.println("totAmtDet for Indent with ordqty * purcrate>>>>>>>> "+indBalance);
System.out.println("totAmtDet for Indent with totAmtDetIndent>>>>>>>> "+totAmtDetIndent); System.out.println("totAmtDet for Indent with totAmtDetIndent>>>>>>>> "+totAmtDetIndent);*/
Double totAmtDetpordertot =0.0;
sql = "select sum(a.quantity * a.rate) from porddet a, porder b" + sql = "select sum(a.quantity * a.rate) from porddet a, porder b" +
" where ( a.purc_order = b.purc_order ) and b.confirmed = 'Y'" + " where ( a.purc_order = b.purc_order ) and b.confirmed = 'Y'" +
" and a.proj_code = ? and a.purc_order! = ? "; " and a.proj_code = ? and a.purc_order! = ? and b.status! = 'X'";
projCode =checkNull(genericUtility.getColumnValue("proj_code",dom )); projCode =checkNull(genericUtility.getColumnValue("proj_code",dom ));
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -1355,6 +1384,8 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1355,6 +1384,8 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
totAmtDetPoamdDetbrowtemp =quantitypoamddet * ratepoamddet; totAmtDetPoamdDetbrowtemp =quantitypoamddet * ratepoamddet;
pordNo =checkNull(genericUtility.getColumnValueFromNode("purc_order", detail2List.item(a))); pordNo =checkNull(genericUtility.getColumnValueFromNode("purc_order", detail2List.item(a)));
linenoOrd=checkNull(genericUtility.getColumnValueFromNode("line_no_ord", detail2List.item(a))); linenoOrd=checkNull(genericUtility.getColumnValueFromNode("line_no_ord", detail2List.item(a)));
System.out.println("totamtdetpoamd");
sql1 ="select sum(a.quantity * a.rate) from porddet a, porder b" + sql1 ="select sum(a.quantity * a.rate) from porddet a, porder b" +
" where ( a.purc_order = b.purc_order ) and b.confirmed = 'Y'" + " where ( a.purc_order = b.purc_order ) and b.confirmed = 'Y'" +
" and a.proj_code = ? and a.purc_order = ? and line_no NOT IN (?) " ; " and a.proj_code = ? and a.purc_order = ? and line_no NOT IN (?) " ;
...@@ -1363,7 +1394,7 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1363,7 +1394,7 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
pstmt.setString(1, projCode); pstmt.setString(1, projCode);
pstmt.setString(2,pordNo); pstmt.setString(2,pordNo);
pstmt.setString(3, lineNoOrd); pstmt.setString(3, lineNoOrd);
System.out.println("pordNo is....."+pordNo);
System.out.println("Project code is....."+projCode); System.out.println("Project code is....."+projCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
...@@ -1387,17 +1418,66 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -1387,17 +1418,66 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
System.out.println("totAmtDetPoamdDetbrow>>"+ totAmtDetPoamdDetbrow); System.out.println("totAmtDetPoamdDetbrow>>"+ totAmtDetPoamdDetbrow);
System.out.println("totAmtDet for Indent with quant* rate>>>>>>>> "+ totAmtDetIndent); //System.out.println("totAmtDet for Indent with quant* rate>>>>>>>> "+ totAmtDetIndent);
System.out.println("totAmtDet for poamd>>>>>>>> " +totAmtDetPoamdDetbrow); System.out.println("totAmtDet for poamd>>>>>>>> " +totAmtDetPoamdDetbrow);
System.out.println("totAmtDet for porder>>>>>>>> " +totAmtDetporder); System.out.println("totAmtDet for porder>>>>>>>> " +totAmtDetporder);
totAmtProj = totAmtDetIndent + totAmtDetPoamdDetbrow + totAmtDetporder + totAmtDetpordertot; //totAmtProj = totAmtDetIndent + totAmtDetPoamdDetbrow + totAmtDetporder + totAmtDetpordertot;
totAmtProj = totAmtDetPoamdDetbrow + totAmtDetporder + totAmtDetpordertot;
System.out.println("totAmtProj>>>>> "+totAmtProj); System.out.println("totAmtProj>>>>> "+totAmtProj);
if(totAmtProj > approxCost ) if(totAmtProj > approxCost )
{ {
//errCode = "VTPROJCOST";
//TODO
errCode = "VTPROJCOST"; errCode = "VTPROJCOST";
errList.add(errCode); errString = getErrorString("proj_code", errCode, userId);
// errString = itmDBAccessEJB.getErrorString("","VTPROJCOST","","",conn);
System.out.println("::: errorstring ::: "+errString);
String startStr = errString.substring(0, errString.indexOf("<description>")+13);
String endStr = errString.substring(errString.indexOf("</description>"), errString.length());
String descrStr = errString.substring(errString.indexOf("<description>")+13, errString.indexOf("</description>"));
String descrStart = descrStr.substring(0, descrStr.indexOf("]"));
String descrEnd = descrStr.substring(descrStr.indexOf("]"), descrStr.length());
/*String totAmtProjStr =Double.toString(totAmtProj);
String approxCostStr = Double.toString(approxCost);
String totAmtDetPoamdDetbrowStr =Double.toString(totAmtDetPoamdDetbrow);*/
String value = "Approx Cost Of budget : "+BigDecimal.valueOf(approxCost).toPlainString() + "" +
", Exceeded Amount : "+ BigDecimal.valueOf(totAmtProj).toPlainString() ;
descrStart = descrStart.concat(value).concat(descrEnd);
errString = startStr.concat(descrStart).concat(endStr);
errorType = errorType(conn, errCode);
if (errString.length() > 0) {
String bifurErrString = errString.substring(errString
.indexOf("<Errors>") + 8, errString
.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(errString
.indexOf("</trace>") + 8, errString
.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E")) {
break;
}
//return errString;
/*errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break; break;*/
} }
} }
} }
...@@ -2150,7 +2230,6 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal, ...@@ -2150,7 +2230,6 @@ public class POrderAmdIC extends ValidatorEJB implements POrderAmdICLocal,
if (rs.next()) { if (rs.next()) {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
......
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