Commit 59a6f716 authored by nkhan's avatar nkhan

Added by Nasruddin khan


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@102601 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0cf306c5
......@@ -155,7 +155,6 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
break ;
}
}
}
if(childNodeName.equalsIgnoreCase("descr") && ("A".equalsIgnoreCase(editFlag)) )
......@@ -405,6 +404,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
break ;
}
}
else
{
......@@ -485,7 +485,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
break ;
}
} // end comm_table
if(childNodeName.equalsIgnoreCase("line_no")) // start line_no
{
System.out.println("validation line no executed");
......@@ -496,7 +496,31 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
break ;
}
} //end line_no
else if(childNodeName.equalsIgnoreCase("comm_type")) // start comm_type
{
System.out.println("validation comm_type executed");
commType = genericUtility.getColumnValue("comm_type",dom);
if(commType == null || commType.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMCOMTYPNU",userId);
break ;
}
} // end comm_type
else if(childNodeName.equalsIgnoreCase("comm_perc")) // start comm_perc
{
System.out.println("validation comm perc executed");
commPercentage = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("comm_perc",dom)));
if("P".equalsIgnoreCase(commType)){
if( commPercentage <= 0 || commPercentage > 100 ){
System.out.println("commission persentace should be greter then zero and less then hundread");
errString = itmDBAccessEJB.getErrorString("","VTCOMAMTPR",userId);
break ;
}
}
}// end comm_perc
else if(childNodeName.equalsIgnoreCase("eff_date")) //start eff_date
{
effDateStr =genericUtility.getColumnValue("eff_date",dom);
......@@ -529,7 +553,8 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = getErrorString("","INVEFDATE ",userId);
System.out.println("errString befor break" +errString);
break;
}
}
}
} //end eff_date
......@@ -539,7 +564,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
effDateStr =genericUtility.getColumnValue("eff_date",dom);
validUptoStr =genericUtility.getColumnValue("valid_upto",dom);
lineNo = genericUtility.getColumnValue("line_no",dom);
if((effDateStr != null) && (validUptoStr != null))
{
effDate= Timestamp.valueOf(genericUtility.getValidDateString(effDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
......@@ -560,59 +585,43 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = itmDBAccessEJB.getErrorString("","VMVALDTNUL",userId);
break ;
}
if(isDulplicateDate(dom2,effDateStr,validUptoStr)){
System.out.println("inside return valuee !!!!!!!!!============");
System.out.println("VMEFVUTDAT");
errString = itmDBAccessEJB.getErrorString("","VMEFVUTDAT",userId);
break ;
}
} // end valid_upto
else if(childNodeName.equalsIgnoreCase("comm_type")) // start comm_type
{
System.out.println("validation comm_type executed");
commType = genericUtility.getColumnValue("comm_type",dom);
if(commType == null || commType.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMCOMTYPNU",userId);
else if(childNodeName.equalsIgnoreCase("min_amt")){ // start if min_amt
minAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("min_amt",dom)));
maxAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("max_amt",dom)));
System.out.println("Minimum amount ["+ minAmount + "]Minimum amount ["+ minAmount + "]" );
if( minAmount <= 0 ){
errString = itmDBAccessEJB.getErrorString("","VTMINAMT",userId);
break ;
}
} // end comm_type
else if(childNodeName.equalsIgnoreCase("comm_perc")) // start comm_perc
{
System.out.println("validation comm perc executed");
commPercentage = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("comm_perc",dom)));
if( commPercentage <= 0 || commPercentage > 100 ){
System.out.println("commission persentace should be greter then zero and less then hundread");
errString = itmDBAccessEJB.getErrorString("","VTCOMAMTPR",userId);
}
if(minAmount >= maxAmount){
errString = itmDBAccessEJB.getErrorString("","VTMINAAMT",userId);
break ;
}
}// end comm_perc
}
} // end min_amt
else if(childNodeName.equalsIgnoreCase("max_amt")){ // start if max_amt
minAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("min_amt",dom)));
maxAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("max_amt",dom)));
if( maxAmount <= 0 ){
if(minAmount >= maxAmount )
{
System.out.println("Max Amount should be greater then Zero");
errString = itmDBAccessEJB.getErrorString("VTMXMNTPR","",userId);
break ;
}
if( maxAmount <= 0 ){
System.out.println("Max Amount should be greater then Zero");
errString = itmDBAccessEJB.getErrorString("","VTMXAMTPR",userId);
break ;
}
else if(minAmount >= maxAmount ){
errString = itmDBAccessEJB.getErrorString("","VTMXAMTPR",userId);
break ;
}
} // end if max_amt
else if(childNodeName.equalsIgnoreCase("min_amt")){ // start if min_amt
minAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("min_amt",dom)));
maxAmount = Double.parseDouble(checkNllOrBlank(genericUtility.getColumnValue("max_amt",dom)));
System.out.println("Minimum amount ["+ minAmount + "]Minimum amount ["+ minAmount + "]" );
if( minAmount <= 0 || minAmount >= maxAmount ){
errString = itmDBAccessEJB.getErrorString("","VTMINAMT",userId);
break ;
}
} // end min_amt
commCriteria = genericUtility.getColumnValue("comm_criteria", dom1);
System.out.println("commCriteria ::: ["+commCriteria);
if(commCriteria != null && commCriteria.trim().length()>0){
......@@ -639,6 +648,14 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = itmDBAccessEJB.getErrorString("","VMVALDTWR",userId);
return errString;
}
// changed by Nasruddin khan [22/JUL/16 D16DFOR001] start
boolean result = isDulplicateDate(dom,dom2,effDateStr,validUptoStr,lineNo);
if( result == true){
errString = itmDBAccessEJB.getErrorString("","VMEFVUTDAT",userId);
return errString;
}
// changed by Nasruddin khan [22/JUL/16 D16DFOR001] end
}//END TRY
catch(Exception e)
{
......@@ -672,121 +689,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
return errString;
}//END OF VALIDATION
// changed by Nasruddin khan [19/JUL/16 D16DFOR001] START
private boolean isDulplicateDate(Document dom2, String effDateStr2, String validUptoStr2) {
System.out.println(" inside duplicate ======");
System.out.println("dom2 ["+dom2+"]");
System.out.println("effDateStr2 ["+effDateStr2+"]");
System.out.println("validUptoStr2 ["+validUptoStr2+"]");
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String effDateStr = "", validUptoStr = "";
boolean isDulplicate = false;
Timestamp effDate = null;
Timestamp effDate2 = null;
Timestamp validUpto = null;
Timestamp validUpto2 = null;
String updateFlag = "";
try
{
effDate2 = Timestamp.valueOf(genericUtility.getValidDateString(effDateStr2, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
validUpto2 = Timestamp.valueOf(genericUtility.getValidDateString(validUptoStr2, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("After Date Conversion ::::");
System.out.println("Before Detail 3");
parentList = dom2.getElementsByTagName("Detail3");
System.out.println("After Detail 3");
int parentNodeListLength = parentList.getLength();
System.out.println("Before First Loop1 ");
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- )
{
System.out.println("After First Loop ");
parentNode = parentList.item(prntCtr-1);
childList = parentNode.getChildNodes();
System.out.println("childList "+childList.getLength());
for (int ctr = 0; ctr < childList.getLength(); ctr++)
{
System.out.println("After Second Loop ");
childNode = childList.item(ctr);
System.out.println("before :::::: child node");
System.out.println("childNode>>>>"+childNode);
System.out.println("After Child node");
if ( childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute") )
{
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("Update Flag ::"+updateFlag);
}
if ( childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("eff_date") )
{
effDateStr = childNode.getFirstChild().getNodeValue().trim();
effDate =Timestamp.valueOf(genericUtility.getValidDateString(effDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println(" effDateStr :::::::"+ effDateStr);
}
if ( childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("valid_upto") )
{
validUptoStr = childNode.getFirstChild().getNodeValue().trim();
validUpto =Timestamp.valueOf(genericUtility.getValidDateString(validUptoStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println(" effDateStr :::::::"+ validUpto);
}
}
if(!updateFlag.equalsIgnoreCase("D"))
{
if (!effDate2.before(effDate) && !( effDate2.equals(effDate) ))
{
if(effDate2.after(validUpto)){
isDulplicate = false;
}
else{
isDulplicate = true;
break;
}
}
if (!validUpto2.after(validUpto) && !(validUpto2.equals(validUpto)))
{
if(validUpto2.before(effDate)){
isDulplicate = false;
}
else{
isDulplicate = true;
break;
}
}
}
}
}catch(Exception e){
System.out.println("CommissiondetIC.isDulplicateDate() ["+ e);
e.printStackTrace();
}
System.out.println("CommissiondetIC.isDulplicateDate() isDulplicate ::"+isDulplicate);
return isDulplicate;
}
private String checkNllOrBlank(String input) {
if(input == null || input.trim().equals(""))
{
return "0";
}
else
{
return input ;
}
}
//changed by Nasruddin khan [19/JUL/16 D16DFOR001] END
public String itemChanged(String xmlString, String xmlString1, String xmlString2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
......@@ -964,10 +867,8 @@ private String checkNllOrBlank(String input) {
{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
}
}
valueXmlString.append("</Detail2>");
break;
// case 2 end
......@@ -1161,6 +1062,121 @@ private String checkNllOrBlank(String input) {
}
return false;
}
// changed by Nasruddin khan [19/JUL/16 D16DFOR001] START
private boolean isDulplicateDate(Document dom,Document dom2,String peffDateStr,String pvalidUptoStr,String plineNo) throws ITMException, Exception {
System.out.println("Call Check dublicate value ::::::");
String lineNo="",commTable="",effDateStr="",validUptoStr="";
String effDateTemp=null ;
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null,peffDate=null,pvalidUpto=null;
String errString = "",editFlag="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//String userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
int ctr1=0,k=0,l=1,noOfParent=0;
String dateStr=null,itemCodeTemp="",itemSerTemp="",validUptoTemp="",itemSerTempLast="",itemCodeTempLast="";
java.sql.Timestamp validUptoTemp2=null;
NodeList detail3List = dom2.getElementsByTagName("Detail3");
//NodeList detail1List = dom2.getElementsByTagName("Detail1");
ArrayList arrLstDate=new ArrayList();
if(detail3List != null && detail3List.getLength() > 0)
{
noOfParent = detail3List.getLength();
System.out.println("@@@@@@@@ noOfParent [["+noOfParent +"]]");
System.out.println("@@@@ ::lineNo:["+lineNo+"]");
if( peffDateStr != null && pvalidUptoStr !=null && peffDateStr.trim().length() > 0 && pvalidUptoStr.trim().length() > 0 )
{
peffDate = Timestamp.valueOf(genericUtility.getValidDateString(peffDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
pvalidUpto = Timestamp.valueOf(genericUtility.getValidDateString(pvalidUptoStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("@@@@@parent date@@@peffDate["+peffDate+"] ::pvalidUpto["+pvalidUpto+"]");
for ( ctr1 = 0; ctr1 < noOfParent; ctr1++ ) //Loop for each node of current detail
{
effDateStr = genericUtility.getColumnValueFromNode( "eff_date", detail3List.item(ctr1) );
validUptoStr = genericUtility.getColumnValueFromNode( "valid_upto", detail3List.item(ctr1) );
editFlag = genericUtility.getColumnValueFromNode( "edit_flag", detail3List.item(ctr1) );
lineNo = genericUtility.getColumnValueFromNode( "line_no", detail3List.item(ctr1) );
dateStr = validUptoStr+"@"+effDateStr ;
System.out.println("dateStr[[[[[[[["+dateStr+"]]]]]]]]]");
if(!( plineNo.trim().equalsIgnoreCase(lineNo.trim() ) ))
{
arrLstDate.add(dateStr);
System.out.println("@@@@ added in arraylist");
}
}
Collections.sort(arrLstDate);
System.out.println("@@@@@arrLstDate.size()["+arrLstDate.size()+"]]]:: Sorted::::"+arrLstDate);
for( k=0;k< arrLstDate.size();k++)
{
String temp = (String) arrLstDate.get(k);
StringTokenizer st = new StringTokenizer(temp,"@");
while(st.hasMoreTokens())
{
if( l== 1)
{
validUptoTemp = st.nextToken();
l++;
}
else if( l== 2)
{
effDateTemp = st.nextToken();
l=1;
}
}
if( effDateTemp != null && validUptoTemp !=null && effDateTemp.trim().length() > 0 && validUptoTemp.trim().length() > 0 && !("D".equalsIgnoreCase(editFlag)))
{
effDateTemp2 = Timestamp.valueOf(genericUtility.getValidDateString(effDateTemp, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
validUptoTemp2 = Timestamp.valueOf(genericUtility.getValidDateString(validUptoTemp, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("@@@@@date@@@effDateTemp2["+effDateTemp2+"] ::validUptoTemp2["+validUptoTemp2+"]");
if( (effDateTemp2 != null ) && (validUptoTemp2 != null ))
{
//if( (effDateTemp2.equals( peffDate )) )
if( (effDateTemp2.equals( peffDate )) && ( validUptoTemp2.equals(pvalidUpto)) )
{
System.out.println("@@@@@@@ error in date");
return true;
}
}
}
}
return false;
}
private String checkNllOrBlank(String input) {
if(input == null || input.trim().equals(""))
{
return "0";
}
else
{
return input ;
}
}
//changed by Nasruddin khan [19/JUL/16 D16DFOR001] END
}
......
......@@ -83,7 +83,6 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
itemSer= rs2.getString("item_ser");
validUptoLast = null;
lineNoLast = null;
//sql = " select line_no,eff_date,valid_upto FROM comm_det where comm_table = ? and item_code=? and item_ser= ? order by eff_date asc " ;
sql="select line_no,eff_date,valid_upto FROM" +
" (select line_no,eff_date,valid_upto from comm_det where comm_table =? and item_code=?" +
" UNION ALL " +
......@@ -198,6 +197,112 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
pstmt2.close();
pstmt2 = null;
}
System.out.println("Called Inside Commistion Post det ===>>>>>>>>>>>");
NodeList detail4List = dom.getElementsByTagName("Detail3");
// changed by Nasruddin khan [19/JUL/16 D16DFOR001] START
if(detail4List != null && detail4List.getLength() > 0)
{
commTable = genericUtility.getColumnValueFromNode("comm_table", dom.getElementsByTagName("Detail3").item(0));
noOfParent = detail3List.getLength();
sql = " select line_no,eff_date,valid_upto FROM COMM_BY_VALUE where comm_table = ? order by eff_date asc " ;
System.out.println("sql :::::::::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,commTable);
rs = pstmt.executeQuery();
while(rs.next())
{
lineNo = rs.getString("line_no");
effDate = rs.getTimestamp("eff_date");
validUpto = rs.getTimestamp("valid_upto");
if( validUptoLast != null && ( lineNoLast != null ) )
{
System.out.println("EffDate ::::::::= "+effDate +" valid up last :::::::::::::::= "+validUptoLast+" valid Upto :::::="+validUpto);
System.out.println("TEST 1= "+validUptoLast.before(validUpto));
if(! (validUptoLast.before(validUpto)) && ((int)( (validUpto.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24))) != 0 )
{
conn.rollback();
customError = "Invalid Effective Date and Valid Upto Date for Line No = "+lineNo+" .";
retString = itmDBAccessEJB.getErrorString("","INVLDT01","","",conn);
begPart = retString.substring( 0, retString.indexOf("<trace>") + 7 );
endPart = retString.substring( retString.indexOf("</trace>"));
mainStr = begPart + customError + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
return errString;
}
if( effDate.before(validUptoLast) || ((int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24))) == 0 )
{
Calendar c = Calendar.getInstance();
c.setTime((effDate));
c.add(Calendar.DATE, -1);
validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new : ["+validUptoLast+"]");
if( effDateLast.after(validUptoLast))
{
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
return errString;
}
sql1="UPDATE COMM_BY_VALUE SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast);
pstmt1.setString(2,commTable);
pstmt1.setString(3,lineNoLast);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
if ( cnt > 0 )
{
System.out.println("@@@@@@update sucess:::.["+commTable+"]...["+lineNoLast+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully.");
}
}
if(effDate.after(validUptoLast) )
{
int diffInDays = (int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24) );
System.out.println("Diff Days="+diffInDays);
if(diffInDays > 1)
{
Calendar c = Calendar.getInstance();
c.setTime((validUptoLast));
c.add(Calendar.DATE, (diffInDays - 1));
validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new 2: ["+validUptoLast+"]::::effDateLast["+effDateLast+"]");
if( effDateLast.after(validUptoLast))
{
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
return errString;
}
sql1="UPDATE COMM_BY_VALUE SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast);
pstmt1.setString(2,commTable);
pstmt1.setString(3,lineNoLast);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
if ( cnt > 0 )
{
System.out.println("@@@@@@update sucess2::record update successfully.");
}
}
}
}
validUptoLast = validUpto;
effDateLast = effDate;
lineNoLast = lineNo;
System.out.println("@@@@ validUptoLast"+validUptoLast+"::::lineNoLast"+lineNoLast);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}// changed by Nasruddin khan [19/JUL/16 D16DFOR001] END
}
catch(Exception e)
{
......
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