Commit 01dc27d4 authored by tmahadi's avatar tmahadi

src updated by Sagar N for pricelist validation in head 300117


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104503 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e615d735
......@@ -94,12 +94,12 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
int ctr = 0;
int n = 0;
int currentFormNo = 0;
String priceList = null;
String priceList = "";
String listType="";
String itemCode = null;
String unit = null;
String slabno = null;
String col_name;
String itemCode = "";
String unit = "";
String slabno = "";
String col_name = "";
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("userId ::-"+userId);
......@@ -172,7 +172,8 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
valueXmlString.append("<list_type protect='1\'>").append(listType).append("</list_type>");
*/
}
else
// Commented By Sagar On 27-JAN-2017 Start
/* else
if (currentColumn.trim().equals("itm_default") )
{
long mslab_no=0;
......@@ -262,7 +263,7 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
// valueXmlString.append("<unit>").append(munit).append("</unit>");
// valueXmlString.append("<list_type>").append(mlist_type).append("</list_type>");
}
} */ //Commented By Sagar On 27-JAN-2017 End
else
if(currentColumn.trim().equals("price_list"))
{
......@@ -405,6 +406,14 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
}
return valueXmlString.toString();
}//itemChanged()
// Added By Sagar On 25-JAN-2017 Start
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
// Added By Sagar On 25-JAN-2017 End
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
......@@ -457,10 +466,17 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
// Added By Sagar on [25-JAN-2017] [Start]
int mmaxqty=0 , mminqty = 0,cnt=0;
double mrate = 0.0;
String mmaxqtyStr = "" , mminqtyStr = "" , strvalid_upto="" , strmeff_from = "" , valid_uptoDate = "" ,
eff_fromDate = "" , mitem_code ="" , mactive ="" , mrateStr= "" , mValue ="", ls_plist_parent = "" , Is_price_list = "" ;
//ConnDriver connDriver = new ConnDriver();
// Added By Sagar on [25-JAN-2017] [End]
try
{
conn = getConnection();
//conn = connDriver.getConnectDB("DriverITM");
stmt = conn.createStatement();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("userId = "+userId);
......@@ -493,7 +509,12 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("slab_no"))
{
}
if(childNodeName.equals("tax_base"))
{
}
// ADDED BY RITESH ON 23/SEP/13 START
if(childNodeName.equals("price_list"))
{
......@@ -510,10 +531,11 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
validUptoStr = genericUtility.getColumnValue("valid_upto",dom);
lotNoFrom = genericUtility.getColumnValue("lot_no__from",dom);
lotNoTo = genericUtility.getColumnValue("lot_no__to",dom);
slabno = genericUtility.getColumnValue("slab_no",dom) ;
minQty = genericUtility.getColumnValue("min_qty",dom);
maxQty = genericUtility.getColumnValue("max_qty", dom);
// Modified By Sagar to check null for dom value on [25-JAN-2017] [Start]
slabno = checkNull(genericUtility.getColumnValue("slab_no",dom));
minQty = checkNull(genericUtility.getColumnValue("min_qty",dom));
maxQty = checkNull(genericUtility.getColumnValue("max_qty", dom));
// Modified By Sagar to to check null for dom value on [25-JAN-2017] [End]
// end 14/11/13 manoharan duplicate checking to consider all parameter
System.out.println("price_list wfvalData :::: " + priceList);
// 14/11/13 manoharan commented as always it will be manual
......@@ -528,21 +550,79 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
//rs.close();rs = null;
//pstmt.close();pstmt = null;
// if("M".equals(lskeyflag) && (priceList == null || priceList.trim().length() == 0))
if(priceList == null || priceList.trim().length() == 0 || itemCode == null || itemCode.trim().length() == 0 || unit == null || unit.trim().length() == 0 || listType == null || listType.trim().length() == 0 || effFromStr == null || effFromStr.trim().length() == 0 || validUptoStr == null || validUptoStr.trim().length() == 0 || lotNoFrom == null || lotNoFrom.trim().length() == 0 || lotNoTo == null || lotNoTo.trim().length() == 0)
// Modified By Sagar to check null for dom value on [25-JAN-2017] [Start]
//if(priceList == null || priceList.trim().length() == 0 || itemCode == null || itemCode.trim().length() == 0 || unit == null || unit.trim().length() == 0 || listType == null || listType.trim().length() == 0 || effFromStr == null || effFromStr.trim().length() == 0 || validUptoStr == null || validUptoStr.trim().length() == 0 || lotNoFrom == null || lotNoFrom.trim().length() == 0 || lotNoTo == null || lotNoTo.trim().length() == 0)
if(priceList == null || priceList.trim().length() == 0 )
{
errCode = "VTLPRCNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(itemCode == null || itemCode.trim().length() == 0)
{
errCode = "VMCODNULL";
errCode = "VTITMNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(unit == null || unit.trim().length() == 0 )
{
errCode = "VTINVUNIT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(listType == null || listType.trim().length() == 0 )
{
errCode = "VTLSTNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(effFromStr == null || effFromStr.trim().length() == 0 )
{
errCode = "VTEFFNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(validUptoStr == null || validUptoStr.trim().length() == 0 )
{
errCode = "VTVLDNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(lotNoFrom == null || lotNoFrom.trim().length() == 0 )
{
errCode = "VTLTFRNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(lotNoTo == null || lotNoTo.trim().length() == 0 )
{
errCode = "VTLTTONUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else // if ("A".equals(editFlag))
{
System.out.println("before effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
/*effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");*/
if(effFromStr.trim().length() > 0 )
{
effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
}
if(validUptoStr.trim().length() > 0 )
{
validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");
}
// Modified By Sagar to check null for dom value on [25-JAN-2017] [End]
System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
System.out.println("Quantity From [" + minQty + "] Quantity To [" + maxQty + "]");
sql = "select count(*) from pricelist where price_list = ? "
+ " and item_code = ? and unit = ? and list_type = ? "
+ " and eff_from = ? and valid_upto = ? "
......@@ -570,8 +650,15 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
{
cnt1 = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(rs != null){
rs.close();
rs = null;
}
if(pstmt != null){
pstmt.close();
pstmt = null;
}
if(cnt1 > 0)
{
errCode = "VMDUPL1";
......@@ -581,7 +668,8 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
}
} // ADDED BY RITESH ON 23/SEP/13 END
else if(childNodeName.equals("item_code"))
// Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*else if(childNodeName.equals("item_code"))
{
System.out.println("childNodeName 1. : " + childNodeName);
String mitem_code = genericUtility.getColumnValue("item_code",dom);
......@@ -618,8 +706,61 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
errFields.add(childNodeName.toLowerCase());
}
}*/
if("item_code".equalsIgnoreCase(childNodeName))
{
System.out.println("childNodeName 1. : " + childNodeName);
mitem_code = checkNull(genericUtility.getColumnValue("item_code",dom));
if(mitem_code == null || mitem_code.length() == 0)
{
errCode = "VTITMNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if (childNodeName.equals("price_list__parent"))
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mitem_code [ " + mitem_code + "]");
sql="select count(*) as count from item where item_code = '"+mitem_code+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
//int cnt=0;
if(rs.next())
{
cnt=rs.getInt("count");
}
if(rs != null){
rs.close();
rs = null;
}
if(cnt==0)
{
errCode = "VMITEM_CD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql="select active from item where item_code='"+mitem_code+"'";
rs=stmt.executeQuery(sql);
if(rs.next())
{
mactive=checkNull(rs.getString("active"));
}
if(rs != null){
rs.close();
rs = null;
}
if("N".equalsIgnoreCase(mactive))
{
errCode="VTITEM4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
// Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*else if (childNodeName.equals("price_list__parent"))
{
String ls_plist_parent,Is_price_list;
System.out.println("childNodeName 1. : " + childNodeName);
......@@ -632,13 +773,31 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
{
if(ls_plist_parent.trim().equals(Is_price_list.trim()) )
errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId);
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}*/
if ("price_list__parent".equalsIgnoreCase(childNodeName))
{
System.out.println("childNodeName 1. : " + childNodeName);
ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom);
Is_price_list = genericUtility.getColumnValue("price_list",dom);
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] ls_plist_parent [ " + ls_plist_parent + "] Is_price_list [" + Is_price_list + "]");
if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/
{
if(ls_plist_parent.equalsIgnoreCase((Is_price_list)))
errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId);
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equals("min_qty"))
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
// Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*else if (childNodeName.equals("min_qty"))
{
int mmaxqty,mminqty;
mminqty =Integer.parseInt(genericUtility.getColumnValue("min_qty",dom));
......@@ -652,18 +811,84 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}*/
if ("min_qty".equalsIgnoreCase(childNodeName))
{
mminqtyStr = checkNull(genericUtility.getColumnValue("min_qty",dom));
mmaxqtyStr = checkNull(genericUtility.getColumnValue("max_qty",dom));
if(mminqtyStr == null || mminqtyStr.length() == 0)
{
errCode = "VTMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(mmaxqtyStr.length() > 0)
{
mmaxqty=Integer.parseInt(mmaxqtyStr);
}
else
{
mmaxqty = 0;
}
if(mminqtyStr.length() > 0)
{
mminqty =Integer.parseInt(mminqtyStr);
}
else if(childNodeName.equals("valid_upto"))
else
{
mminqty = 0;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
if (mmaxqty < mminqty )
{
errCode = "VMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("max_qty".equalsIgnoreCase(childNodeName))
{
mmaxqtyStr = checkNull(genericUtility.getColumnValue("max_qty",dom));
mminqtyStr = checkNull(genericUtility.getColumnValue("min_qty",dom));
if(mmaxqtyStr == null || mmaxqtyStr.length() == 0)
{
errCode = "VTMMAXQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(mmaxqtyStr.length() > 0)
{
mmaxqty=Integer.parseInt(mmaxqtyStr);
}
else
{
mmaxqty = 0;
}
if(mminqtyStr.length() > 0)
{
mminqty =Integer.parseInt(mminqtyStr);
}
else
{
mminqty = 0;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
if (mmaxqty < mminqty )
{
errCode = "VMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
//Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*else if(childNodeName.equals("valid_upto"))
{
Timestamp mvalid_upto,meff_from;
String strvalid_upto,strmeff_from;
strvalid_upto=genericUtility.getColumnValue("valid_upto",dom) ;
strmeff_from=genericUtility.getColumnValue("eff_from",dom);
String valid_uptoDate=getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
String eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
......@@ -678,18 +903,96 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
errFields.add(childNodeName.toLowerCase());
}
}
*/
if("valid_upto".equalsIgnoreCase(childNodeName))
{
strvalid_upto = checkNull(genericUtility.getColumnValue("valid_upto",dom)) ;
strmeff_from = checkNull(genericUtility.getColumnValue("eff_from",dom));
if(strvalid_upto.length() > 0 )
{
valid_uptoDate = getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
//mvalid_upto = Timestamp.valueOf(valid_uptoDate+" 00:00:00");
}else{
errCode="VTVLDNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(strmeff_from.length() > 0 )
{
eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
//meff_from = Timestamp.valueOf(eff_fromDate+" 00:00:00");
}
else
{
errCode="VTEFFNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
if(valid_uptoDate.compareTo(eff_fromDate) <= 0)
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("eff_from".equalsIgnoreCase(childNodeName))
{
strvalid_upto = checkNull(genericUtility.getColumnValue("valid_upto",dom)) ;
strmeff_from = checkNull(genericUtility.getColumnValue("eff_from",dom));
else if(childNodeName.equals("tax_code"))
if(strvalid_upto.length() > 0 )
{
valid_uptoDate = getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
}
else
{
errCode="VTVLDNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(strmeff_from.length() > 0 )
{
eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
}
else
{
errCode="VTEFFNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
if(valid_uptoDate.compareTo(eff_fromDate) <= 0)
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
//else if(childNodeName.equals("tax_code"))
// Modified By Sagar to check null for dom value[25-JAN-17] [Start]
//SIR
if("tax_code".equalsIgnoreCase(childNodeName))
{
String mValue=genericUtility.getColumnValue("tax_code",dom);
//String mValue=genericUtility.getColumnValue("tax_code",dom);
mValue=checkNull(genericUtility.getColumnValue("tax_code",dom));
// Modified By Sagar to check null for dom value[25-JAN-17] [End]
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mValue [ " + mValue + "]");
sql="Select Count(*) as count from tax where tax_code = '"+mValue+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
if(rs.next())
{
int cnt=rs.getInt("count");
cnt=rs.getInt("count");
}
if(rs != null){
rs.close();
rs = null;
}
if(cnt==0)
{
errCode = "VTTAX1";
......@@ -697,11 +1000,8 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
}
else if(childNodeName.equals("rate") || childNodeName.equals("min_rate") || childNodeName.equals("max_rate") ) // 20/10/14 manoharan min_rate and max_rate included
// //Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*else if(childNodeName.equals("rate") || childNodeName.equals("min_rate") || childNodeName.equals("max_rate") ) // 20/10/14 manoharan min_rate and max_rate included
{
double mrate; // 20/10/14 manoharan changes from integer to double
mrate= Double.parseDouble(genericUtility.getColumnValue(childNodeName,dom) );
......@@ -712,24 +1012,85 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}*/
if("rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTRATE2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("min_rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTMINRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("max_rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTMAXVRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
}
}
break;
}//switch
//}//for
int errListSize = errList.size();
int cnt = 0;
int cntErr = 0;
String errFldName = null, errorType = null;
System.out.println("errListSize ..........[" + errListSize + "]");
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
for(cntErr = 0; cntErr < errListSize; cntErr ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
errCode = errList.get(cntErr);
errFldName = errFields.get(cntErr);
System.out.println("errCode ..........[" + errCode + "]");
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode);
......@@ -876,14 +1237,4 @@ public String getValidDateTimeString(String dateTimeStr, String sourceDateTimeFo
}
return msgType;
}
}//class
\ 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