Commit 7c6148a4 authored by tmahadi's avatar tmahadi

Changes in Ecollection Module.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104176 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 972939a9
[Dolphin] [Dolphin]
HeaderColumnWidths=335,74,146
SortOrder=1 SortOrder=1
SortRole=date SortRole=date
Timestamp=2016,6,10,11,5,29 Timestamp=2016,12,12,18,55,2
Version=3 Version=3
ViewMode=1 ViewMode=1
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import org.w3c.dom.Document;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless @Stateless
public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal,EcollectionPostSaveRemote { public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal, EcollectionPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{ public String postSave(String xmlString, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException {
System.out.println("------------ postSave method called-----------------EcollectionPostSave : "); System.out.println("------------ postSave method called-----------------EcollectionPostSave : ");
System.out.println("tranId111--->>["+tranId+"]"); System.out.println("tranId111--->>[" + tranId + "]");
System.out.println("xml String--->>["+xmlString+"]"); System.out.println("xml String--->>[" + xmlString + "]");
Document dom = null; Document dom = null;
String errString=""; String errString = "";
try {
try if (xmlString != null && xmlString.trim().length() > 0) {
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString); dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn); errString = postSave(dom, tranId, xtraParams, conn);
}
} }
catch(Exception e) } catch (Exception e) {
{ System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n" + e.getMessage());
System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return errString; return errString;
} }
public String postSave(Document dom,String tranId,String xtraParams,Connection conn)
{ public String postSave(Document dom, String tranId, String xtraParams, Connection conn) {
System.out.println("in EcollectionPostSave tran_id---->>["+tranId+"]"); System.out.println("in EcollectionPostSave tran_id---->>[" + tranId + "]");
ResultSet rs=null; ResultSet rs = null;
PreparedStatement pstmt=null; PreparedStatement pstmt = null;
String sql="",errorString=""; String sql = "", errorString = "", custCode = "", siteCode = "", errCode = "";
double rcpamt=0; double rcpAmt = 0, chqAmt = 0, rcpamtSum = 0, rcpAmtT = 0, rcpAmtNew = 0, rcpAmtStatus = 0;
double rcpamtSum=0; int count = 0;
int count=0;
try try {
{ // GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
tranId = genericUtility.getColumnValue("tran_id",dom); String userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tranId--->>["+tranId+"]"); tranId = genericUtility.getColumnValue("tran_id", dom);
chqAmt = Double.parseDouble(genericUtility.getColumnValue("chq_amt", dom, "1"));
custCode = genericUtility.getColumnValue("cust_code", dom, "1");
siteCode = genericUtility.getColumnValue("site_code", dom, "1");
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmt = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtNew>>>[" + rcpAmtNew + "]rcpAmt[" + rcpAmt + "]");
// Start added by chandr shekar on 21-mar-2016
sql = "select nvl(sum(rcpdet.rcp_amt), 0) as amt from rcpdet_form rcpdet, receipt_form rcpform "
+ "where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? "
+ "and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? "
+ "AND rcpform.cust_code = ? and rcpform.site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmtStatus = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtStatus>>>" + rcpAmtStatus);
// End added by chandrashekar on 21-mar-2016
if (rcpAmt - rcpAmtStatus < rcpAmtNew) {
errCode = "VTINVTLAMT";
errorString = getErrorString("", errCode, userId);
return errorString;
}
sql = "SELECT rcp_amt FROM RCPDET_FORM WHERE tran_id = ? "; if(isChqAmtGreater(dom, chqAmt)){
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
System.out.println("tranId--->>[" + tranId + "]");
sql = "SELECT NVL(SUM(RCP_AMT), 0) FROM RCPDET_FORM WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while( rs.next() ) while (rs.next()) {
{
count++; count++;
rcpamt=rs.getDouble(1); rcpAmtT = rs.getDouble(1);
rcpamtSum=rcpamtSum+rcpamt; rcpamtSum = rcpamtSum + rcpAmtT;
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("rcpamtSum>>>>>>>>" + rcpamtSum);
System.out.println("rcpamtSum>>>>>>>>"+rcpamtSum); if(chqAmt > rcpamtSum) {
System.out.println("count>>>>>>>>"+count); System.out.println("Receipt Amount is Less... :)");
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
System.out.println("count>>>>>>>>" + count);
if(count >0) /*if (count > 0) {
{ sql = "update receipt_form set chq_amt = ? where tran_id = ?";
sql="update receipt_form set chq_amt = ? where tran_id = ?"; pstmt = conn.prepareStatement(sql);
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, rcpamtSum); pstmt.setDouble(1, rcpamtSum);
pstmt.setString(2, tranId); pstmt.setString(2, tranId);
count=pstmt.executeUpdate(); count = pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]"); System.out.println("post count---->>[" + count + "]");
if(count >0 ) if (count > 0) {
{
conn.commit(); conn.commit();
} }
}else } else {
{
conn.rollback(); conn.rollback();
} }*/
} } catch (Exception e) {
catch(Exception e) System.out.println("Exception : EcollectionPostSave -->["
{ + e.getMessage() + "]");
System.out.println("Exception : EcollectionPostSave -->["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
try try {
{
conn.rollback(); conn.rollback();
} } catch (Exception e1) {
catch(Exception e1) System.out
{ .println("Exception while rollbacking transaction....");
System.out.println("Exception while rollbacking transaction....");
e1.printStackTrace(); e1.printStackTrace();
} }
} }
return errorString; return errorString;
} }
private String checkNull(String columnValue) {
return columnValue == null ? "" : columnValue;
}
private boolean isChqAmtGreater(Document dom, double chqAmt) {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String lineNoDom = "", rcpAmtSt = "";
boolean ischqAmtGreater = false;
double chqAmtMeth = 0.0, chqAmtSum = 0.0;
String refNoDom = "", refSerDom = "";
System.out.println("---inside ischqAmtGreater--");
try {
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
parentNode = parentList.item(prntCtr - 1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++) {
childNode = childList.item(ctr);
System.out.println("childNode>>>" + childNode);
if (childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) {
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>" + updateFlag);
if (updateFlag.equalsIgnoreCase("D")) {
System.out.println("Break from here as the record is deleted");
break;
}
}
if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("rcp_amt")) {
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) {
try {
chqAmtMeth = Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n) {
chqAmtMeth = 0;
}
}
}
}
chqAmtSum = chqAmtSum + chqAmtMeth;
}// for loop
System.out.println("chqAmtSum>>>[" + chqAmtSum + "] : chqAmt>>>>[" + chqAmt + "]");
if (chqAmt < chqAmtSum) {
ischqAmtGreater = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("ischqAmtGreater>>>>>> [" + ischqAmtGreater + "]");
return ischqAmtGreater;
}
} }
[Dolphin] [Dolphin]
HeaderColumnWidths=328,70,146
SortOrder=1 SortOrder=1
SortRole=date SortRole=date
Sorting=2 Sorting=2
Timestamp=2016,6,10,11,6,27 Timestamp=2016,12,12,18,55,58
Version=3 Version=3
ViewMode=1 ViewMode=1
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