Commit 8e5b5e26 authored by kshinde's avatar kshinde

Bug fix in VouchPayAct MiscPayAct for req ID[F17KGTP004]

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@181426 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 86245223
......@@ -68,10 +68,12 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
String resString="";
Connection conn = null;
try
{
conn=getConnection();
VouchPayAct vouchpay=new VouchPayAct();
resString=vouchpay.actionPay(tranId, xtraParams, "M_VOUC");
resString=vouchpay.actionPay(tranId, xtraParams, "M-VOUC",conn);
}
catch(Exception e)
......
......@@ -38,9 +38,11 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
String resString="";
Connection conn=null;
try
{
resString = actionPay(tranId,xtraParams,"M-VOUC");
conn = getConnection();
resString = actionPay(tranId,xtraParams,"VOUCH",conn);
}
catch(Exception e)
......@@ -53,15 +55,16 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
return resString;
}
public String actionPay(String tranId,String xtraParams, String VouchType) throws RemoteException , ITMException
public String actionPay(String tranId,String xtraParams, String tranSer,Connection conn) throws RemoteException , ITMException
{
System.out.println("---ActionHandler---@@@@@@@@xtraParams["+xtraParams+"]");
Connection conn = null;
//Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null, rs1 = null, rs2 = null;
String retString = "",errString="";
String conf="",errCode="",payMode="",refNo="";
int refCount=0;
String sql="";
ITMDBAccessEJB itmDBAccessEJB=new ITMDBAccessEJB();
......@@ -74,7 +77,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
FinCommon finCommon = new FinCommon();
Timestamp tranDate=null,billDate=null,dueDate=null,refDate=null,effDate=null,ldDiscountDt=null,ldStartDate=null;
String billNo="",currCode="",acctCode="",cctrCode="",siteCode="",finEntity="",sundryType="",bankCode="",userName="",sundryCode="",tranSer="",
String billNo="",currCode="",acctCode="",cctrCode="",siteCode="",finEntity="",sundryType="",bankCode="",userName="",sundryCode="",tranSerM="",
purcOrder="",pCrTerm="",acctCodeDisc="",cctrCodeDisc="",startFrom="";
double exchRate=0.0d,totAmt=0.0d,advAmt=0.0d,holdAmt=0.0d,netPayable=0.0d,adjAmt=0.0d,lcDiscount=0.0d,lcDiscountAmt=0.0d,payAmt=0.0d,totAmount=0.0d;
E12GenericUtility genericUtility = new E12GenericUtility();
......@@ -82,7 +85,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{
//Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
//conn.setAutoCommit(false);
......@@ -91,10 +94,17 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
//tranId=genericUtility.getColumnValue("tran_id", dom);
System.out.println("TranID["+tranId+"]");
String sql="Select confirmed,pay_mode from misc_voucher where tran_id= ?";
if("M-VOUC".equalsIgnoreCase(tranSer))
{
sql="Select confirmed,pay_mode from misc_voucher where tran_id= ?";
}
else
{
sql="Select confirmed,pay_mode from voucher where tran_id= ?";
}
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
if(rs.next())
{
conf=rs.getString(1);
......@@ -109,9 +119,9 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
sql="select count(1) from misc_paydet where tran_ser= ? and vouch_no= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, VouchType);
pstmt.setString(1, tranSer);
pstmt.setString(2, tranId);
rs=pstmt.executeQuery();
if(rs.next())
{
refCount=rs.getInt(1);
......@@ -128,21 +138,21 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
if(!"Y".equalsIgnoreCase(conf))
{
errCode="VTELMNCNF2";
errString = itmDBAccessEJB.getErrorString("", errCode, "");
errString = itmDBAccessEJB.getErrorString("",errCode, "", "", conn);
return errString;
}
//validation if payment already present
else if(refCount>0)
{
errCode="VTPAYEXIST";
errString = itmDBAccessEJB.getErrorString("", errCode, "");
errString = itmDBAccessEJB.getErrorString("",errCode, "", "", conn);
return errString;
}
//validation if paymode is not Cash
else if(!"C".equalsIgnoreCase(payMode))
{
errCode="VTINMODE";
errString = itmDBAccessEJB.getErrorString("", errCode, "");
errString = itmDBAccessEJB.getErrorString("",errCode, "", "", conn);
return errString;
}
......@@ -163,19 +173,19 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
+ "MISC_PAYABLES.FIN_ENTITY,MISC_PAYABLES.TOT_AMT,MISC_PAYABLES.SUNDRY_TYPE,MISC_PAYABLES.BANK_CODE,"
+ "CASE WHEN MISC_PAYABLES.PAY_MODE IS NULL THEN '' ELSE MISC_PAYABLES.PAY_MODE END as PAY_MODE,MISC_PAYABLES.ADV_AMT,MISC_PAYABLES.TRAN_ID,MISC_PAYABLES.TRAN_SER,MISC_PAYABLES.ADJ_AMT,"
+ "MISC_PAYABLES.HOLD_AMT, fn_confirmed_by(misc_payables.tran_ser, misc_payables.ref_no) as username,"
+ "misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as net_payable"
+ "FROM MISC_PAYABLES WHERE"
+ "misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as net_payable "
+ "FROM MISC_PAYABLES WHERE "
//+ "( misc_payables.sundry_type like '' ) AND"
//+ "( misc_payables.sundry_code like '' ) AND"
+ "( misc_payables.ref_no = ? )"
+ "( misc_payables.ref_no = ? ) "
//+ "(misc_payables.pay_mode like 'C') AND"
//+ "misc_payables.entry_batch_no like ' '"
+ "ORDER BY MISC_PAYABLES.SUNDRY_TYPE ASC,"
+ "ORDER BY MISC_PAYABLES.SUNDRY_TYPE ASC, "
+ "MISC_PAYABLES.SUNDRY_CODE ASC,"
+ "MISC_PAYABLES.REF_NO ASC ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs=pstmt.executeQuery();
if(rs.next())
{
refNo=rs.getString("ref_no");
......@@ -201,8 +211,8 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
userName=rs.getString("username");
netPayable=rs.getDouble("NET_PAYABLE");
sundryCode=rs.getString("sundry_code");
tranSer=rs.getString("tran_ser");
payAmt=rs.getDouble("pay_amt");
tranSerM=rs.getString("tran_ser");
}
pstmt.close();
pstmt=null;
......@@ -213,7 +223,6 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
Timestamp today = new java.sql.Timestamp(System.currentTimeMillis());
sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateFormat());
remarks = "Automatic Payment";
//bank details
......@@ -245,7 +254,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
rs.close();
//calculating discount for Voucher
if("VOUCH".equalsIgnoreCase(VouchType))
if("VOUCH".equalsIgnoreCase(tranSer))
{
sql="select purc_order,eff_date,bill_date from misc_voucher where tran_id = ?";
pstmt = conn.prepareStatement(sql);
......@@ -326,7 +335,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
}
//calculating total amount
totAmount = payAmt - lcDiscountAmt;
totAmount = totAmt - lcDiscountAmt;
System.out.println("Pay Amt : "+payAmt + "Total Amt : "+totAmt);
//09062007 (set currCode bc with Curr Code
......@@ -360,17 +369,21 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[" + sdf.format(today) + "]]></tran_date>");
xmlBuff.append("<tran_type><![CDATA[" + tranType + "]]></tran_type>");
xmlBuff.append("<sundry_code><![CDATA[" + sundryCode + "]]></sundry_type>");
xmlBuff.append("<sundry_code><![CDATA[" + sundryCode + "]]></sundry_code>");
xmlBuff.append("<pay_mode><![CDATA[" + payMode + "]]></pay_mode>");
xmlBuff.append("<ref_date><![CDATA[" + refDate + "]]></ref_date>");
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>");
xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>");
xmlBuff.append("<net_amt__bc><![CDATA[" + totAmount + "]]></net_amt__bc>");
xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>");
xmlBuff.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlBuff.append("<acct_code__bal><![CDATA[" +acctCodeBal + "]]></acct_code__bal>");
xmlBuff.append("<cctr_code__bal><![CDATA[" + cctrCodeBal + "]]></cctr_code__bal>");
xmlBuff.append("<auto_paid><![CDATA["+'Y'+"]]></auto_paid>");
xmlBuff.append("<confirmed><![CDATA["+'N'+ "]]></confirmed>");
xmlBuff.append("<curr_code><![CDATA[" + currCode + "]]></curr_code>");
xmlBuff.append("<acct_code__bc><![CDATA[" + acctCodeBc + "]]></acct_code__bc>");
xmlBuff.append("<bank_code><![CDATA[" + bankCode + "]]></bank_code>");
xmlBuff.append("<exch_rate><![CDATA[" + exchRate + "]]></exch_rate>");
xmlBuff.append("<cctr_code__bc><![CDATA[" + cctrCodeBc + "]]></cctr_code__bc>");
xmlBuff.append("<curr_code__bc><![CDATA[" +currCodeBc + "]]></curr_code__bc>");
xmlBuff.append("<exch_rate__bc><![CDATA[" + exchRate + "]]></exch_rate__bc>");
......@@ -380,14 +393,16 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("</Detail1>");
xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay\" objContext=\"1\">");
xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay\" objContext=\"2\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_ser><![CDATA[" + tranSer + "]]></tran_ser>");
xmlBuff.append("<tran_ser><![CDATA[" + tranSerM+ "]]></tran_ser>");
xmlBuff.append("<vouch_date><![CDATA[" + sdf.format(refDate) + "]]></vouch_date>");
xmlBuff.append("<vouch_no><![CDATA[" + refNo + "]]></vouch_no>");
xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>");
xmlBuff.append("<pay_amt><![CDATA[" + totAmount + "]]></pay_amt>");
xmlBuff.append("<curr_code><![CDATA[" + currCode + "]]></curr_code>");
xmlBuff.append("<exch_rate__vouch><![CDATA[" + exchRate + "]]></exch_rate__vouch>");
xmlBuff.append("<diff_amt__exch><![CDATA[" + 0 + "]]></diff_amt__exch>");
xmlBuff.append("<acct_code__ap><![CDATA[" + acctCode + "]]></acct_code__ap>");
xmlBuff.append("<cctr_code__ap><![CDATA[" + cctrCode + "]]></cctr_code__ap>");
xmlBuff.append("<sundry_type><![CDATA[" + sundryType + "]]></sundry_type>");
......@@ -397,6 +412,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("<line_no><![CDATA[" + 1 + "]]></line_no>");
xmlBuff.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>");
xmlBuff.append("<net_pay_amt><![CDATA[" + totAmount + "]]></net_pay_amt>");
xmlBuff.append("</Detail2>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
......@@ -408,7 +424,8 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
if( retString.indexOf("Success") != -1 || retString==null)
{
return (itmDBAccessEJB.getErrorString("","VOUCHSUCC",""));
conn.commit();
return (itmDBAccessEJB.getErrorString("","VOUCHSUCC", "", "", conn));
}
}
......@@ -441,6 +458,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
}
if( conn != null && ! conn.isClosed() )
{
conn.close();
conn = null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment