Commit 20ad741e authored by ssalve's avatar ssalve

Updated CostCtrAllocIC.java class on 03November2017

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@172869 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 85898f69
...@@ -4,6 +4,7 @@ import ibase.system.config.AppConnectParm; ...@@ -4,6 +4,7 @@ import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
...@@ -17,6 +18,7 @@ import java.sql.Connection; ...@@ -17,6 +18,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -38,7 +40,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -38,7 +40,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
{ {
public String globalXtraParams = ""; public String globalXtraParams = "";
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
DecimalFormat deciFormater = new DecimalFormat("0.00");
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{ {
Document dom = null; Document dom = null;
...@@ -90,6 +92,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -90,6 +92,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
int childNodeLength = 0; int childNodeLength = 0;
int ctr = 0, cnt = 0; int ctr = 0, cnt = 0;
String childNodeName = "",siteCode="",prdCode=""; String childNodeName = "",siteCode="",prdCode="";
double totalPer=0 ,crntPer=0;
String allocation = "",CurrentLineNo="";
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try try
{ {
...@@ -98,7 +102,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -98,7 +102,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::"+currentFormNo); System.out.println("currentFormNo::: in Validation"+currentFormNo);
switch(currentFormNo) switch(currentFormNo)
{ {
case 1: case 1:
...@@ -117,8 +121,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -117,8 +121,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
if("site_code".equalsIgnoreCase(childNodeName)) if("site_code".equalsIgnoreCase(childNodeName))
{ {
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom)).trim(); siteCode = checkNull(genericUtility.getColumnValue("site_code",dom)).trim();
System.out.println("site_code******"+siteCode); System.out.println("site_code******"+siteCode);
}//end of if block for site_code }//end of if block for site_code
else if("prd_code".equalsIgnoreCase(childNodeName)) else if("prd_code".equalsIgnoreCase(childNodeName))
{ {
...@@ -127,40 +130,95 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -127,40 +130,95 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
}//end of if block for prd_code }//end of if block for prd_code
}//end of for loop }//end of for loop
if(siteCode == null || siteCode.trim().length() ==0) if(siteCode == null || siteCode.trim().length() ==0)
{ {
errCode = "VMPSITECD"; errCode = "VMPSITECD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(prdCode == null || prdCode.trim().length() == 0) else
{ {
errCode = "VPATDPRC01"; sql = "select count(*) as cnt from site where site_code=?";
errList.add(errCode); pstmt = conn.prepareStatement(sql);
errFields.add(childNodeName.toLowerCase()); pstmt.setString(1,siteCode);
} rs = pstmt.executeQuery();
if(rs.next())
System.out.println("Site Code is ==="+siteCode +"----- AND -----"+"Period Code is ===="+prdCode); {
sql = "select count(*) as count from resource_cons where site_code=? and prd_code=?"; cnt = rs.getInt("cnt");
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,siteCode); if(pstmt != null)
pstmt.setString(2,prdCode); {
rs = pstmt.executeQuery(); pstmt.close();
if(rs.next()) pstmt = null;
{ }
cnt = rs.getInt("count"); if(rs != null)
System.out.println("Count is :::::"+cnt); {
} rs.close();
if(pstmt != null) rs = null;
{ }
pstmt.close(); if(cnt==0)
pstmt = null; {
} errCode = "VTSITEXT";
if(rs != null) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
rs.close(); }
rs = null; }
} if(prdCode == null || prdCode.trim().length() == 0)
{
errCode = "VPATDPRC01";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom)).trim();
sql = "select count(*) as cnt from period where code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt==0)
{
errCode = "VTMONATD10";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
System.out.println("Site Code is ==="+siteCode +"----- AND -----"+"Period Code is ===="+prdCode);
sql = "select count(*) as count from resource_cons where site_code=? and prd_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
System.out.println("Count is :::::"+cnt);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
/* if(cnt > 0) /* if(cnt > 0)
{ {
...@@ -168,94 +226,190 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -168,94 +226,190 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
}*/ }*/
}//end of case1 }//end of case1
break; break;
}//end of switch statement
int errListSize = errList.size(); case 2:
System.out.println("errListSize::::::::::"+errListSize); {
int count = 0; System.out.println("Inside Case3 Validation:::");
String errFldName = null; parentNodeList = dom.getElementsByTagName("Detail2");
if (errList != null && errListSize > 0) parentNode = parentNodeList.item(0);
{ childNodeList = parentNode.getChildNodes();
for (count = 0; count < errListSize; count++) childNodeLength = childNodeList.getLength();
{ for(ctr = 0; ctr < childNodeLength; ctr++)
errCode = errList.get(count); {
errFldName = errFields.get(count); childNode = childNodeList.item(ctr);
System.out.println(" testing :errCode .:" + errCode); childNodeName = childNode.getNodeName();
errString = getErrorString(errFldName, errCode, userId); System.out.println("childNodeName::: for Case3"+childNodeName);
System.out.println("errString>>>>>>>>>"+errString); }
errorType = errorType(conn, errCode); }
if (errString.length() > 0) break;
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); case 3:
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); {
errStringXml.append(bifurErrString); System.out.println("Inside Case3 Validation:::");
errString = ""; parentNodeList = dom.getElementsByTagName("Detail3");
} parentNode = parentNodeList.item(0);
if (errorType.equalsIgnoreCase("E")) childNodeList = parentNode.getChildNodes();
{ childNodeLength = childNodeList.getLength();
break; for(ctr = 0; ctr < childNodeLength; ctr++)
} {
} childNode = childNodeList.item(ctr);
errList.clear(); childNodeName = childNode.getNodeName();
errList = null; System.out.println("childNodeName::: for Case3"+childNodeName);
errFields.clear(); if("allocation".equalsIgnoreCase(childNodeName))
errFields = null; {
errStringXml.append("</Errors> </Root> \r\n"); allocation = checkNull(genericUtility.getColumnValue("allocation",dom)).trim();
} CurrentLineNo= checkNull(genericUtility.getColumnValue("line_no",dom)).trim();
else System.out.println("Allocation Percentage Value is :::::["+allocation+"]");
{
errStringXml = new StringBuffer(""); if(allocation.trim().length()==0 || allocation == null)
} {
System.out.println("inside alloc_perc LENGTH..");
}//end of if for obj_context errCode = "VMEMPQLF03";
}//end of try block errList.add(errCode);
catch(Exception e) errFields.add(childNodeName.toLowerCase());
{ }
System.out.println("Exception ::"+e); else
e.printStackTrace(); {
} System.out.println("inside alloc_perc ");
finally crntPer = Double.parseDouble(allocation);
System.out.println("crntPer :::::["+crntPer+"]");
NodeList detailNoteList = dom2.getElementsByTagName("Detail3");
int detlCnt = detailNoteList.getLength();
System.out.println("DETAIL COUNT" +detlCnt);
totalPer = getNumOftotalallocPercentage( dom2 ,CurrentLineNo);
System.out.println("TOTAL AMOUNT..." +totalPer);
if(totalPer > 100)
{
System.out.println("AMOUNT..." +crntPer);
errCode = "OVERALLINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(totalPer < 100)
{
System.out.println("AMOUNT..." +crntPer);
errCode = "VTRCONT2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
/* if(detlCnt >=2)
{
totalPer = getNumOftotalallocPercentage( dom2 ,CurrentLineNo);
System.out.println("TOTAL AMOUNT..." +totalPer);
double remAmt = 100 - totalPer; // 5
if(crntPer > remAmt) //
{
System.out.println("EXCEED AMOUNT..." +remAmt);
errCode = "OVERALLINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
if(crntPer > 100)
{
System.out.println("AMOUNT..." +crntPer);
errCode = "OVERALLINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}*/
}
}
}//end of for loop
}//end of case3
break;
}//end of switch statement
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>"+errString);
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;
}
}//end of for loop
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//end of if for obj_context
}//end of try block
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
}
finally
{
try
{ {
try if (conn != null)
{ {
if (conn != null) if (rs != null)
{ {
if (rs != null) rs.close();
{ rs = null;
rs.close(); }
rs = null; if (pstmt != null)
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch (Exception d)
{ {
d.printStackTrace(); pstmt.close();
throw new ITMException(d); pstmt = null;
} }
} conn.close();
errString = errStringXml.toString(); }
System.out.println("testing : final errString : " + errString); conn = null;
return errString; }
}// end of wfvalData method catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}//end of finally block
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}// end of wfvalData method
private String checkNull(String input) private String checkNull(String input)
{ {
return input == null ? "" : input; return input == null ? "" : input;
} }
public String defaultDataWiz() throws RemoteException, ITMException public String defaultDataWiz() throws RemoteException, ITMException
{ {
return ""; return "";
} }
//private String defaultDataWiz( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName ) throws RemoteException,ITMException //private String defaultDataWiz( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName ) throws RemoteException,ITMException
/*public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException /*public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
...@@ -394,12 +548,13 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -394,12 +548,13 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
String fromDate = "", toDate ="",acctPeriod = "",finEntity =""; String fromDate = "", toDate ="",acctPeriod = "",finEntity ="";
ArrayList cosAllocationList = new ArrayList(); ArrayList cosAllocationList = new ArrayList();
HashMap dataMap = null; HashMap dataMap = null;
String cctrCodeFrm = "", acctCode = "",subGroupCode = "",groupCode = "", allocBasis = "",resBasis = "",tranIDMst = ""; String cctrCodeFrm = "", acctCode = "",subGroupCode = "",groupCode = "",accCatGrp = "", allocBasis = "",resBasis = "",tranIDMst = "";
int childNodeListLength = 0; int childNodeListLength = 0;
Timestamp fromDateTimestamp = null; Timestamp fromDateTimestamp = null;
Timestamp toDateTimestamp = null; Timestamp toDateTimestamp = null;
int domID=0,domIDDet =0; int domID=0,domIDDet =0;
String drcrFlagVal = ""; String drcrFlagVal = "", allocdescr = "";
double allocation_perc=0,unitAllocation = 0;;
int cnt=0; int cnt=0;
double allocPercent=0; double allocPercent=0;
try try
...@@ -534,6 +689,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -534,6 +689,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
if(rs.next()) if(rs.next())
{ {
prdCodeDescr = rs.getString("descr"); prdCodeDescr = rs.getString("descr");
System.out.println("Description is ::::===="+prdCodeDescr);
} }
if(pstmt != null) if(pstmt != null)
{ {
...@@ -546,10 +702,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -546,10 +702,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
rs = null; rs = null;
} }
valueXmlString.append("<period_descr>").append("<![CDATA["+prdCodeDescr+"]]>").append("</period_descr>\r\n"); valueXmlString.append("<period_descr>").append("<![CDATA["+prdCodeDescr+"]]>").append("</period_descr>\r\n");
} }
valueXmlString.append("</Detail1>\r\n"); valueXmlString.append("</Detail1>\r\n");
break; break;
} }
...@@ -574,8 +727,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -574,8 +727,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
{ {
/*valueXmlString.append("<acct_code><![CDATA[").append("acct01").append( "]]></acct_code>"); /*valueXmlString.append("<acct_code><![CDATA[").append("acct01").append( "]]></acct_code>");
valueXmlString.append("<accounts_descr><![CDATA[").append("Trave Expense").append( "]]></accounts_descr>"); valueXmlString.append("<accounts_descr><![CDATA[").append("Trave Expense").append( "]]></accounts_descr>");
valueXmlString.append("<costalloc_bas_alloc_basis><![CDATA[").append("Percentage(%) Basis").append( "]]></costalloc_bas_alloc_basis>");*/ valueXmlString.append("<costalloc_bas_alloc_basis><![CDATA[").append("Percentage(%) Basis").append( "]]></costalloc_bas_alloc_basis>");*/
sSQL = "select fr_date, to_date, acct_prd from period where code = ?"; sSQL = "select fr_date, to_date, acct_prd from period where code = ?";
pstmt = conn.prepareStatement(sSQL); pstmt = conn.prepareStatement(sSQL);
...@@ -638,7 +790,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -638,7 +790,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
+" and exp_date >= ? " +" and exp_date >= ? "
+" group by cctr_code__from, sgroup_code, group_code, acct_code";*/ +" group by cctr_code__from, sgroup_code, group_code, acct_code";*/
sSQL = "select tran_id,cctr_code__from, sgroup_code,group_code, acct_code, alloc_basis, res_basis from costalloc_bas " sSQL = "select tran_id,cctr_code__from, sgroup_code,group_code,acct_cat, acct_code, alloc_basis, res_basis from costalloc_bas "
+ " where site_code = ? " + " where site_code = ? "
+" and eff_from >= ? " +" and eff_from >= ? "
+" and valid_upto <= ? "; +" and valid_upto <= ? ";
...@@ -694,6 +846,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -694,6 +846,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
cctrCodeFrm = (String)tempMap.get("cctr_code__from"); cctrCodeFrm = (String)tempMap.get("cctr_code__from");
acctCode = (String)tempMap.get("acct_code"); acctCode = (String)tempMap.get("acct_code");
subGroupCode = (String)tempMap.get("sgroup_code"); subGroupCode = (String)tempMap.get("sgroup_code");
accCatGrp = (String)tempMap.get("acct_cat");
groupCode = (String)tempMap.get("group_code"); groupCode = (String)tempMap.get("group_code");
allocBasis = (String)tempMap.get("alloc_basis"); allocBasis = (String)tempMap.get("alloc_basis");
resBasis = (String)tempMap.get("res_basis"); resBasis = (String)tempMap.get("res_basis");
...@@ -702,13 +855,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -702,13 +855,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("cctrList :::------------------"+cctrList+"]")*/; System.out.println("cctrList :::------------------"+cctrList+"]")*/;
ArrayList<HashMap> accountDataList = getAllocationAmt(siteCode ,groupCode,subGroupCode ,acctCode,acctPeriod,finEntity,cctrCodeFrm,prdCode ,conn); ArrayList<HashMap> accountDataList = getAllocationAmt(siteCode ,groupCode,subGroupCode ,accCatGrp,acctCode,acctPeriod,finEntity,cctrCodeFrm,prdCode ,conn);
System.out.println("accountList :::////////////////////////"+accountDataList.toString()); System.out.println("accountList :::////////////////////////"+accountDataList.toString());
int accountListLength = accountDataList.size(); int accountListLength = accountDataList.size();
System.out.println("accountListLength ++++++++++++"+accountListLength); System.out.println("accountListLength ++++++++++++"+accountListLength);
if("1".equalsIgnoreCase(allocBasis))
{
allocdescr = "Percentage";
}
else
{
allocdescr = "Resource";
}
System.out.println("allocdescr ::::: ["+allocdescr+"]");
double totUnit = 0.0; double totUnit = 0.0;
String acctCodeGet = "",acctCodeGetDescr = " ",detail3 =""; String acctCodeGet = "",acctCodeGetDescr = " ",detail3 ="";
...@@ -731,8 +892,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -731,8 +892,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("Value of drcr_flag is ======="+drcrFlagVal); System.out.println("Value of drcr_flag is ======="+drcrFlagVal);
domID++; domID++;
valueXmlString.append("<Detail2 domID='" + domID + "' selected=\"Y\">\r\n"); valueXmlString.append("<Detail2 domID='" + domID + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"N\"/>\r\n"); valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlString.append("<tran_id><![CDATA[" ).append(checkNull("")).append( "]]></tran_id>\r\n" ); //valueXmlString.append("<tran_id><![CDATA[" ).append(checkNull("1")).append( "]]></tran_id>\r\n" );
valueXmlString.append("<tran_id_mst><![CDATA[" ).append(checkNull(tranIDMst)).append( "]]></tran_id_mst>\r\n" ); valueXmlString.append("<tran_id_mst><![CDATA[" ).append(checkNull(tranIDMst)).append( "]]></tran_id_mst>\r\n" );
valueXmlString.append("<prd_code><![CDATA[" ).append(checkNull(prdCode)).append( "]]></prd_code>\r\n" ); valueXmlString.append("<prd_code><![CDATA[" ).append(checkNull(prdCode)).append( "]]></prd_code>\r\n" );
valueXmlString.append("<site_code><![CDATA[" ).append(checkNull(siteCode)).append( "]]></site_code>\r\n" ); valueXmlString.append("<site_code><![CDATA[" ).append(checkNull(siteCode)).append( "]]></site_code>\r\n" );
...@@ -743,9 +904,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -743,9 +904,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
valueXmlString.append("<exp_head><![CDATA[" ).append(checkNull(acctCodeGetDescr)).append( "]]></exp_head>\r\n" ); valueXmlString.append("<exp_head><![CDATA[" ).append(checkNull(acctCodeGetDescr)).append( "]]></exp_head>\r\n" );
valueXmlString.append("<alloc_basis><![CDATA[" ).append(checkNull(allocBasis)).append( "]]></alloc_basis>\r\n" ); valueXmlString.append("<alloc_basis><![CDATA[" ).append(checkNull(allocBasis)).append( "]]></alloc_basis>\r\n" );
valueXmlString.append("<res_basis><![CDATA[" ).append(checkNull(resBasis)).append( "]]></res_basis>\r\n" ); valueXmlString.append("<res_basis><![CDATA[" ).append(checkNull(resBasis)).append( "]]></res_basis>\r\n" );
valueXmlString.append("<tot_units><![CDATA[" ).append(totUnit).append( "]]></tot_units>\r\n" ); valueXmlString.append("<tot_units><![CDATA[" ).append(deciFormater.format(totUnit)).append( "]]></tot_units>\r\n" );
valueXmlString.append("<current_form_subform><![CDATA[" ).append("3").append( "]]></current_form_subform>\r\n" ); valueXmlString.append("<current_form_subform><![CDATA[" ).append("3").append( "]]></current_form_subform>\r\n" );
valueXmlString.append("<drcr_flag><![CDATA[" ).append(drcrFlagVal).append( "]]></drcr_flag>\r\n" ); valueXmlString.append("<drcr_flag><![CDATA[" ).append(drcrFlagVal).append( "]]></drcr_flag>\r\n" );
valueXmlString.append("<allocpercdescr><![CDATA[" ).append(checkNull(allocdescr)).append( "]]></allocpercdescr>\r\n" );
valueXmlString.append("</Detail2>\r\n"); valueXmlString.append("</Detail2>\r\n");
detail3 = getCostCenetrAllocationDetail(siteCode, acctCodeGet, tranIDMst, totUnit, resBasis, allocBasis, conn); detail3 = getCostCenetrAllocationDetail(siteCode, acctCodeGet, tranIDMst, totUnit, resBasis, allocBasis, conn);
...@@ -763,15 +925,15 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -763,15 +925,15 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
break; break;
} }
case 3 : case 3 :
{ {
parentNodeList = dom.getElementsByTagName("Detail2"); parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("childNodeName ::::: for Detail3"+childNodeName);
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
String detailData3 = "",tranIdMaster = "",acctCodeGet = "", String detailData3 = "",tranIdMaster = "",acctCodeGet = "",
resBas ="",allocBas = ""; resBas ="",allocBas = "";
...@@ -785,13 +947,38 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -785,13 +947,38 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
resBas = checkNull(genericUtility.getColumnValue("res_basis", dom2)); resBas = checkNull(genericUtility.getColumnValue("res_basis", dom2));
allocBas = checkNull(genericUtility.getColumnValue("alloc_basis", dom2)); allocBas = checkNull(genericUtility.getColumnValue("alloc_basis", dom2));
totUnit = Double.parseDouble(genericUtility.getColumnValue("tot_units", dom2)); totUnit = Double.parseDouble(genericUtility.getColumnValue("tot_units", dom2));
//allocation_perc = checkNull(genericUtility.getColumnValue("allocation", dom2));
System.out.println("prdCode :::111:["+prdCode+"]" + "siteCode ::::["+siteCode+"]Master tranId["+tranIdMaster+"]Acct Code["+acctCodeGet+"]Res Bas["+resBas+"]allocBas["+allocBas+"] Tot Units["+totUnit+"]"+"allocPercent["+allocPercent+"]"); System.out.println("prdCode :::111:["+prdCode+"]" + "siteCode ::::["+siteCode+"]Master tranId["+tranIdMaster+"]Acct Code["+acctCodeGet+"]Res Bas["+resBas+"]allocBas["+allocBas+"] Tot Units["+totUnit+"]"+"allocPercent["+allocPercent+"]");
if("itm_default".equalsIgnoreCase(currentColumn.trim())) if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{ {
detailData3 = getCostCenetrAllocationDetail(siteCode, acctCodeGet, tranIdMaster, totUnit, resBas, allocBas, conn); detailData3 = getCostCenetrAllocationDetail(siteCode, acctCodeGet, tranIdMaster, totUnit, resBas, allocBas, conn);
valueXmlString.append(detailData3 + "\r\n"); valueXmlString.append(detailData3 + "\r\n");
} }
else if("allocation".equalsIgnoreCase(currentColumn))
{
String accountCode="";
Node curDetail = dom.getChildNodes().item(0);
System.out.println("detailString value is DOM=="+genericUtility.serializeDom(dom));
domIDDet = Integer.parseInt(curDetail.getAttributes().getNamedItem("domID").getNodeValue());
System.out.println("domIDDet ["+domIDDet+"]");
totUnit = Double.parseDouble(genericUtility.getColumnValue("tot_units", dom));
allocation_perc = Double.parseDouble(genericUtility.getColumnValue("allocation", dom));
System.out.println("Value of totUnit :::: ["+totUnit+"]" + "allocation_perc :::: ["+allocation_perc+"]");
unitAllocation = setUnitAllocationValue(totUnit,allocation_perc);
accountCode = checkNull(genericUtility.getColumnValue("acct_code", dom));
System.out.println("allocation_perc ::::["+allocation_perc+"]" + "unitAllocation ::::["+unitAllocation+"]" + "accountCode ::::["+accountCode+"]" + "totUnit ::::: ["+totUnit+"]");
valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlString.append("<selectbox>true</selectbox>\r\n");
valueXmlString.append("<unit_alloc><![CDATA[" ).append(unitAllocation).append( "]]></unit_alloc>\r\n" );
valueXmlString.append("</Detail3>\r\n");
}
break; break;
} }
...@@ -829,14 +1016,12 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -829,14 +1016,12 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
} }
} }//end of finally block
return valueXmlString.toString(); return valueXmlString.toString();
} }//end of defaultDataWiz
private ArrayList<HashMap> getAllocationAmt(String siteCode ,String groupCode,String subGroupCode ,String acctCode,String acctPeriod,String finEntity,String cctrCodeFrm,String periodCode ,Connection conn) throws ITMException
{
private ArrayList<HashMap> getAllocationAmt(String siteCode ,String groupCode,String subGroupCode ,String catGroupCode,String acctCode,String acctPeriod,String finEntity,String cctrCodeFrm,String periodCode ,Connection conn) throws ITMException
{
ArrayList<HashMap> accontsList = new ArrayList<HashMap>(); ArrayList<HashMap> accontsList = new ArrayList<HashMap>();
HashMap tempMap = null; HashMap tempMap = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -846,7 +1031,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -846,7 +1031,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
double allocAmt = 0.0; double allocAmt = 0.0;
boolean isGroup = false; boolean isGroup = false;
boolean isSubGroup = false; boolean isSubGroup = false;
System.out.println("siteCode>>"+siteCode +"groupCode>>"+groupCode+"subGroupCode>>"+subGroupCode+"acctCode>>"+acctCode+"acctPeriod>>"+acctPeriod+"finEntity>>"+finEntity+"cctrCodeFrm>>"+cctrCodeFrm+"periodCode>>"+periodCode); boolean isCatGroup = false;
System.out.println("siteCode>>"+siteCode +"groupCode>>"+groupCode+"subGroupCode>>"+subGroupCode+"acctCode>>"+catGroupCode+"catGroupCode>>"+acctCode+"acctPeriod>>"+acctPeriod+"finEntity>>"+finEntity+"cctrCodeFrm>>"+cctrCodeFrm+"periodCode>>"+periodCode);
try try
{ {
tempMap = new HashMap(); tempMap = new HashMap();
...@@ -898,6 +1084,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -898,6 +1084,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
+" and s.group_code = ? group by b.acct_code,b.descr "; +" and s.group_code = ? group by b.acct_code,b.descr ";
isGroup = true; isGroup = true;
} }
else if(catGroupCode != null && catGroupCode.length() > 0)
{
sSql = " select sum(dr_amt - cr_amt),b.acct_code,b.descr "
+" from acctbal a, accounts b,acctsgrp s , acctgrp g "
+" where a.acct_prd = ? "
+" and a.prd_code = ? "
+" and a.fin_entity = ? "
+" and a.acct_code = b.acct_code "
+" and b.sgroup_code = s.sgroup_code "
+" and g.group_code = s.group_code "
+" and a.cctr_code = ? "
+" and a.site_code = ?"
+" and s.acct_cat = ? group by b.acct_code,b.descr ";
isCatGroup = true;
}
pstmt = conn.prepareStatement(sSql); pstmt = conn.prepareStatement(sSql);
pstmt.setString(1,acctPeriod); pstmt.setString(1,acctPeriod);
...@@ -918,6 +1119,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -918,6 +1119,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
{ {
pstmt.setString(6,groupCode); pstmt.setString(6,groupCode);
} }
else if(isCatGroup)
{
pstmt.setString(6,catGroupCode);
}
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()) while(rs.next())
...@@ -941,23 +1146,18 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -941,23 +1146,18 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
tempMap.put("acct_code", acountCode); tempMap.put("acct_code", acountCode);
tempMap.put("acct_descr", acctDescr); tempMap.put("acct_descr", acctDescr);
tempMap.put("alloc_amt", allocAmt); tempMap.put("alloc_amt", allocAmt);
accontsList.add(tempMap);
accontsList.add(tempMap); }
}
} catch (Exception e)
{
// TODO: handle exception
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("accontsList :::::--------------------------"+accontsList); System.out.println("accontsList :::::--------------------------"+accontsList);
return accontsList; return accontsList;
} }
private ArrayList<HashMap> getCostCenterList(String siteCode,String traidMst,String resBas,String allocBas,Connection conn) throws ITMException private ArrayList<HashMap> getCostCenterList(String siteCode,String traidMst,String resBas,String allocBas,Connection conn) throws ITMException
...@@ -965,7 +1165,9 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -965,7 +1165,9 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("Inside getCostCenterList method"); System.out.println("Inside getCostCenterList method");
System.out.println("siteCode4545::["+siteCode+"]"+"traidMst::["+traidMst+"]"+"resBas::["+resBas+"]"+"allocBas::123["+allocBas+"]"); System.out.println("siteCode4545::["+siteCode+"]"+"traidMst::["+traidMst+"]"+"resBas::["+resBas+"]"+"allocBas::123["+allocBas+"]");
ArrayList<HashMap> cctrList = new ArrayList<HashMap>(); ArrayList<HashMap> cctrList = new ArrayList<HashMap>();
ArrayList<HashMap> tempList = new ArrayList<HashMap>();
HashMap tempMap = null; HashMap tempMap = null;
HashMap tempMap1 = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
String sSql = ""; String sSql = "";
...@@ -973,6 +1175,9 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -973,6 +1175,9 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
double allocAmt = 0.0; double allocAmt = 0.0;
boolean isGroup = false; boolean isGroup = false;
boolean isSubGroup = false; boolean isSubGroup = false;
String itemSer = "",techSpec = "",utilSQL = "";
double invAmt = 0;
double totSalesAmt = 0.0;
try try
{ {
...@@ -1009,55 +1214,147 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1009,55 +1214,147 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
cctrList.add(tempMap); cctrList.add(tempMap);
} }
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}//end of if block for alloc_basis is 1
else if("2".equalsIgnoreCase(allocBas.trim())) else if("2".equalsIgnoreCase(allocBas.trim()))
{ {
System.out.println("Inside Else Block of getCostCenterList method");
String resBasis = getResourceBasVal(conn);
sSql = "select util_sql from resource_basis where res_bas = ?"; sSql = "select util_sql from resource_basis where res_bas = ?";
} pstmt = conn.prepareStatement(sSql);
pstmt.setString(1,resBasis);
rs = pstmt.executeQuery();
} catch (Exception e) { while(rs.next())
{
utilSQL = rs.getString("util_sql");
System.out.println("utilSQL ::::: ["+utilSQL+"]");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(utilSQL != null)
{
pstmt = conn.prepareStatement(utilSQL);
rs = pstmt.executeQuery();
while(rs.next())
{
itemSer = rs.getString("item_ser");
techSpec = rs.getString("tech_spec");
invAmt = rs.getDouble("inv_amt");
totSalesAmt = totSalesAmt + invAmt;
System.out.println("Value of itemSer::["+itemSer+"]" + "Value of techSpec:: ["+techSpec+"]" + "Value of invAmt::["+invAmt+"]");
tempMap1 = new HashMap();
tempMap1.put("item_ser", itemSer);
tempMap1.put("tech_spec", techSpec);
tempMap1.put("inv_amt", invAmt);
tempList.add(tempMap1);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
int temListlen = tempList.size();
if(temListlen > 0 && totSalesAmt >0)
{
HashMap dataMap = null;
double calcAlloc = 0.0;
for (int iCtr = 0; iCtr < temListlen; iCtr++)
{
dataMap = tempList.get(iCtr);
cctrCode = (String)dataMap.get("tech_spec");
itemSer = (String)dataMap.get("item_ser");
invAmt = (double)dataMap.get("inv_amt");
calcAlloc = (invAmt / totSalesAmt) * 100;
System.out.println("calcAlloc Amt::[" +calcAlloc+"]");
calcAlloc = Math.round(calcAlloc);
System.out.println("calcAlloc Amt after Round::[" +calcAlloc+"]");
tempMap = new HashMap();
tempMap.put("cctr_code", cctrCode);
tempMap.put("acct_code__alloc", itemSer);
tempMap.put("cctr_descr", cctrCode);
tempMap.put("alloc_perc",String.valueOf(calcAlloc));
cctrList.add(tempMap);
}
}//end of if block
}//end of if block for utilSQL
}//end of else for alloc basis 2
}//end of try block....
catch (Exception e)
{
// TODO: handle exception // TODO: handle exception
System.out.println(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("accontsList :::::"+cctrList); System.out.println("accontsList :::::"+cctrList);
return cctrList; return cctrList;
}//end of method getCostCenterList
}
private String getCostCenetrAllocationDetail(String siteCode,String acctCodeFor,String traidMst,double totUnit,String resBas,String allocBas,Connection conn) private String getCostCenetrAllocationDetail(String siteCode,String acctCodeFor,String traidMst,double totUnit,String resBas,String allocBas,Connection conn) throws ITMException
{ {
System.out.println("Inside getCostCenetrAllocationDetail method"); System.out.println("Inside getCostCenetrAllocationDetail method");
ArrayList cctrDataList = null; ArrayList cctrDataList = null;
StringBuffer valueXmlString = new StringBuffer(""); StringBuffer valueXmlString = new StringBuffer("");
int domIDDet =0; int domIDDet =0;
FinCommon finCommon = new FinCommon();
try try
{ {
cctrDataList = getCostCenterList(siteCode, traidMst, resBas, allocBas, conn); cctrDataList = getCostCenterList(siteCode, traidMst, resBas, allocBas, conn);
System.out.println("cctrDataList Value ::::::::::["+cctrDataList+"]");
int costCtrtListLength = cctrDataList.size(); int costCtrtListLength = cctrDataList.size();
System.out.println("costCtrtListLength ["+costCtrtListLength+"]"); System.out.println("costCtrtListLength ["+costCtrtListLength+"]");
System.out.println("Value of siteCode ::["+siteCode+"]" + "Value of traidMst ::["+traidMst+"]" + "Value of resBas ::["+resBas+"]" + "Value of allocBas ::["+allocBas+"]");
if(costCtrtListLength > 0) if(costCtrtListLength > 0)
{ {
HashMap cctrDataMap = null; HashMap cctrDataMap = null;
double percentage = 0.0; double percentage = 0.0,allocPerc = 0.0;
double allocUnit = 0.0; double allocUnit = 0.0;
String ccctrCode = ""; String ccctrCode = "";
String cctrsDescription = ""; String cctrsDescription = "";
for(int cctrCnt = 0;cctrCnt < costCtrtListLength; cctrCnt++) for(int cctrCnt = 0;cctrCnt < costCtrtListLength; cctrCnt++)
{ {
domIDDet++;
cctrDataMap = (HashMap)cctrDataList.get(cctrCnt); cctrDataMap = (HashMap)cctrDataList.get(cctrCnt);
ccctrCode = (String)cctrDataMap.get("cctr_code"); ccctrCode = (String)cctrDataMap.get("cctr_code");
cctrsDescription = (String)cctrDataMap.get("cctr_descr"); cctrsDescription = (String)cctrDataMap.get("cctr_descr");
valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n"); valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\"/>\r\n"); //valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\"/>\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlString.append("<selectbox>true</selectbox>\r\n"); valueXmlString.append("<selectbox>true</selectbox>\r\n");
valueXmlString.append("<tran_id><![CDATA[" ).append(checkNull("")).append( "]]></tran_id>\r\n" ); valueXmlString.append("<tran_id><![CDATA[" ).append(checkNull("")).append( "]]></tran_id>\r\n" );
valueXmlString.append("<line_no><![CDATA[" ).append(domIDDet).append( "]]></line_no>\r\n" ); valueXmlString.append("<line_no><![CDATA[" ).append(domIDDet).append( "]]></line_no>\r\n" );
...@@ -1067,35 +1364,46 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1067,35 +1364,46 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
percentage = Double.parseDouble((String)cctrDataMap.get("alloc_perc")); percentage = Double.parseDouble((String)cctrDataMap.get("alloc_perc"));
System.out.println("Allocation Percentage ::::"+percentage); System.out.println("Allocation Percentage ::::"+percentage);
System.out.println("Current Allocation % ["+percentage+"totUnit["+totUnit+"]["+(totUnit*percentage)/100+"]"); System.out.println("Current Allocation % ["+percentage+"totUnit["+totUnit+"]["+(totUnit*percentage)/100+"]");
allocUnit = Math.round(((totUnit*percentage)/100)); //Round function should be taken from finparm allocUnit = Math.round(((totUnit*percentage)/100)); //Round function should be taken from finCommon
valueXmlString.append("<allocation><![CDATA[" ).append(percentage + "%").append( "]]></allocation>\r\n" ); System.out.println("allocUnit:::"+allocUnit);
//allocUnit = finCommon.getRequiredDecimal(allocUnit,2);
System.out.println("allocUnit:::123"+allocUnit);
//valueXmlString.append("<allocation><![CDATA[" ).append(percentage + "%").append( "]]></allocation>\r\n" );
valueXmlString.append("<allocation><![CDATA[" ).append(percentage).append( "]]></allocation>\r\n" );
} }
else if("2".equalsIgnoreCase(allocBas)) else if("2".equalsIgnoreCase(allocBas))
{ {
//development pending //development pending
valueXmlString.append("<allocation><![CDATA[" ).append(percentage ).append( "]]></allocation>\r\n" ); System.out.println("cctrDataMap :::::::["+cctrDataMap+"]");
System.out.println("cctrDataMap.get(alloc_perc) ::"+cctrDataMap.get("alloc_perc"));
allocPerc = Double.parseDouble((String)cctrDataMap.get("alloc_perc"));
allocUnit = Math.round(((totUnit*allocPerc)/100));
System.out.println("allocUnit:::"+allocUnit);
//percentage = Double.parseDouble((String)cctrDataMap.get("alloc_perc"));
valueXmlString.append("<allocation><![CDATA[" ).append(allocPerc ).append( "]]></allocation>\r\n" );
} }
domIDDet++;
valueXmlString.append("<site_code><![CDATA[" ).append(checkNull(siteCode)).append( "]]></site_code>\r\n" ); valueXmlString.append("<site_code><![CDATA[" ).append(checkNull(siteCode)).append( "]]></site_code>\r\n" );
valueXmlString.append("<acct_code><![CDATA[" ).append(checkNull(acctCodeFor)).append( "]]></acct_code>\r\n" ); valueXmlString.append("<acct_code><![CDATA[" ).append(checkNull(acctCodeFor)).append( "]]></acct_code>\r\n" );
valueXmlString.append("<cctr_code_alloc><![CDATA[" ).append(checkNull(ccctrCode)).append( "]]></cctr_code_alloc>\r\n" ); valueXmlString.append("<cctr_code_alloc><![CDATA[" ).append(checkNull(ccctrCode)).append( "]]></cctr_code_alloc>\r\n" );
valueXmlString.append("<cctr_descr><![CDATA[" ).append(checkNull(cctrsDescription)).append( "]]></cctr_descr>\r\n" ); valueXmlString.append("<cctr_descr><![CDATA[" ).append(checkNull(cctrsDescription)).append( "]]></cctr_descr>\r\n" );
valueXmlString.append("<unit_alloc><![CDATA[" ).append(allocUnit).append( "]]></unit_alloc>\r\n" ); valueXmlString.append("<unit_alloc><![CDATA[" ).append(deciFormater.format(allocUnit)).append( "]]></unit_alloc>\r\n" );
valueXmlString.append("<tot_units><![CDATA[" ).append(deciFormater.format(totUnit)).append( "]]></tot_units>\r\n" );
valueXmlString.append("</Detail3>\r\n"); valueXmlString.append("</Detail3>\r\n");
} }//end of for loop
} }//end of if block if costCtrtListLength > 0
}//end of try block
} catch (Exception e) { catch (Exception e)
{
e.printStackTrace();
// TODO: handle exception // TODO: handle exception
System.out.println(e);
e.printStackTrace();
throw new ITMException(e);
} }
System.out.println("getCostCenetrAllocationDetail :::::"+valueXmlString.toString()); System.out.println("getCostCenetrAllocationDetail :::::"+valueXmlString.toString());
return valueXmlString.toString(); return valueXmlString.toString();
}//end of method getCostCenetrAllocationDetail
}
private String errorType(Connection conn, String errorCode) throws ITMException private String errorType(Connection conn, String errorCode) throws ITMException
{ {
...@@ -1125,6 +1433,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1125,6 +1433,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
catch (Exception ex) catch (Exception ex)
{ {
System.out.println("Exception inside errorType method"+ex);
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} }
...@@ -1150,7 +1459,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1150,7 +1459,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
} }
return msgType; return msgType;
} }//end of method errorType
@Override @Override
public String handleRequest(HashMap<String, String> reqParamMap) public String handleRequest(HashMap<String, String> reqParamMap)
...@@ -1261,7 +1570,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1261,7 +1570,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
return retXMLStr; return retXMLStr;
} }//END OF METHOD handleRequest
public InitialContext getInitialContext()throws ITMException public InitialContext getInitialContext()throws ITMException
{ {
...@@ -1282,7 +1591,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1282,7 +1591,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
throw new ITMException(e); throw new ITMException(e);
} }
return ctx; return ctx;
} }//end of method getInitialContext
public boolean preDomExists(Document dom, String currentFormNo) throws ITMException public boolean preDomExists(Document dom, String currentFormNo) throws ITMException
{ {
...@@ -1308,22 +1617,19 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1308,22 +1617,19 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
} }
} }
} }
catch ( Exception e ) catch ( Exception e )
{ {
System.out.println( "Exception preDomExists :==>\n"+e.getMessage()); System.out.println( "Exception preDomExists :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("preDomExists =["+selected+"] and currentFormNo =["+currentFormNo+"]"); System.out.println("preDomExists =["+selected+"] and currentFormNo =["+currentFormNo+"]");
return selected; return selected;
} }//end of method preDomExists
public String getPrevFormVal( Document dom, String currentFormNo, ArrayList temp, String colName ) throws ITMException public String getPrevFormVal( Document dom, String currentFormNo, ArrayList temp, String colName ) throws ITMException
{ {
NodeList parentList = null; NodeList parentList = null;
NodeList childList = null; NodeList childList = null;
Node parentNode = null; Node parentNode = null;
...@@ -1371,8 +1677,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1371,8 +1677,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
} }
} }
}//END OF FOR LOOP
}
if(currentFormNo.equals("1")) if(currentFormNo.equals("1"))
{ {
domID = 1; domID = 1;
...@@ -1383,13 +1688,94 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1383,13 +1688,94 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
returnPrevStr = returnPrevStr.substring(returnPrevStr.indexOf(">") + 1, returnPrevStr.lastIndexOf("</")); returnPrevStr = returnPrevStr.substring(returnPrevStr.indexOf(">") + 1, returnPrevStr.lastIndexOf("</"));
} }
returnPrevStr = returnPrevStr.indexOf("Detail"+currentFormNo) != -1 ? returnPrevStr : ""; returnPrevStr = returnPrevStr.indexOf("Detail"+currentFormNo) != -1 ? returnPrevStr : "";
} }//end of try block
catch ( Exception e ) catch ( Exception e )
{ {
System.out.println( "Exception : :getPrevFormValues :==>\n"+e.getMessage()); System.out.println( "Exception : :getPrevFormValues :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return returnPrevStr; return returnPrevStr;
}//end of method getPrevFormVal
}
} public double getNumOftotalallocPercentage(Document dom2,String CurrentLineNo) throws ITMException
{
String perAmt="",lineNo="";
double num=0;
System.out.println("Inside getXmlDocument method!!!!!!!!!!!!!!");
try
{
NodeList detailNoteList = dom2.getElementsByTagName("Detail3");
System.out.println("Value of dom2 is :::::["+dom2+"]");
System.out.println("Length of detailNoteList" +detailNoteList.getLength());
for(int cnt = 0;cnt<detailNoteList.getLength();cnt++)
{
Element pNode=(Element) detailNoteList.item(cnt);
perAmt= pNode.getElementsByTagName("allocation").item(0).getFirstChild().getNodeValue();
lineNo= pNode.getElementsByTagName("line_no").item(0).getFirstChild().getNodeValue();
if(!lineNo.equalsIgnoreCase(CurrentLineNo.trim()))
{
System.out.println("Line No is.. "+CurrentLineNo);
num += Double.parseDouble(perAmt);
System.out.println("perAmt is ==="+perAmt);
}
}
System.out.println("num is ==="+num);
}
catch(Exception e)
{
System.out.println("Exception : : getNumOftotalallocPercentage :"+e);
e.printStackTrace();
throw new ITMException(e);
}
return num;
}//end of method getNumOftotalallocPercentage
public double setUnitAllocationValue(double totUnit,double allocation_perc )
{
double unitAlloc=0;
System.out.println("totUnit :: ["+totUnit+"]" + "allocation_perc :: ["+allocation_perc+"]");
unitAlloc = Math.round(((totUnit*allocation_perc)/100));
System.out.println("Value of unitAlloc:::"+unitAlloc);
return unitAlloc;
}//end of method setUnitAllocationValue
public String getResourceBasVal(Connection conn) throws ITMException
{
System.out.println("Inside getResourceBasVal Method!!!");
String resBas="",sql="";
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = "select res_basis from costalloc_bas where alloc_basis=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"2");
rs = pstmt.executeQuery();
while(rs.next())
{
resBas = rs.getString("res_basis");
System.out.println("Value of Resource Basis is ====="+resBas);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception : : getResourceBasVal :"+e);
throw new ITMException(e);
}
return resBas;
}//end of method getResourceBasVal
}//end of class CostCtrAllocIC
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