Commit b5ec7f8e authored by dpawar's avatar dpawar

add validation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93939 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9a41c097
...@@ -169,14 +169,54 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -169,14 +169,54 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
if (childNodeName.equalsIgnoreCase("site_code"))
{
String siteCode="";
int count=0;
siteCode = genericUtility.getColumnValue("site_code",dom);
siteCode=siteCode==null ? "" : siteCode.trim();
if(siteCode.length()== 0){
errCode = "VTSITECNE";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}else{
count=getDBRowCount(conn,"site","site_code",siteCode);
if(count==0){
errCode = "VTSITENEX";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
if (childNodeName.equalsIgnoreCase("cust_code"))
{
String custCode="";
int count=0;
custCode = genericUtility.getColumnValue("cust_code",dom);
custCode=custCode==null ? "" : custCode.trim();
if(custCode.length()== 0){
errCode = "VTCUSTCNE";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}else{
count=getDBRowCount(conn,"customer","cust_code",custCode);
if(count==0){
errCode = "VTCUSTNEX";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
if (childNodeName.equalsIgnoreCase("wf_status")) if (childNodeName.equalsIgnoreCase("wf_status"))
{ {
String wfStatus=""; String wfStatus="";
wfStatus = genericUtility.getColumnValue("wf_status",dom); wfStatus = genericUtility.getColumnValue("wf_status",dom);
wfStatus= wfStatus==null ?"":wfStatus; wfStatus= wfStatus==null ?"":wfStatus.trim();
if (wfStatus.trim().equalsIgnoreCase("R")) if (wfStatus.equalsIgnoreCase("R"))
{ {
errCode = "VTREJNOTA"; errCode = "VTREJNOTA";
errList.add( errCode ); errList.add( errCode );
...@@ -301,16 +341,86 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -301,16 +341,86 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
String rateResale=""; String rateResale="";
double rateResaleD=0.0; double rateResaleD=0.0;
rateResale=genericUtility.getColumnValue("rate__resale", dom); rateResale=genericUtility.getColumnValue("rate__resale", dom);
rateResale=rateResale == null ? "0.0" : rateResale; rateResale=rateResale == null ? "0.0" : rateResale.trim();
rateResaleD=Double.parseDouble(checkSpaceNull(rateResale)); rateResaleD=Double.parseDouble(checkSpaceNull(rateResale));
System.out.println("rateResaleD------->> "+rateResaleD); System.out.println("rateResaleD------->> "+rateResaleD);
if (rateResale == null || rateResale.trim().length() == 0 || rateResaleD <= 0) if (rateResale == null || rateResale.length() == 0 || rateResaleD <= 0)
{ {
errCode = "VTRSALENN"; errCode = "VTRSALENN";
errList.add( errCode ); errList.add( errCode );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
if(childNodeName.equalsIgnoreCase("item_code"))
{
String itemCode="",regulatedPrice="",itemActive="";
itemCode=genericUtility.getColumnValue("item_code", dom);
itemCode=itemCode==null ? "" :itemCode.trim();
System.out.println("itemCode------->> "+itemCode);
if(itemCode.length() > 0){
regulatedPrice=getColumnDescr(conn,"regulated_price","item","item_code",itemCode);
itemActive=getColumnDescr(conn,"active","item","item_code",itemCode);
itemActive=itemActive==null ? "" :itemActive.trim();
regulatedPrice=regulatedPrice==null ? "" :regulatedPrice.trim();
if(regulatedPrice.length() < 0){
errCode = "VTREGPRCN"; //regulated price not define in item master
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
else if(itemActive.length() < 0){
errCode = "VTITMCNAC"; //item code not active in item master
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
if(childNodeName.equalsIgnoreCase("bil_date"))
{
String billDate="",billNo="",sql="",invID="",custCodeBil="",orgDate1="";
Timestamp orgDate=null;
Date d1=null,d2=null;
invID = genericUtility.getColumnValue("invoice_id",dom1);
billDate=genericUtility.getColumnValue("bil_date", dom);
billNo=genericUtility.getColumnValue("bill_no", dom);
invID=invID==null ? "" :invID.trim();
billDate=billDate==null ? "" :billDate.trim();
billNo=billNo==null ? "" :billNo.trim();
sql="select cust_code__bil,tran_date from invoice where invoice_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invID);
rs=pstmt.executeQuery();
if(rs.next())
{
custCodeBil=rs.getString(1);
orgDate=rs.getTimestamp(2);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
if(billDate.length() > 0 && orgDate !=null){
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yy");
orgDate1=sdf.format(orgDate);
d1=sdf.parse(orgDate1);
d2=sdf.parse(billDate);
long diffDate=Math.abs(d2.getTime() - d1.getTime());
long diffDays = diffDate / (24 * 60 * 60 * 1000);
System.out.println("Difference in days--------->>["+diffDays+"]");
if(diffDays > 365)
{
errCode = "VTBLBDNRP"; //Bill no., bill date can not be repeated for this invoice
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
} }
break; break;
...@@ -470,9 +580,16 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -470,9 +580,16 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
String invoiceID ="",siteCode="",custCode="",sql="",siteDescr="",custName="",currencyCode="",prdCode=""; String invoiceID ="",siteCode="",custCode="",sql="",siteDescr="",custName="",currencyCode="",prdCode="";
double amount=0.0,exchRate=0.0; double amount=0.0,exchRate=0.0;
invoiceID = genericUtility.getColumnValue("invoice_id",dom); invoiceID = genericUtility.getColumnValue("invoice_id",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
invoiceID=invoiceID==null ? "" :invoiceID.trim();
siteCode=siteCode==null ? "" :siteCode.trim();
custCode=custCode==null ? "" :custCode.trim();
System.out.println("invoiceID ----- :->> "+invoiceID); System.out.println("invoiceID ----- :->> "+invoiceID);
System.out.println("siteCode ----- :->> "+siteCode);
System.out.println("custCode ----- :->> "+custCode);
if(invoiceID != null && invoiceID.trim().length()>0 ) if(invoiceID.length()>0 )
{ {
sql="select site_code,cust_code,net_amt,curr_code,exch_rate,prd_code from invoice where invoice_id = ?"; sql="select site_code,cust_code,net_amt,curr_code,exch_rate,prd_code from invoice where invoice_id = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
...@@ -480,22 +597,29 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -480,22 +597,29 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
siteCode=rs.getString(1)==null ? "" :rs.getString(1); if(siteCode.length() <= 0){
custCode=rs.getString(2)==null ? "" : rs.getString(2); siteCode=rs.getString(1);
siteCode=siteCode==null ? "" :siteCode.trim();
System.out.println("siteCode ----- rs :->> "+siteCode);
}
if(custCode.length() <= 0){
custCode=rs.getString(2);
custCode=custCode==null ? "" :custCode.trim();
}
amount=rs.getDouble(3); amount=rs.getDouble(3);
currencyCode=rs.getString(4)==null ? "" : rs.getString(4); currencyCode=rs.getString(4);
exchRate=rs.getDouble(5); exchRate=rs.getDouble(5);
prdCode=rs.getString(6)==null ? "" :rs.getString(6); prdCode=rs.getString(6);
} }
rs.close();pstmt.close(); rs.close();pstmt.close();
rs=null;pstmt=null; rs=null;pstmt=null;
if(siteCode.trim().length() > 0) if(siteCode.length() > 0)
{ {
siteDescr=getNameOrDescrForCode(conn, "SITE", "DESCR", "SITE_CODE", siteCode); siteDescr=getNameOrDescrForCode(conn, "SITE", "DESCR", "SITE_CODE", siteCode);
} }
if(custCode.trim().length() > 0) if(custCode.length() > 0)
{ {
custName=getNameOrDescrForCode(conn, "customer", "cust_name", "cust_code", custCode); custName=getNameOrDescrForCode(conn, "customer", "cust_name", "cust_code", custCode);
} }
...@@ -515,17 +639,42 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -515,17 +639,42 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
{ {
System.out.println("------invoice id null-----"); System.out.println("------invoice id null-----");
//valueXmlString.append("<project_descr>").append("").append("</project_descr>"); //valueXmlString.append("<project_descr>").append("").append("</project_descr>");
valueXmlString.append("<site_code>").append("").append("</site_code>"); //valueXmlString.append("<site_code>").append("").append("</site_code>");
valueXmlString.append("<cust_code>").append("").append("</cust_code>"); //valueXmlString.append("<cust_code>").append("").append("</cust_code>");
valueXmlString.append("<amount>").append("").append("</amount>"); valueXmlString.append("<amount>").append("").append("</amount>");
valueXmlString.append("<exch_rate>").append("").append("</exch_rate>"); valueXmlString.append("<exch_rate>").append("").append("</exch_rate>");
valueXmlString.append("<curr_code>").append("").append("</curr_code>"); valueXmlString.append("<curr_code>").append("").append("</curr_code>");
valueXmlString.append("<site_descr>").append("").append("</site_descr>"); //valueXmlString.append("<site_descr>").append("").append("</site_descr>");
valueXmlString.append("<cust_name>").append("").append("</cust_name>"); //valueXmlString.append("<cust_name>").append("").append("</cust_name>");
valueXmlString.append("<prd_code>").append("").append("</prd_code>"); valueXmlString.append("<prd_code>").append("").append("</prd_code>");
} }
} }
else if (currentColumn.trim().equalsIgnoreCase("site_code"))
{
String siteCode="",siteDescr1="";
siteCode = genericUtility.getColumnValue("site_code",dom);
siteCode=siteCode==null ? "" :siteCode.trim();
System.out.println("siteCode ----->>["+siteCode+"]");
if(siteCode.length() > 0){
siteDescr1=getNameOrDescrForCode(conn, "SITE", "DESCR", "SITE_CODE", siteCode);
}
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr1 + "]]>").append("</site_descr>");
}
else if (currentColumn.trim().equalsIgnoreCase("cust_code"))
{
String custCode="",custName1="";
custCode = genericUtility.getColumnValue("cust_code",dom);
custCode=custCode==null ? "" :custCode.trim();
System.out.println("custCode ----->>["+custCode+"]");
if(custCode.length() > 0){
custName1=getNameOrDescrForCode(conn, "customer", "cust_name", "cust_code", custCode);
}
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName1+ "]]>").append("</cust_name>");
}
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
break; break;
case 2: case 2:
...@@ -534,7 +683,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -534,7 +683,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>"); valueXmlString.append("<Detail2>");
int childListLength = childNodeList.getLength(); int childListLength = childNodeList.getLength();
if (currentColumn.trim().equals("quantity__resale")) /*if (currentColumn.trim().equals("quantity__resale"))
{ {
System.out.println("-------item chnage quantity__resale-------------"); System.out.println("-------item chnage quantity__resale-------------");
String rateResale="",rateInv="",quantityInv="",podQty=""; String rateResale="",rateInv="",quantityInv="",podQty="";
...@@ -568,7 +717,6 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -568,7 +717,6 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
if (currentColumn.trim().equals("rate__resale")) if (currentColumn.trim().equals("rate__resale"))
{ {
System.out.println("-------item chnage rate__resale-------------"); System.out.println("-------item chnage rate__resale-------------");
String rateResale="",rateInv="",quantityInv="",podQty=""; String rateResale="",rateInv="",quantityInv="",podQty="";
double rateResaleD=0.0,rateInvoiceD=0.0,diffAmt=0.0,quantityInvD=0.0,podQtyD=0.0; double rateResaleD=0.0,rateInvoiceD=0.0,diffAmt=0.0,quantityInvD=0.0,podQtyD=0.0;
...@@ -595,12 +743,48 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -595,12 +743,48 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
diffAmt= PODprice - actualPrice ; diffAmt= PODprice - actualPrice ;
System.out.println("Diff Amount ------>>"+PODprice); System.out.println("Diff Amount ------>>"+PODprice);
valueXmlString.append("<amount>").append("<![CDATA["+diffAmt+"]]>").append("</amount>"); valueXmlString.append("<amount>").append("<![CDATA["+diffAmt+"]]>").append("</amount>");
}*/
if (currentColumn.trim().equals("bil_date"))
{
String sql="",invoiceID="",stkBillDate="",invoiceDate="";
Date d1=null,d2=null;
Timestamp invDateT=null;
long diffDate=0;
invoiceID = genericUtility.getColumnValue("invoice_id",dom1);
stkBillDate=genericUtility.getColumnValue("bil_date",dom);
invoiceID=invoiceID==null ? "" :invoiceID.trim();
stkBillDate=stkBillDate==null ? "" :stkBillDate.trim();
System.out.println("Invoice Id in bill date item change ------>>["+invoiceID+"]");
System.out.println("Stockist bill date item change ------>>["+stkBillDate+"]");
if (invoiceID.length() > 0 && stkBillDate.length() > 0){
sql="select tran_date from invoice where invoice_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs=pstmt.executeQuery();
if(rs.next()){
invDateT=rs.getTimestamp(1);
}
System.out.println("rs date --->>["+invDateT+"]");
if(invDateT !=null){
SimpleDateFormat format = new SimpleDateFormat("dd/mm/yy");
invoiceDate = format.format(invDateT);
System.out.println("tranDate ------>>["+invoiceDate+"]");
d1=format.parse(invoiceDate);
d2=format.parse(stkBillDate);
diffDate=Math.abs(d2.getTime() - d1.getTime());
long diffDays = diffDate / (24 * 60 * 60 * 1000);
System.out.print("Difference in days ------->>>>>>>>>>>["+diffDays+"]");
valueXmlString.append("<transit_day>").append("<![CDATA["+diffDays+"]]>").append("</transit_day>");
}
}
} }
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
}// end switch }// end switch
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
...@@ -1115,6 +1299,37 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -1115,6 +1299,37 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return false; return false;
}
private String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value)
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
e.printStackTrace();
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
} }
private String getSalesReturnTranID(Connection conn, String table_name, String tranID,String whrCondCol, String whrCondVal) private String getSalesReturnTranID(Connection conn, String table_name, String tranID,String whrCondCol, String whrCondVal)
...@@ -1128,7 +1343,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -1128,7 +1343,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
String sql="SELECT "+tranID+" FROM "+table_name+" WHERE "+whrCondCol+" = ? and confirmed = ?"; String sql="SELECT "+tranID+" FROM "+table_name+" WHERE "+whrCondCol+" = ? and confirmed = ?";
//select tran_id from sreturn where invoice_id = '10DS086300' and confirmed ='Y'; //select tran_id from sreturn where invoice_id = '10DS086300' and confirmed ='Y';
System.out.println("SQL in getNameOrDescrForCode method : "+sql); System.out.println("SQL in getSalesReturnTranID method : "+sql);
try try
{ {
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
......
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