Commit 0cc4fa1e authored by kmandhre's avatar kmandhre

change validation of road permit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94144 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 78bfa801
......@@ -76,6 +76,7 @@ public class InvoiceAmendmentIC extends ValidatorEJB implements InvoiceAmendment
String errString = "";
String siteCode1 = "";
String siteCode = "";
String invoiceId = "",despatchId = "",sorder = "",customerStatecode = "",siteCodeShip = "" ;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
......@@ -351,34 +352,209 @@ public class InvoiceAmendmentIC extends ValidatorEJB implements InvoiceAmendment
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
columnValue = genericUtility.getColumnValue("rd_permit_no", dom);
if(columnValue != null && columnValue.trim().length() > 0 && date1 != null)
invoiceId = genericUtility.getColumnValue("invoice_id", dom);
sql = "select desp_id from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId);
rs = pstmt.executeQuery();
if( rs.next() )
{
despatchId = rs.getString("desp_id");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select sord_no from despatch where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despatchId);
rs = pstmt.executeQuery();
if( rs.next() )
{
sql = "select expiry_date, status from roadpermit where rd_permit_no = ? ";
sorder = rs.getString("sord_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select sorder.site_code__ship ,customer.state_code from sorder , customer where sale_order = ? and sorder.cust_code__dlv = customer.cust_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sorder);
rs = pstmt.executeQuery();
if( rs.next() )
{
siteCodeShip= checkNull(rs.getString(1));
customerStatecode = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("399::"+siteCodeShip+" "+customerStatecode );
if(columnValue == null || columnValue.trim().length() == 0 )
{
sql = " select count(*) from state where state_code = ? and rd_permit_reqd = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, customerStatecode);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt > 0)////added by kunal on 18/jan/13
{
errList.add( "VTRDPT" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( date1 != null)
{
sql = " select count(*) from roadpermit where rd_permit_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
date2 = rs.getTimestamp(1);
columnValue1 = checkNull(rs.getString(2));
if(date2.after(date1))
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errList.add( "VTRDPT1" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
/*
invoiceId = genericUtility.getColumnValue("invoice_id", dom);
sql = "select desp_id from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId);
rs = pstmt.executeQuery();
if( rs.next() )
{
despatchId = rs.getString("desp_id");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select sord_no from despatch where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despatchId);
rs = pstmt.executeQuery();
if( rs.next() )
{
sorder = rs.getString("sord_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select sorder.site_code__ship ,customer.state_code from sorder , customer where sale_order = ? and sorder.cust_code__dlv = customer.cust_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sorder);
rs = pstmt.executeQuery();
if( rs.next() )
{
siteCodeShip= checkNull(rs.getString(1));
customerStatecode = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
*/
sql = "select expiry_date, status ,state_code__fr,state_code__to from roadpermit where rd_permit_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
errList.add( "VTEFF01" );
date2 = rs.getTimestamp(1);
columnValue1 = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("502::"+date1+" "+date2+" "+date1.after(date2));
if(date1.after(date2) && ((int)( (date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24))) != 0 )
{
errList.add( "VTRDPT5" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
if(columnValue1.equals("C"))
{
errList.add( "VTRDPS" );
errList.add( "VTRDPT6" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
//added by kunal on 17/jan/13
sql = " select count(*) from roadpermit where rd_permit_no = ? and site_code__fr = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
pstmt.setString(2, siteCodeShip);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errList.add( "VTRDPT3" );
errFields.add( childNodeName.toLowerCase() );
}
sql = " select count(*) from roadpermit where rd_permit_no = ? and state_code__to = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
pstmt.setString(2, customerStatecode);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errList.add( "VTRDPT4" );
errFields.add( childNodeName.toLowerCase() );
}
//added by kunal on 17/jan/13 end
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment