Commit 7dc9c25f authored by ssurve's avatar ssurve

Invoice Amendment Req. ID - WM2CSUN002 cust_pord, pord_date added


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93150 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 24e7b930
/******************************************************** /********************************************************
Title : InvoiceAmendmentIC Title : InvoiceAmendmentIC
Date : 01/06/2012 Date : 01/06/2012
Developer: Mahesh Patidar Developer: Mahesh Patidar
********************************************************/ ********************************************************/
package ibase.webitm.ejb.wms; package ibase.webitm.ejb.wms;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date; import java.sql.Date;
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.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import org.w3c.dom.CDATASection; import org.w3c.dom.CDATASection;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@javax.ejb.Stateless @javax.ejb.Stateless
public class InvoiceAmendmentIC extends ValidatorEJB implements InvoiceAmendmentICLocal,InvoiceAmendmentICRemote public class InvoiceAmendmentIC extends ValidatorEJB implements InvoiceAmendmentICLocal,InvoiceAmendmentICRemote
{ {
public String wfValData() throws RemoteException, ITMException public String wfValData() throws RemoteException, ITMException
{ {
return ""; return "";
} }
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;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String errString = null; String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("WFVALDATA 111111"); System.out.println("WFVALDATA 111111");
try try
{ {
System.out.println("xmlString [" + xmlString + "]"); System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]"); System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]"); System.out.println("xmlString2 [" + xmlString2 + "]");
if(xmlString != null && xmlString.trim().length()!=0) if(xmlString != null && xmlString.trim().length()!=0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length()!=0) if(xmlString1 != null && xmlString1.trim().length()!=0)
{ {
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length()!=0) if(xmlString2 != null && xmlString2.trim().length()!=0)
{ {
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams ); errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams );
System.out.println ( "ErrString: " + errString); System.out.println ( "ErrString: " + errString);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println ( "Exception: InvoiceAmendmentIC: wfValData(String xmlString): " + e.getMessage() + ":" ); System.out.println ( "Exception: InvoiceAmendmentIC: wfValData(String xmlString): " + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e); errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println ( "Returning from InvoiceAmendmentIC wfValData" ); System.out.println ( "Returning from InvoiceAmendmentIC wfValData" );
return ( errString ); return ( errString );
} }
public String wfValData(Document dom, Document dom1, Document dom2, String objContext,String editFlag, String xtraParams ) throws RemoteException, ITMException public String wfValData(Document dom, Document dom1, Document dom2, String objContext,String editFlag, String xtraParams ) throws RemoteException, ITMException
{ {
String errString = ""; String errString = "";
String siteCode1 = ""; String siteCode1 = "";
String siteCode = ""; String siteCode = "";
ResultSet rs = null; ResultSet rs = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = ""; String errorType = "", errCode = "";
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
NodeList parentList = null; NodeList parentList = null;
NodeList childList = null; NodeList childList = null;
int noOfChilds ; int noOfChilds ;
String childNodeName = ""; String childNodeName = "";
Node childNode =null; Node childNode =null;
String userId = ""; String userId = "";
int cnt = 0; int cnt = 0;
String columnValue = ""; String columnValue = "";
String columnValue1 = ""; String columnValue1 = "";
String confirmed = ""; String confirmed = "";
String sql = ""; String sql = "";
Timestamp date1 = null; Timestamp date1 = null;
Timestamp date2 = null; Timestamp date2 = null;
int currentFormNo = 0; int currentFormNo = 0;
ConnDriver connDriver = null; ConnDriver connDriver = null;
try try
{ {
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ); userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
if ( objContext != null && objContext.trim().length() > 0 ) if ( objContext != null && objContext.trim().length() > 0 )
{ {
currentFormNo = Integer.parseInt( objContext ); currentFormNo = Integer.parseInt( objContext );
} }
switch(currentFormNo) switch(currentFormNo)
{ {
case 1 : case 1 :
{ {
parentList = dom.getElementsByTagName( "Detail" + currentFormNo ); parentList = dom.getElementsByTagName( "Detail" + currentFormNo );
childList = parentList.item( 0 ).getChildNodes(); childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength(); noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++) for (int ctr = 0; ctr < noOfChilds; ctr++)
{ {
childNode = childList.item( ctr ); childNode = childList.item( ctr );
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null ) if ( childNode != null && childNode.getFirstChild() != null )
{ {
columnValue = childNode.getFirstChild().getNodeValue(); columnValue = childNode.getFirstChild().getNodeValue();
} }
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]"); System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if ( childNodeName.equalsIgnoreCase("invoice_id") ) if ( childNodeName.equalsIgnoreCase("invoice_id") )
{ {
columnValue = genericUtility.getColumnValue("invoice_id", dom); columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom); columnValue1 = genericUtility.getColumnValue("status", dom);
System.out.println("iNSIDE INVOICE ID["+columnValue+"]"); System.out.println("iNSIDE INVOICE ID["+columnValue+"]");
if(columnValue != null && columnValue.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
sql = "select confirmed from invoice where invoice_id = ? "; sql = "select confirmed from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
confirmed = checkNull(rs.getString(1)); confirmed = checkNull(rs.getString(1));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(! confirmed.trim().equals("Y")) if(! confirmed.trim().equals("Y"))
{ {
errList.add( "VMINVCD1" ); errList.add( "VMINVCD1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
else else
{ {
sql = "select count(*) from invoice_amendment where invoice_id = ? and status = ? "; sql = "select count(*) from invoice_amendment where invoice_id = ? and status = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
pstmt.setString(2, columnValue1); pstmt.setString(2, columnValue1);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
confirmed = ""; confirmed = "";
sql = "select (case when a.confirmed is null then 'N' else a.confirmed end) " + sql = "select (case when a.confirmed is null then 'N' else a.confirmed end) " +
" from receipt a, rcpdet b where a.tran_id = b.tran_id and b.ref_ser = 'S-INV' and b.ref_no = ?"; " from receipt a, rcpdet b where a.tran_id = b.tran_id and b.ref_ser = 'S-INV' and b.ref_no = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
confirmed = rs.getString(1); confirmed = rs.getString(1);
} }
if(confirmed.trim().equals("Y")) if(confirmed.trim().equals("Y"))
{ {
errList.add( "VTRCPCON" ); errList.add( "VTRCPCON" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
if(errList == null || errList.size() == 0) if(errList == null || errList.size() == 0)
{ {
if(cnt == 1 && (! editFlag.equals("E"))) if(cnt == 1 && (! editFlag.equals("E")))
{ {
errList.add( "VTINVCD01" ); errList.add( "VTINVCD01" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(errList == null || errList.size() == 0) if(errList == null || errList.size() == 0)
{ {
siteCode = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); siteCode = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sql = "select site_code from invoice where invoice_id =? "; sql = "select site_code from invoice where invoice_id =? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
siteCode1 = checkNull(rs.getString(1)); siteCode1 = checkNull(rs.getString(1));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(! siteCode.trim().equals(siteCode1)) if(! siteCode.trim().equals(siteCode1))
{ {
errList.add( "VTDIFFST" ); errList.add( "VTDIFFST" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
else else
{ {
errList.add( "VMINVIDNL" ); errList.add( "VMINVIDNL" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("tran_code") ) else if ( childNodeName.equalsIgnoreCase("tran_code") )
{ {
columnValue = genericUtility.getColumnValue("tran_code", dom); columnValue = genericUtility.getColumnValue("tran_code", dom);
if(columnValue != null && columnValue.trim().length() >0) if(columnValue != null && columnValue.trim().length() >0)
{ {
columnValue1 = genericUtility.getColumnValue("status", dom); columnValue1 = genericUtility.getColumnValue("status", dom);
if(columnValue1.equals("S")) if(columnValue1.equals("S"))
{ {
sql = " Select Count(*) from transporter where tran_code = ? "; sql = " Select Count(*) from transporter where tran_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VMTRAN1" ); errList.add( "VMTRAN1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else else
{ {
errList.add( "VMTRANCD1" ); errList.add( "VMTRANCD1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("trans_mode") ) else if ( childNodeName.equalsIgnoreCase("trans_mode") )
{ {
columnValue = genericUtility.getColumnValue("trans_mode", dom); columnValue = genericUtility.getColumnValue("trans_mode", dom);
if(columnValue == null || columnValue.trim().length() == 0) if(columnValue == null || columnValue.trim().length() == 0)
{ {
errList.add( "VTITMOD" ); errList.add( "VTITMOD" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
else else
{ {
sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT' "; sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X' "; sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VTITMOD" ); errList.add( "VTITMOD" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else if ( childNodeName.equalsIgnoreCase("eff_date") ) else if ( childNodeName.equalsIgnoreCase("eff_date") )
{ {
if(genericUtility.getColumnValue("eff_date", dom) != null) if(genericUtility.getColumnValue("eff_date", dom) != null)
{ {
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
columnValue = genericUtility.getColumnValue("invoice_id", dom); columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom); columnValue1 = genericUtility.getColumnValue("status", dom);
if(columnValue1.equals("B")) if(columnValue1.equals("B"))
{ {
sql = "select eff_date from invoice where invoice_id = ? "; sql = "select eff_date from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
date2 = rs.getTimestamp(1); date2 = rs.getTimestamp(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(date1 != null && date2 != null && date2.before(date1)) if(date1 != null && date2 != null && date2.before(date1))
{ {
errList.add( "VTEFF01" ); errList.add( "VTEFF01" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("rd_permit_no") ) else if ( childNodeName.equalsIgnoreCase("rd_permit_no") )
{ {
if(genericUtility.getColumnValue("eff_date", dom) != null) if(genericUtility.getColumnValue("eff_date", dom) != null)
{ {
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
columnValue = genericUtility.getColumnValue("rd_permit_no", dom); columnValue = genericUtility.getColumnValue("rd_permit_no", dom);
if(columnValue != null && columnValue.trim().length() > 0 && date1 != null) if(columnValue != null && columnValue.trim().length() > 0 && date1 != null)
{ {
sql = "select expiry_date, status from roadpermit where rd_permit_no = ? "; sql = "select expiry_date, status from roadpermit where rd_permit_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
date2 = rs.getTimestamp(1); date2 = rs.getTimestamp(1);
columnValue1 = checkNull(rs.getString(2)); columnValue1 = checkNull(rs.getString(2));
if(date2.after(date1)) if(date2.after(date1))
{ {
errList.add( "VTEFF01" ); errList.add( "VTEFF01" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
else else
{ {
if(columnValue1.equals("C")) if(columnValue1.equals("C"))
{ {
errList.add( "VTRDPS" ); errList.add( "VTRDPS" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else if ( childNodeName.equalsIgnoreCase("curr_code__frt") ) else if ( childNodeName.equalsIgnoreCase("curr_code__frt") )
{ {
columnValue = genericUtility.getColumnValue("curr_code__frt", dom); columnValue = genericUtility.getColumnValue("curr_code__frt", dom);
if(columnValue != null && columnValue.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
sql = "Select Count(*) from currency where curr_code = ?"; sql = "Select Count(*) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VTCURRCD1" ); errList.add( "VTCURRCD1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else if ( childNodeName.equalsIgnoreCase("curr_code__ins") ) else if ( childNodeName.equalsIgnoreCase("curr_code__ins") )
{ {
columnValue = genericUtility.getColumnValue("curr_code__ins", dom); columnValue = genericUtility.getColumnValue("curr_code__ins", dom);
if(columnValue != null && columnValue.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
sql = "Select Count(*) from currency where curr_code = ?"; sql = "Select Count(*) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VTCURRCD1" ); errList.add( "VTCURRCD1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else if ( childNodeName.equalsIgnoreCase("lr_date") ) else if ( childNodeName.equalsIgnoreCase("lr_date") )
{ {
if(genericUtility.getColumnValue("lr_date", dom) != null) if(genericUtility.getColumnValue("lr_date", dom) != null)
{ {
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("lr_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("lr_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
columnValue = genericUtility.getColumnValue("invoice_id", dom); columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom); columnValue1 = genericUtility.getColumnValue("status", dom);
if(! columnValue1.equals("D")) if(! columnValue1.equals("D"))
{ {
if(date1 != null) if(date1 != null)
{ {
sql = "select var_value from disparm where prd_code = '999999'" + sql = "select var_value from disparm where prd_code = '999999'" +
" and var_name = 'MAX_DELAY_IN_SHIP' "; " and var_name = 'MAX_DELAY_IN_SHIP' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
else else
{ {
cnt = 7; cnt = 7;
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(errList == null || errList.size() == 0) if(errList == null || errList.size() == 0)
{ {
sql = "select tran_date from invoice where invoice_id = ?"; sql = "select tran_date from invoice where invoice_id = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
date2 = rs.getTimestamp(1); date2 = rs.getTimestamp(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
int diffDays = Math.abs(date1.compareTo(date2)); int diffDays = Math.abs(date1.compareTo(date2));
if(date1 != null && (date1.before(date2) || diffDays > cnt)) if(date1 != null && (date1.before(date2) || diffDays > cnt))
{ {
errList.add( "VTILRD" ); errList.add( "VTILRD" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
else else
{ {
errList.add( "VTILRDATE" ); errList.add( "VTILRDATE" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
else if ( childNodeName.equalsIgnoreCase("shipment_id") ) else if ( childNodeName.equalsIgnoreCase("shipment_id") )
{ {
columnValue = genericUtility.getColumnValue("shipment_id", dom); columnValue = genericUtility.getColumnValue("shipment_id", dom);
if(columnValue != null && columnValue.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
sql = "select count(1) from shipment where shipment_id = ?"; sql = "select count(1) from shipment where shipment_id = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VTSHIPIDEX" ); errList.add( "VTSHIPIDEX" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
else else
{ {
errList.add( "VTSHIPID" ); errList.add( "VTSHIPID" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("stan_code__init") ) else if ( childNodeName.equalsIgnoreCase("stan_code__init") )
{ {
columnValue = genericUtility.getColumnValue("stan_code__init", dom); columnValue = genericUtility.getColumnValue("stan_code__init", dom);
if(columnValue != null && columnValue.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
sql = "select count(*) from STATION where STAN_CODE = ?"; sql = "select count(*) from STATION where STAN_CODE = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue); pstmt.setString(1, columnValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
if(cnt == 0) if(cnt == 0)
{ {
errList.add( "VESTACD2" ); errList.add( "VESTACD2" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
else if ( childNodeName.equalsIgnoreCase("date_dep") ) else if ( childNodeName.equalsIgnoreCase("date_dep") )
{ {
if(genericUtility.getColumnValue("date_dep", dom) != null) if(genericUtility.getColumnValue("date_dep", dom) != null)
{ {
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
if(genericUtility.getColumnValue("date_arr", dom) != null) if(genericUtility.getColumnValue("date_arr", dom) != null)
{ {
date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
if(date1 != null && date2 != null && date1.before(date2)) if(date1 != null && date2 != null && date1.before(date2))
{ {
System.out.println("Date ["+date1+"]["+date2+"]"); System.out.println("Date ["+date1+"]["+date2+"]");
errList.add( "VTETDETA" ); errList.add( "VTETDETA" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("date_arr") ) else if ( childNodeName.equalsIgnoreCase("date_arr") )
{ {
if(genericUtility.getColumnValue("date_dep", dom) != null) if(genericUtility.getColumnValue("date_dep", dom) != null)
{ {
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
if(genericUtility.getColumnValue("date_arr", dom) != null) if(genericUtility.getColumnValue("date_arr", dom) != null)
{ {
date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom), genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");; date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom), genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
} }
if(date1 != null && date2 != null && date1.before(date2)) if(date1 != null && date2 != null && date1.before(date2))
{ {
errList.add( "VTETDETA" ); errList.add( "VTETDETA" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
} }
break; break;
case 2 : case 2 :
{ {
parentList = dom.getElementsByTagName( "Detail2" ); parentList = dom.getElementsByTagName( "Detail2" );
childList = parentList.item( 0 ).getChildNodes(); childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength(); noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++) for (int ctr = 0; ctr < noOfChilds; ctr++)
{ {
childNode = childList.item( ctr ); childNode = childList.item( ctr );
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null ) if ( childNode != null && childNode.getFirstChild() != null )
{ {
columnValue = childNode.getFirstChild().getNodeValue(); columnValue = childNode.getFirstChild().getNodeValue();
} }
else if ( childNodeName.equalsIgnoreCase("status") ) else if ( childNodeName.equalsIgnoreCase("status") )
{ {
columnValue = genericUtility.getColumnValue("status", dom); columnValue = genericUtility.getColumnValue("status", dom);
System.out.println("cURRENT COLUNM STATUS["+columnValue+"]"); System.out.println("cURRENT COLUNM STATUS["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0) if(columnValue == null || columnValue.trim().length() == 0)
{ {
errList.add( "VMSTAT" ); errList.add( "VMSTAT" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
if ( childNodeName.equalsIgnoreCase("tracking_no") ) if ( childNodeName.equalsIgnoreCase("tracking_no") )
{ {
columnValue = genericUtility.getColumnValue("tracking_no", dom); columnValue = genericUtility.getColumnValue("tracking_no", dom);
System.out.println("cURRENT COLUNM TRACKING NO["+columnValue+"]"); System.out.println("cURRENT COLUNM TRACKING NO["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0) if(columnValue == null || columnValue.trim().length() == 0)
{ {
errList.add( "VMTRACKCD" ); errList.add( "VMTRACKCD" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
else if ( childNodeName.equalsIgnoreCase("status_date") ) else if ( childNodeName.equalsIgnoreCase("status_date") )
{ {
columnValue = genericUtility.getColumnValue("status_date", dom); columnValue = genericUtility.getColumnValue("status_date", dom);
System.out.println("cURRENT COLUNM status datee["+columnValue+"]"); System.out.println("cURRENT COLUNM status datee["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0) if(columnValue == null || columnValue.trim().length() == 0)
{ {
errList.add( "VMSTSCD1" ); errList.add( "VMSTSCD1" );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
} }
} }
int errListSize = errList.size(); int errListSize = errList.size();
cnt =0; cnt =0;
String errFldName = null; String errFldName = null;
if ( errList != null && errListSize > 0 ) if ( errList != null && errListSize > 0 )
{ {
for (cnt = 0; cnt < errListSize; cnt++ ) for (cnt = 0; cnt < errListSize; cnt++ )
{ {
errCode = (String)errList.get(cnt); errCode = (String)errList.get(cnt);
errFldName = (String)errFields.get(cnt); errFldName = (String)errFields.get(cnt);
System.out.println("errCode .........."+errCode); System.out.println("errCode .........."+errCode);
//String errMsg = hashMap.get(errCode)!=null ? hashMap.get(errCode).toString():""; //String errMsg = hashMap.get(errCode)!=null ? hashMap.get(errCode).toString():"";
//System.out.println("errMsg .........."+errMsg); //System.out.println("errMsg .........."+errMsg);
errString = getErrorString( errFldName, errCode, userId ); errString = getErrorString( errFldName, errCode, userId );
errorType = errorType( conn , errCode ); errorType = errorType( conn , errCode );
if ( errString.length() > 0) if ( errString.length() > 0)
{ {
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>")); bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml); System.out.println("errStringXml .........."+errStringXml);
errString = ""; errString = "";
} }
if ( errorType.equalsIgnoreCase("E")) if ( errorType.equalsIgnoreCase("E"))
{ {
break; break;
} }
} }
errList.clear(); errList.clear();
errList = null; errList = null;
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors></Root>\r\n"); errStringXml.append("</Errors></Root>\r\n");
} }
else else
{ {
errStringXml = new StringBuffer( "" ); errStringXml = new StringBuffer( "" );
} }
errString = errStringXml.toString(); errString = errStringXml.toString();
}//END TRY }//END TRY
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception in invoice amendmentIC == >"); System.out.println("Exception in invoice amendmentIC == >");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if( conn != null && !conn.isClosed() ) if( conn != null && !conn.isClosed() )
{ {
if( rs != null ) if( rs != null )
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if( pstmt != null ) if( pstmt != null )
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println( "Exception :invoice amendmentIC:wfValData :==>\n"+e.getMessage()); System.out.println( "Exception :invoice amendmentIC:wfValData :==>\n"+e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
private String errorType( Connection conn , String errorCode ) throws ITMException private String errorType( Connection conn , String errorCode ) throws ITMException
{ {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? "; String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql ); pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while( rs.next() ) while( rs.next() )
{ {
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} }
finally finally
{ {
try try
{ {
if ( rs != null ) if ( rs != null )
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if ( pstmt != null ) if ( pstmt != null )
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
catch ( Exception e ) catch ( Exception e )
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return msgType; return msgType;
} }
public String itemChanged() throws RemoteException, ITMException public String itemChanged() throws RemoteException, ITMException
{ {
return ""; return "";
} }
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
{ {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String errString = null; String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
if (xmlString != null && xmlString.trim().length()!=0) if (xmlString != null && xmlString.trim().length()!=0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length()!=0) if (xmlString1 != null && xmlString1.trim().length()!=0)
{ {
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length()!=0) if (xmlString2 != null && xmlString2.trim().length()!=0)
{ {
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams ); errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString); System.out.println ( "ErrString :" + errString);
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println ( "Exception :invoice amendmentIC :itemChanged(String,String):" + e.getMessage() + ":" ); System.out.println ( "Exception :invoice amendmentIC :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e); errString = genericUtility.createErrorString(e);
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println ( "returning from invoice amendmentIC itemChanged" ); System.out.println ( "returning from invoice amendmentIC itemChanged" );
return errString; return errString;
} }
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{ {
int grossWeight = 0; int grossWeight = 0;
int frtAmt = 0; int frtAmt = 0;
int exchRateFrt = 0; int exchRateFrt = 0;
int exchRateIns = 0; int exchRateIns = 0;
int currentFormNo = 0; int currentFormNo = 0;
int InsAmt = 0; int InsAmt = 0;
int noArt = 0; int noArt = 0;
int pos = 0; int pos = 0;
int amt1 = 0; int amt1 = 0;
int childNodeListLength = 0; int childNodeListLength = 0;
int ctr = 0; int ctr = 0;
double amt4 = 0.0; double amt4 = 0.0;
String sql = ""; String sql = "";
String columnValue = ""; String columnValue = "";
String columnValue1 = ""; String columnValue1 = "";
String itemCode = ""; String itemCode = "";
String childNodeName = ""; String childNodeName = "";
String descr = ""; String descr = "";
String descr1 = ""; String descr1 = "";
String reStr = ""; String reStr = "";
String currCodeFrt = ""; String currCodeFrt = "";
String currCodeIns = ""; String currCodeIns = "";
String lrNo = ""; String lrNo = "";
String octroiRcpNo = ""; String octroiRcpNo = "";
String lorryNo = ""; String lorryNo = "";
String gpNo = ""; String gpNo = "";
String grNo = ""; String grNo = "";
String sbNo = ""; String sbNo = "";
String stanCodeInit = ""; String stanCodeInit = "";
String shipmentId = ""; String shipmentId = "";
String custCode = ""; String custCode = "";
String custName = ""; String custName = "";
String salesPers = ""; String salesPers = "";
String spName = ""; String spName = "";
String saleOrder = ""; String saleOrder = "";
String tranCode = ""; String tranCode = "";
String transMode = ""; String transMode = "";
String despId = ""; String despId = "";
String remark = ""; String remark = "";
String chequeNo = ""; String chequeNo = "";
Date effFrom = null; String custPord = "";
Date sbDate = null; Date effFrom = null;
Date grDate = null; Date sbDate = null;
Date sailDate = null; Date grDate = null;
Date gpDate = null; Date sailDate = null;
Date lrDate = null; Date gpDate = null;
Date octroiRcpDate = null; Date lrDate = null;
Date chequeDate = null; Date octroiRcpDate = null;
NodeList parentNodeList = null; Date chequeDate = null;
NodeList childNodeList = null; Date pordDate = null;
Node parentNode = null; NodeList parentNodeList = null;
Node childNode = null; NodeList childNodeList = null;
Connection conn = null; Node parentNode = null;
PreparedStatement pstmt = null; Node childNode = null;
ResultSet rs = null; Connection conn = null;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy"); PreparedStatement pstmt = null;
StringBuffer valueXmlString = new StringBuffer(); ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
try StringBuffer valueXmlString = new StringBuffer();
{ GenericUtility genericUtility = GenericUtility.getInstance();
columnValue = genericUtility.getColumnValue( currentColumn, dom ); try
ConnDriver connDriver = null; {
connDriver = new ConnDriver(); columnValue = genericUtility.getColumnValue( currentColumn, dom );
conn = connDriver.getConnectDB("DriverValidator"); ConnDriver connDriver = null;
if( objContext != null && objContext.trim().length() > 0 ) connDriver = new ConnDriver();
{ conn = connDriver.getConnectDB("DriverValidator");
currentFormNo = Integer.parseInt( objContext ); if( objContext != null && objContext.trim().length() > 0 )
} {
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" ); currentFormNo = Integer.parseInt( objContext );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" ); }
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
switch ( currentFormNo ) valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
{
case 1: switch ( currentFormNo )
parentNodeList = dom.getElementsByTagName("Detail1"); {
parentNode = parentNodeList.item(0); case 1:
childNodeList = parentNode.getChildNodes(); parentNodeList = dom.getElementsByTagName("Detail1");
valueXmlString.append( "<Detail1>\r\n" ); parentNode = parentNodeList.item(0);
childNodeListLength = childNodeList.getLength(); childNodeList = parentNode.getChildNodes();
do valueXmlString.append( "<Detail1>\r\n" );
{ childNodeListLength = childNodeList.getLength();
childNode = childNodeList.item(ctr); do
childNodeName = childNode.getNodeName(); {
ctr ++; childNode = childNodeList.item(ctr);
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn)); childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if( currentColumn.trim().equalsIgnoreCase( "invoice_id" ) )
{
columnValue = genericUtility.getColumnValue("invoice_id",dom); if( currentColumn.trim().equalsIgnoreCase( "invoice_id" ) )
sql = "select invoice.frt_amt, invoice.curr_code__frt, invoice.exch_rate__frt, " + {
" invoice.curr_code__ins, invoice.exch_rate__ins, invoice.ins_amt, " + columnValue = genericUtility.getColumnValue("invoice_id",dom);
" invoice.cust_code,customer.cust_name,invoice.sales_pers,sales_pers.sp_name, " + sql = "select invoice.frt_amt, invoice.curr_code__frt, invoice.exch_rate__frt, " +
" invoice.sale_order,invoice.tran_code,invoice.trans_mode ,invoice.desp_id, remarks " + " invoice.curr_code__ins, invoice.exch_rate__ins, invoice.ins_amt, " +
" From invoice LEFT OUTER JOIN customer ON invoice.cust_code = customer.cust_code " + " invoice.cust_code,customer.cust_name,invoice.sales_pers,sales_pers.sp_name, " +
" LEFT OUTER JOIN sales_pers ON invoice.sales_pers = sales_pers.sales_pers " + " invoice.sale_order,invoice.tran_code,invoice.trans_mode ,invoice.desp_id, remarks " +
" where invoice.invoice_id = ?"; " From invoice LEFT OUTER JOIN customer ON invoice.cust_code = customer.cust_code " +
pstmt = conn.prepareStatement(sql); " LEFT OUTER JOIN sales_pers ON invoice.sales_pers = sales_pers.sales_pers " +
pstmt.setString(1, columnValue); " where invoice.invoice_id = ?";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if( rs.next() ) pstmt.setString(1, columnValue);
{ rs = pstmt.executeQuery();
frtAmt = rs.getInt(1); if( rs.next() )
currCodeFrt = checkNull(rs.getString(2)); {
exchRateFrt = rs.getInt(3); frtAmt = rs.getInt(1);
currCodeIns = checkNull(rs.getString(4)); currCodeFrt = checkNull(rs.getString(2));
exchRateIns = rs.getInt(5); exchRateFrt = rs.getInt(3);
InsAmt = rs.getInt(6); currCodeIns = checkNull(rs.getString(4));
custCode = checkNull(rs.getString(7)); exchRateIns = rs.getInt(5);
custName = checkNull(rs.getString(8)); InsAmt = rs.getInt(6);
salesPers = checkNull(rs.getString(9)); custCode = checkNull(rs.getString(7));
spName = checkNull(rs.getString(10)); custName = checkNull(rs.getString(8));
saleOrder = checkNull(rs.getString(11)); salesPers = checkNull(rs.getString(9));
tranCode = checkNull(rs.getString(12)); spName = checkNull(rs.getString(10));
transMode = checkNull(rs.getString(13)); saleOrder = checkNull(rs.getString(11));
despId = checkNull(rs.getString(14)); tranCode = checkNull(rs.getString(12));
remark = checkNull(rs.getString(15)); transMode = checkNull(rs.getString(13));
despId = checkNull(rs.getString(14));
} remark = checkNull(rs.getString(15));
rs.close();
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
sql = "select gross_weight from despatch where desp_id = ?"; pstmt = null;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despId); sql = "select gross_weight from despatch where desp_id = ?";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if( rs.next() ) pstmt.setString(1, despId);
{ rs = pstmt.executeQuery();
grossWeight = rs.getInt(1); if( rs.next() )
} {
rs.close(); grossWeight = rs.getInt(1);
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
valueXmlString.append( "<gross_weight><![CDATA[" ).append( grossWeight ).append( "]]></gross_weight>\r\n" ); pstmt.close();
pstmt = null;
sql = "select cheque_no, cheque_date from sorder where sale_order = ?"; valueXmlString.append( "<gross_weight><![CDATA[" ).append( grossWeight ).append( "]]></gross_weight>\r\n" );
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder); // Query modified by sandesh on 21/May/2013 . cust_pord, pord_date added
rs = pstmt.executeQuery();
if( rs.next() ) sql = "select cheque_no, cheque_date, cust_pord, pord_date from sorder where sale_order = ?";
{
chequeNo = checkNull(rs.getString(1)); System.out.println("query => select cheque_no, cheque_date, cust_pord, pord_date from sorder where sale_order = '"+saleOrder+"'");
chequeDate = rs.getDate(2);
} pstmt = conn.prepareStatement(sql);
rs.close(); pstmt.setString(1, saleOrder);
rs = null; rs = pstmt.executeQuery();
pstmt.close(); if( rs.next() )
pstmt = null; {
valueXmlString.append( "<ref_no><![CDATA[" ).append( chequeNo ).append( "]]></ref_no>\r\n" ); chequeNo = checkNull(rs.getString(1));
valueXmlString.append( "<ref_date><![CDATA[" ).append( chequeDate==null?"":sdf.format(chequeDate) ).append( "]]></ref_date>\r\n" ); chequeDate = rs.getDate(2);
custPord = rs.getString("cust_pord");
sql = "select descr from gencodes where fld_value = ? and mod_name='W_INVOICE_AMENDMENT'"; pordDate = rs.getDate("pord_date");
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,transMode );
rs = pstmt.executeQuery(); System.out.println("chequeNo : "+chequeNo+" chequeDate : "+chequeDate+" custPord : "+custPord+" pordDate : "+pordDate);
if( rs.next() ) rs.close();
{ rs = null;
descr = checkNull(rs.getString(1)); pstmt.close();
} pstmt = null;
rs.close(); valueXmlString.append( "<ref_no><![CDATA[" ).append( chequeNo==null?"":chequeNo).append( "]]></ref_no>\r\n" );
rs = null; valueXmlString.append( "<ref_date><![CDATA[" ).append( chequeDate==null?"":sdf.format(chequeDate) ).append( "]]></ref_date>\r\n" );
pstmt.close();
pstmt = null; // Added by sandesh on 21/May/2013 . cust_pord, pord_date added
valueXmlString.append( "<trans_mode><![CDATA[" ).append( transMode ).append( "]]></trans_mode>\r\n" );
valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" ); valueXmlString.append( "<cust_pord><![CDATA[" ).append( custPord==null?"":custPord).append( "]]></cust_pord>\r\n" );
descr = ""; valueXmlString.append( "<pord_date><![CDATA[" ).append( pordDate==null?"":sdf.format(pordDate) ).append( "]]></pord_date>\r\n" );
sql = "select tran_name from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql); sql = "select descr from gencodes where fld_value = ? and mod_name='W_INVOICE_AMENDMENT'";
pstmt.setString(1,tranCode ); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); pstmt.setString(1,transMode );
if( rs.next() ) rs = pstmt.executeQuery();
{ if( rs.next() )
descr = checkNull(rs.getString(1)); {
} descr = checkNull(rs.getString(1));
rs.close(); }
rs = null; rs.close();
pstmt.close(); rs = null;
pstmt = null; pstmt.close();
valueXmlString.append( "<invoice_cust_code><![CDATA[" ).append( custCode ).append( "]]></invoice_cust_code>\r\n" ); pstmt = null;
valueXmlString.append( "<customer_cust_name><![CDATA[" ).append( custName ).append( "]]></customer_cust_name>\r\n" ); valueXmlString.append( "<trans_mode><![CDATA[" ).append( transMode ).append( "]]></trans_mode>\r\n" );
valueXmlString.append( "<frt_amt><![CDATA[" ).append( frtAmt ).append( "]]></frt_amt>\r\n" ); valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" );
valueXmlString.append( "<invoice_sales_pers><![CDATA[" ).append( salesPers ).append( "]]></invoice_sales_pers>\r\n" ); descr = "";
valueXmlString.append( "<sales_pers_sp_name><![CDATA[" ).append( spName ).append( "]]></sales_pers_sp_name>\r\n" ); sql = "select tran_name from transporter where tran_code = ?";
valueXmlString.append( "<curr_code__frt><![CDATA[" ).append( currCodeFrt ).append( "]]></curr_code__frt>\r\n" ); pstmt = conn.prepareStatement(sql);
valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( exchRateFrt ).append( "]]></exch_rate__frt>\r\n" ); pstmt.setString(1,tranCode );
valueXmlString.append( "<ins_amt><![CDATA[" ).append( InsAmt ).append( "]]></ins_amt>\r\n" ); rs = pstmt.executeQuery();
valueXmlString.append( "<curr_code__ins><![CDATA[" ).append( currCodeIns ).append( "]]></curr_code__ins>\r\n" ); if( rs.next() )
valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( exchRateIns ).append( "]]></exch_rate__ins>\r\n" ); {
valueXmlString.append( "<remarks><![CDATA[" ).append( remark ).append( "]]></remarks>\r\n" ); descr = checkNull(rs.getString(1));
}
reStr = itemChanged(dom, dom1, dom2, objContext, "status", editFlag, xtraParams); rs.close();
pos = reStr.indexOf("<Detail1>"); rs = null;
reStr = reStr.substring(pos + 9); pstmt.close();
pos = reStr.indexOf("</Detail1>"); pstmt = null;
reStr = reStr.substring(0,pos); valueXmlString.append( "<invoice_cust_code><![CDATA[" ).append( custCode ).append( "]]></invoice_cust_code>\r\n" );
valueXmlString.append(reStr); valueXmlString.append( "<customer_cust_name><![CDATA[" ).append( custName ).append( "]]></customer_cust_name>\r\n" );
valueXmlString.append( "<frt_amt><![CDATA[" ).append( frtAmt ).append( "]]></frt_amt>\r\n" );
descr = ""; valueXmlString.append( "<invoice_sales_pers><![CDATA[" ).append( salesPers ).append( "]]></invoice_sales_pers>\r\n" );
descr1 = ""; valueXmlString.append( "<sales_pers_sp_name><![CDATA[" ).append( spName ).append( "]]></sales_pers_sp_name>\r\n" );
sql = "select distinct invdet.item_code, rtrim(ltrim(item.descr)), sum(invdet.quantity) " + valueXmlString.append( "<curr_code__frt><![CDATA[" ).append( currCodeFrt ).append( "]]></curr_code__frt>\r\n" );
" from invdet,item where invdet.item_code = item.item_code and invdet.invoice_id = ? " + valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( exchRateFrt ).append( "]]></exch_rate__frt>\r\n" );
" group by invdet.item_code, rtrim(ltrim(item.descr)) "; valueXmlString.append( "<ins_amt><![CDATA[" ).append( InsAmt ).append( "]]></ins_amt>\r\n" );
pstmt = conn.prepareStatement(sql); valueXmlString.append( "<curr_code__ins><![CDATA[" ).append( currCodeIns ).append( "]]></curr_code__ins>\r\n" );
pstmt.setString(1, columnValue); valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( exchRateIns ).append( "]]></exch_rate__ins>\r\n" );
rs = pstmt.executeQuery(); valueXmlString.append( "<remarks><![CDATA[" ).append( remark ).append( "]]></remarks>\r\n" );
while( rs.next() )
{ reStr = itemChanged(dom, dom1, dom2, objContext, "status", editFlag, xtraParams);
itemCode = checkNull(rs.getString(1)); pos = reStr.indexOf("<Detail1>");
descr = checkNull(rs.getString(2)); reStr = reStr.substring(pos + 9);
amt1 = rs.getInt(3); pos = reStr.indexOf("</Detail1>");
if(descr.indexOf('/') > 0) reStr = reStr.substring(0,pos);
{ valueXmlString.append(reStr);
descr = descr.replace('/', '\'');
} descr = "";
descr1 = descr1 + itemCode +" "+ descr + " "+ amt1 +"/"; descr1 = "";
} sql = "select distinct invdet.item_code, rtrim(ltrim(item.descr)), sum(invdet.quantity) " +
rs.close(); " from invdet,item where invdet.item_code = item.item_code and invdet.invoice_id = ? " +
rs = null; " group by invdet.item_code, rtrim(ltrim(item.descr)) ";
pstmt.close(); pstmt = conn.prepareStatement(sql);
pstmt = null; pstmt.setString(1, columnValue);
valueXmlString.append( "<item_info><![CDATA[" ).append( descr1 ).append( "]]></item_info>\r\n" ); rs = pstmt.executeQuery();
} while( rs.next() )
{
if( currentColumn.trim().equalsIgnoreCase( "status" ) ) itemCode = checkNull(rs.getString(1));
{ descr = checkNull(rs.getString(2));
columnValue = genericUtility.getColumnValue("status",dom).trim(); amt1 = rs.getInt(3);
columnValue1 = genericUtility.getColumnValue("invoice_id",dom); if(descr.indexOf('/') > 0)
if(columnValue.equals("S")) {
{ descr = descr.replace('/', '\'');
sql = "select desp_id, eff_date from invoice where invoice_id = ?"; }
pstmt = conn.prepareStatement(sql); descr1 = descr1 + itemCode +" "+ descr + " "+ amt1 +"/";
pstmt.setString(1, columnValue1); }
rs = pstmt.executeQuery(); rs.close();
if( rs.next() ) rs = null;
{ pstmt.close();
despId = checkNull(rs.getString(1)); pstmt = null;
effFrom = rs.getDate(2); valueXmlString.append( "<item_info><![CDATA[" ).append( descr1 ).append( "]]></item_info>\r\n" );
} }
rs.close();
rs = null; if( currentColumn.trim().equalsIgnoreCase( "status" ) )
pstmt.close(); {
pstmt = null; columnValue = genericUtility.getColumnValue("status",dom).trim();
columnValue1 = genericUtility.getColumnValue("invoice_id",dom);
sql = "select tran_code, lr_no, lr_date, octroi_rcp_no, orctoi_rcp_date," + if(columnValue.equals("S"))
" case when no_art is null then 0 else no_art end, lorry_no,gp_no, " + {
" gp_date,gr_no,gr_date,sail_date, sb_no,sb_date,stan_code__init, " + sql = "select desp_id, eff_date from invoice where invoice_id = ?";
" SHIPMENT_ID from despatch where desp_id = ?"; pstmt = conn.prepareStatement(sql);
pstmt = conn.prepareStatement(sql); pstmt.setString(1, columnValue1);
pstmt.setString(1, despId); rs = pstmt.executeQuery();
rs = pstmt.executeQuery(); if( rs.next() )
if( rs.next() ) {
{ despId = checkNull(rs.getString(1));
tranCode = checkNull(rs.getString(1)); effFrom = rs.getDate(2);
lrNo = checkNull(rs.getString(2)); }
lrDate = rs.getDate(3); rs.close();
octroiRcpNo = checkNull(rs.getString(4)); rs = null;
octroiRcpDate = rs.getDate(5); pstmt.close();
noArt = rs.getInt(6); pstmt = null;
lorryNo = checkNull(rs.getString(7));
gpNo = checkNull(rs.getString(8)); sql = "select tran_code, lr_no, lr_date, octroi_rcp_no, orctoi_rcp_date," +
gpDate = rs.getDate(9); " case when no_art is null then 0 else no_art end, lorry_no,gp_no, " +
grNo = checkNull(rs.getString(10)); " gp_date,gr_no,gr_date,sail_date, sb_no,sb_date,stan_code__init, " +
grDate = rs.getDate(11); " SHIPMENT_ID from despatch where desp_id = ?";
sailDate = rs.getDate(12); pstmt = conn.prepareStatement(sql);
sbNo = checkNull(rs.getString(13)); pstmt.setString(1, despId);
sbDate = rs.getDate(14); rs = pstmt.executeQuery();
stanCodeInit = checkNull(rs.getString(15)); if( rs.next() )
shipmentId = checkNull(rs.getString(16)); {
} tranCode = checkNull(rs.getString(1));
rs.close(); lrNo = checkNull(rs.getString(2));
rs = null; lrDate = rs.getDate(3);
pstmt.close(); octroiRcpNo = checkNull(rs.getString(4));
pstmt = null; octroiRcpDate = rs.getDate(5);
noArt = rs.getInt(6);
descr = ""; lorryNo = checkNull(rs.getString(7));
gpNo = checkNull(rs.getString(8));
sql = "select tran_name from transporter where tran_code = ?"; gpDate = rs.getDate(9);
pstmt = conn.prepareStatement(sql); grNo = checkNull(rs.getString(10));
pstmt.setString(1, tranCode); grDate = rs.getDate(11);
rs = pstmt.executeQuery(); sailDate = rs.getDate(12);
if( rs.next() ) sbNo = checkNull(rs.getString(13));
{ sbDate = rs.getDate(14);
descr = rs.getString(1); stanCodeInit = checkNull(rs.getString(15));
} shipmentId = checkNull(rs.getString(16));
rs.close(); }
rs = null; rs.close();
pstmt.close(); rs = null;
pstmt = null; pstmt.close();
pstmt = null;
valueXmlString.append( "<shipment_id><![CDATA[" ).append( shipmentId ).append( "]]></shipment_id>\r\n" );
valueXmlString.append( "<tran_code protect = \"0\"><![CDATA[" ).append( tranCode ).append( "]]></tran_code>\r\n" ); descr = "";
valueXmlString.append( "<tran_name><![CDATA[" ).append( descr ).append( "]]></tran_name>\r\n" );
valueXmlString.append( "<lr_no protect = \"0\"><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" ); sql = "select tran_name from transporter where tran_code = ?";
valueXmlString.append( "<lr_date protect = \"0\"><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" ); pstmt = conn.prepareStatement(sql);
valueXmlString.append( "<no_art><![CDATA[" ).append( noArt ).append( "]]></no_art>\r\n" ); pstmt.setString(1, tranCode);
valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[" ).append( octroiRcpNo ).append( "]]></octroi_rcp_no>\r\n" ); rs = pstmt.executeQuery();
valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( octroiRcpDate==null?"":sdf.format(octroiRcpDate) ).append( "]]></octroi_rcp_date>\r\n" ); if( rs.next() )
valueXmlString.append( "<desp_id><![CDATA[" ).append( despId ).append( "]]></desp_id>\r\n" ); {
valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( effFrom==null?"":sdf.format(effFrom) ).append( "]]></eff_date>\r\n" ); descr = rs.getString(1);
valueXmlString.append( "<lorry_no><![CDATA[" ).append( lorryNo ).append( "]]></lorry_no>\r\n" ); }
valueXmlString.append( "<gp_no><![CDATA[" ).append( gpNo ).append( "]]></gp_no>\r\n" ); rs.close();
valueXmlString.append( "<gp_date><![CDATA[" ).append( gpDate==null?"":sdf.format(gpDate) ).append( "]]></gp_date>\r\n" ); rs = null;
valueXmlString.append( "<gr_no><![CDATA[" ).append( grNo ).append( "]]></gr_no>\r\n" ); pstmt.close();
valueXmlString.append( "<gr_date><![CDATA[" ).append( grDate==null?"":sdf.format(grDate) ).append( "]]></gr_date>\r\n" ); pstmt = null;
valueXmlString.append( "<sail_date><![CDATA[" ).append( sailDate==null?"":sdf.format(sailDate) ).append( "]]></sail_date>\r\n" );
valueXmlString.append( "<sb_no><![CDATA[" ).append( sbNo ).append( "]]></sb_no>\r\n" ); valueXmlString.append( "<shipment_id><![CDATA[" ).append( shipmentId ).append( "]]></shipment_id>\r\n" );
valueXmlString.append( "<sb_date><![CDATA[" ).append( sbDate==null?"":sdf.format(sbDate) ).append( "]]></sb_date>\r\n" ); valueXmlString.append( "<tran_code protect = \"0\"><![CDATA[" ).append( tranCode ).append( "]]></tran_code>\r\n" );
valueXmlString.append( "<stan_code__init><![CDATA[" ).append( stanCodeInit ).append( "]]></stan_code__init>\r\n" ); valueXmlString.append( "<tran_name><![CDATA[" ).append( descr ).append( "]]></tran_name>\r\n" );
valueXmlString.append( "<ref_no><![CDATA[" ).append( genericUtility.getColumnValue("ref_no", dom) ).append( "]]></ref_no>\r\n" ); valueXmlString.append( "<lr_no protect = \"0\"><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
valueXmlString.append( "<ref_date><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" ); valueXmlString.append( "<lr_date protect = \"0\"><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
setNodeValue( dom,"stan_code__init" ,stanCodeInit ); valueXmlString.append( "<no_art><![CDATA[" ).append( noArt ).append( "]]></no_art>\r\n" );
reStr = itemChanged(dom, dom1, dom2, objContext, "stan_code__init", editFlag, xtraParams); valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[" ).append( octroiRcpNo ).append( "]]></octroi_rcp_no>\r\n" );
pos = reStr.indexOf("<Detail1>"); valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( octroiRcpDate==null?"":sdf.format(octroiRcpDate) ).append( "]]></octroi_rcp_date>\r\n" );
reStr = reStr.substring(pos + 9); valueXmlString.append( "<desp_id><![CDATA[" ).append( despId ).append( "]]></desp_id>\r\n" );
pos = reStr.indexOf("</Detail1>"); valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( effFrom==null?"":sdf.format(effFrom) ).append( "]]></eff_date>\r\n" );
reStr = reStr.substring(0,pos); valueXmlString.append( "<lorry_no><![CDATA[" ).append( lorryNo ).append( "]]></lorry_no>\r\n" );
valueXmlString.append(reStr); valueXmlString.append( "<gp_no><![CDATA[" ).append( gpNo ).append( "]]></gp_no>\r\n" );
} valueXmlString.append( "<gp_date><![CDATA[" ).append( gpDate==null?"":sdf.format(gpDate) ).append( "]]></gp_date>\r\n" );
else valueXmlString.append( "<gr_no><![CDATA[" ).append( grNo ).append( "]]></gr_no>\r\n" );
{ valueXmlString.append( "<gr_date><![CDATA[" ).append( grDate==null?"":sdf.format(grDate) ).append( "]]></gr_date>\r\n" );
valueXmlString.append( "<tran_code protect = \"1\"><![CDATA[]]></tran_code>\r\n" ); valueXmlString.append( "<sail_date><![CDATA[" ).append( sailDate==null?"":sdf.format(sailDate) ).append( "]]></sail_date>\r\n" );
valueXmlString.append( "<lr_no protect = \"1\"><![CDATA[]]></lr_no>\r\n" ); valueXmlString.append( "<sb_no><![CDATA[" ).append( sbNo ).append( "]]></sb_no>\r\n" );
valueXmlString.append( "<lr_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("lr_date", dom)) ).append( "]]></lr_date>\r\n" ); valueXmlString.append( "<sb_date><![CDATA[" ).append( sbDate==null?"":sdf.format(sbDate) ).append( "]]></sb_date>\r\n" );
if(columnValue.equals("B")) valueXmlString.append( "<stan_code__init><![CDATA[" ).append( stanCodeInit ).append( "]]></stan_code__init>\r\n" );
{ valueXmlString.append( "<ref_no><![CDATA[" ).append( genericUtility.getColumnValue("ref_no", dom) ).append( "]]></ref_no>\r\n" );
valueXmlString.append( "<octroi_rcp_no protect = \"1\"><![CDATA[]]></octroi_rcp_no>\r\n" ); valueXmlString.append( "<ref_date><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" );
valueXmlString.append( "<octroi_rcp_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" ); setNodeValue( dom,"stan_code__init" ,stanCodeInit );
} reStr = itemChanged(dom, dom1, dom2, objContext, "stan_code__init", editFlag, xtraParams);
else pos = reStr.indexOf("<Detail1>");
{ reStr = reStr.substring(pos + 9);
valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[]]></octroi_rcp_no>\r\n" ); pos = reStr.indexOf("</Detail1>");
valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" ); reStr = reStr.substring(0,pos);
} valueXmlString.append(reStr);
valueXmlString.append( "<transporter_tran_name><![CDATA[]]></transporter_tran_name>\r\n" ); }
valueXmlString.append( "<desp_id><![CDATA[]]></desp_id>\r\n" ); else
valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("eff_date", dom)) ).append( "]]></eff_date>\r\n" ); {
valueXmlString.append( "<ref_no protect = \"1\"><![CDATA[]]></ref_no>\r\n" ); valueXmlString.append( "<tran_code protect = \"1\"><![CDATA[]]></tran_code>\r\n" );
valueXmlString.append( "<ref_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" ); valueXmlString.append( "<lr_no protect = \"1\"><![CDATA[]]></lr_no>\r\n" );
} valueXmlString.append( "<lr_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("lr_date", dom)) ).append( "]]></lr_date>\r\n" );
} if(columnValue.equals("B"))
{
if( currentColumn.trim().equalsIgnoreCase( "tran_code" ) ) valueXmlString.append( "<octroi_rcp_no protect = \"1\"><![CDATA[]]></octroi_rcp_no>\r\n" );
{ valueXmlString.append( "<octroi_rcp_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" );
columnValue = genericUtility.getColumnValue("tran_code",dom); }
sql = "select tran_name from transporter where tran_code = ? "; else
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1, columnValue); valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[]]></octroi_rcp_no>\r\n" );
rs = pstmt.executeQuery(); valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" );
if( rs.next() ) }
{ valueXmlString.append( "<transporter_tran_name><![CDATA[]]></transporter_tran_name>\r\n" );
descr = checkNull(rs.getString(1)); valueXmlString.append( "<desp_id><![CDATA[]]></desp_id>\r\n" );
} valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("eff_date", dom)) ).append( "]]></eff_date>\r\n" );
rs.close(); valueXmlString.append( "<ref_no protect = \"1\"><![CDATA[]]></ref_no>\r\n" );
rs = null; valueXmlString.append( "<ref_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" );
pstmt.close(); }
pstmt = null; }
valueXmlString.append( "<transporter_tran_name><![CDATA[" ).append( descr ).append( "]]></transporter_tran_name>\r\n" );
} if( currentColumn.trim().equalsIgnoreCase( "tran_code" ) )
{
if( currentColumn.trim().equalsIgnoreCase( "trans_mode" ) ) columnValue = genericUtility.getColumnValue("tran_code",dom);
{ sql = "select tran_name from transporter where tran_code = ? ";
columnValue = genericUtility.getColumnValue("trans_mode",dom); pstmt = conn.prepareStatement(sql);
sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT'"; pstmt.setString(1, columnValue);
pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery();
pstmt.setString(1, columnValue); if( rs.next() )
rs = pstmt.executeQuery(); {
if( rs.next() ) descr = checkNull(rs.getString(1));
{ }
descr = checkNull(rs.getString(1)); rs.close();
} rs = null;
else pstmt.close();
{ pstmt = null;
rs.close(); valueXmlString.append( "<transporter_tran_name><![CDATA[" ).append( descr ).append( "]]></transporter_tran_name>\r\n" );
rs = null; }
pstmt.close();
pstmt = null; if( currentColumn.trim().equalsIgnoreCase( "trans_mode" ) )
{
sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X'"; columnValue = genericUtility.getColumnValue("trans_mode",dom);
pstmt = conn.prepareStatement(sql); sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT'";
pstmt.setString(1, columnValue); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); pstmt.setString(1, columnValue);
if( rs.next() ) rs = pstmt.executeQuery();
{ if( rs.next() )
descr = checkNull(rs.getString(1)); {
} descr = checkNull(rs.getString(1));
} }
rs.close(); else
rs = null; {
pstmt.close(); rs.close();
pstmt = null; rs = null;
valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" ); pstmt.close();
} pstmt = null;
sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X'";
if( currentColumn.trim().equalsIgnoreCase( "curr_code__frt" ) ) pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1, columnValue);
columnValue = genericUtility.getColumnValue("curr_code__frt",dom); rs = pstmt.executeQuery();
sql = "select std_exrt from currency where curr_code = ? "; if( rs.next() )
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1, columnValue); descr = checkNull(rs.getString(1));
rs = pstmt.executeQuery(); }
if( rs.next() ) }
{ rs.close();
amt4 = rs.getDouble(1); rs = null;
} pstmt.close();
rs.close(); pstmt = null;
rs = null; valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" );
pstmt.close(); }
pstmt = null;
valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__frt>\r\n" );
} if( currentColumn.trim().equalsIgnoreCase( "curr_code__frt" ) )
{
columnValue = genericUtility.getColumnValue("curr_code__frt",dom);
if( currentColumn.trim().equalsIgnoreCase( "curr_code__ins" ) ) sql = "select std_exrt from currency where curr_code = ? ";
{ pstmt = conn.prepareStatement(sql);
columnValue = genericUtility.getColumnValue("curr_code__ins",dom); pstmt.setString(1, columnValue);
sql = "select std_exrt from currency where curr_code = ? "; rs = pstmt.executeQuery();
pstmt = conn.prepareStatement(sql); if( rs.next() )
pstmt.setString(1, columnValue); {
rs = pstmt.executeQuery(); amt4 = rs.getDouble(1);
if( rs.next() ) }
{ rs.close();
amt4 = rs.getDouble(1); rs = null;
} pstmt.close();
rs.close(); pstmt = null;
rs = null; valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__frt>\r\n" );
pstmt.close(); }
pstmt = null;
valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__ins>\r\n" );
} if( currentColumn.trim().equalsIgnoreCase( "curr_code__ins" ) )
{
columnValue = genericUtility.getColumnValue("curr_code__ins",dom);
if( currentColumn.trim().equalsIgnoreCase( "stan_code__init" ) ) sql = "select std_exrt from currency where curr_code = ? ";
{ pstmt = conn.prepareStatement(sql);
columnValue = genericUtility.getColumnValue("stan_code__init",dom); pstmt.setString(1, columnValue);
sql = "select descr from station where stan_code = ? "; rs = pstmt.executeQuery();
pstmt = conn.prepareStatement(sql); if( rs.next() )
pstmt.setString(1, columnValue); {
rs = pstmt.executeQuery(); amt4 = rs.getDouble(1);
if( rs.next() ) }
{ rs.close();
descr = checkNull(rs.getString(1)); rs = null;
} pstmt.close();
rs.close(); pstmt = null;
rs = null; valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__ins>\r\n" );
pstmt.close(); }
pstmt = null;
valueXmlString.append( "<station_descr><![CDATA[" ).append( descr ).append( "]]></station_descr>\r\n" );
} if( currentColumn.trim().equalsIgnoreCase( "stan_code__init" ) )
{
columnValue = genericUtility.getColumnValue("stan_code__init",dom);
if( currentColumn.trim().equalsIgnoreCase( "shipment_id" ) ) sql = "select descr from station where stan_code = ? ";
{ pstmt = conn.prepareStatement(sql);
columnValue = genericUtility.getColumnValue("shipment_id",dom); pstmt.setString(1, columnValue);
if(columnValue != null && columnValue.trim().length() > 0) rs = pstmt.executeQuery();
{ if( rs.next() )
sql = "select lr_no,lr_date from shipment where shipment_id = ? "; {
pstmt = conn.prepareStatement(sql); descr = checkNull(rs.getString(1));
pstmt.setString(1, columnValue); }
rs = pstmt.executeQuery(); rs.close();
if( rs.next() ) rs = null;
{ pstmt.close();
lrNo = checkNull(rs.getString(1)); pstmt = null;
lrDate = rs.getDate(2); valueXmlString.append( "<station_descr><![CDATA[" ).append( descr ).append( "]]></station_descr>\r\n" );
} }
rs.close();
rs = null;
pstmt.close(); if( currentColumn.trim().equalsIgnoreCase( "shipment_id" ) )
pstmt = null; {
columnValue = genericUtility.getColumnValue("shipment_id",dom);
if(lrNo.trim().length() > 0) if(columnValue != null && columnValue.trim().length() > 0)
{ {
valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" ); sql = "select lr_no,lr_date from shipment where shipment_id = ? ";
} pstmt = conn.prepareStatement(sql);
if(lrDate != null) pstmt.setString(1, columnValue);
{ rs = pstmt.executeQuery();
valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" ); if( rs.next() )
} {
} lrNo = checkNull(rs.getString(1));
else lrDate = rs.getDate(2);
{ }
columnValue1 = genericUtility.getColumnValue("desp_id",dom); rs.close();
if(columnValue1 != null && columnValue1.trim().length() > 0) rs = null;
{ pstmt.close();
sql = "select lr_no, lr_date from despatch where desp_id = ? "; pstmt = null;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue1); if(lrNo.trim().length() > 0)
rs = pstmt.executeQuery(); {
if( rs.next() ) valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
{ }
lrNo = checkNull(rs.getString(1)); if(lrDate != null)
lrDate = rs.getDate(2); {
} valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
rs.close(); }
rs = null; }
pstmt.close(); else
pstmt = null; {
columnValue1 = genericUtility.getColumnValue("desp_id",dom);
if(lrNo.trim().length() > 0) if(columnValue1 != null && columnValue1.trim().length() > 0)
{ {
valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" ); sql = "select lr_no, lr_date from despatch where desp_id = ? ";
} pstmt = conn.prepareStatement(sql);
if(lrDate != null) pstmt.setString(1, columnValue1);
{ rs = pstmt.executeQuery();
valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" ); if( rs.next() )
} {
} lrNo = checkNull(rs.getString(1));
} lrDate = rs.getDate(2);
} }
valueXmlString.append( "</Detail1>\r\n" ); rs.close();
break; rs = null;
pstmt.close();
pstmt = null;
case 2:
{ if(lrNo.trim().length() > 0)
parentNodeList = dom.getElementsByTagName("Detail2"); {
parentNode = parentNodeList.item(0); valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
childNodeList = parentNode.getChildNodes(); }
valueXmlString.append("<Detail2>"); if(lrDate != null)
childNodeListLength = childNodeList.getLength(); {
do valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
{ }
childNode = childNodeList.item(ctr); }
childNodeName = childNode.getNodeName(); }
ctr ++; }
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn)); valueXmlString.append( "</Detail1>\r\n" );
break;
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
columnValue = genericUtility.getColumnValue("tran_id", dom1); case 2:
valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull(columnValue) ).append( "]]></tran_id>\r\n" ); {
valueXmlString.append( "<status_date><![CDATA[" ).append( sdf.format(new java.util.Date()) ).append( "]]></status_date>\r\n" ); parentNodeList = dom.getElementsByTagName("Detail2");
} parentNode = parentNodeList.item(0);
valueXmlString.append( "</Detail2>\r\n" ); childNodeList = parentNode.getChildNodes();
System.out.println("------------------------COMPLETE DESCRIPTION-------------------"); valueXmlString.append("<Detail2>");
break; childNodeListLength = childNodeList.getLength();
} do
} {
} childNode = childNodeList.item(ctr);
catch(Exception e) childNodeName = childNode.getNodeName();
{ ctr ++;
System.out.println( "Exception :invoice amendment :itemChanged(Document,String):" + e.getMessage() + ":" ); }while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) );
throw new ITMException(e); if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
} {
finally columnValue = genericUtility.getColumnValue("tran_id", dom1);
{ valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull(columnValue) ).append( "]]></tran_id>\r\n" );
try valueXmlString.append( "<status_date><![CDATA[" ).append( sdf.format(new java.util.Date()) ).append( "]]></status_date>\r\n" );
{ }
if( conn != null && ! conn.isClosed() ) valueXmlString.append( "</Detail2>\r\n" );
{ System.out.println("------------------------COMPLETE DESCRIPTION-------------------");
if( rs != null ) break;
{ }
rs.close(); }
rs = null; }
} catch(Exception e)
if( pstmt != null ) {
{ System.out.println( "Exception :invoice amendment :itemChanged(Document,String):" + e.getMessage() + ":" );
pstmt.close(); valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) );
pstmt = null; throw new ITMException(e);
} }
finally
conn.close(); {
} try
//System.out.println("------------------------INSIDE FINALLY-------------------"); {
} if( conn != null && ! conn.isClosed() )
catch(Exception e) {
{ if( rs != null )
System.out.println( "Exception :invoice amendment:itemChanged :==>\n"+e.getMessage()); {
throw new ITMException(e); rs.close();
} rs = null;
} }
valueXmlString.append( "</Root>\r\n" ); if( pstmt != null )
System.out.println( "\n****ValueXmlString :" + valueXmlString.toString() + ":********" ); {
return valueXmlString.toString(); pstmt.close();
} pstmt = null;
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception }
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0); conn.close();
}
if( tempNode != null ) //System.out.println("------------------------INSIDE FINALLY-------------------");
{ }
if( tempNode.getFirstChild() == null ) catch(Exception e)
{ {
CDATASection cDataSection = dom.createCDATASection( nodeVal ); System.out.println( "Exception :invoice amendment:itemChanged :==>\n"+e.getMessage());
tempNode.appendChild( cDataSection ); throw new ITMException(e);
} }
else }
{ valueXmlString.append( "</Root>\r\n" );
tempNode.getFirstChild().setNodeValue(nodeVal); System.out.println( "\n****ValueXmlString :" + valueXmlString.toString() + ":********" );
} return valueXmlString.toString();
} }
tempNode = null; private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
} {
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
private String checkNull( String input )
{ if( tempNode != null )
if ( input == null ) {
{ if( tempNode.getFirstChild() == null )
input = ""; {
} CDATASection cDataSection = dom.createCDATASection( nodeVal );
return input; tempNode.appendChild( cDataSection );
} }
else
private String checkDate( String input ) throws ITMException {
{ tempNode.getFirstChild().setNodeValue(nodeVal);
try }
{ }
if(input != null && input.trim().length() > 0 && (! input.trim().equals("null"))) tempNode = null;
{ }
input = GenericUtility.getInstance().getValidDateString(input, getApplDateFormat());
} private String checkNull( String input )
else {
input = ""; if ( input == null )
} {
catch (Exception e) input = "";
{ }
input = ""; return input;
System.out.println("Error in date format at 1283"+e.getMessage()); }
e.printStackTrace();
throw new ITMException(e); private String checkDate( String input ) throws ITMException
{
} try
{
if(input != null && input.trim().length() > 0 && (! input.trim().equals("null")))
return input; {
} input = GenericUtility.getInstance().getValidDateString(input, getApplDateFormat());
}
else
input = "";
}
catch (Exception e)
{
input = "";
System.out.println("Error in date format at 1283"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return input;
}
} }
\ 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