Commit edbb5168 authored by arawankar's avatar arawankar

FinCommon.java

-Locking implemented in fincommon ,as suggested by Manoharan sir.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194445 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d45aea93
......@@ -53,9 +53,20 @@ public class FinCommon
double advAmount = 0.0;
double crAmtBase = 0.0;
double drAmtBase = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try
{
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
......@@ -207,6 +218,62 @@ public class FinCommon
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
......@@ -339,6 +406,61 @@ public class FinCommon
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
......@@ -436,9 +558,25 @@ public class FinCommon
double lc_cramt_b = 0;
double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmDbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try
{
System.out.println("Inside acctbalOpnUpd...."+acctbalMap.toString());
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmDbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code");
String acctVar_finentity = (String)acctbalMap.get("fin_entity");
......@@ -450,14 +588,14 @@ public class FinCommon
String userId = (String)acctbalMap.get("user_id");
String acctPrd = (String)acctbalMap.get("acct_prd");
String chgTerm = (String)acctbalMap.get("chg_term"); //Added by poonam on 28-07-16 for chg_term from map
System.out.println("chgTerm in sundrybalOpnUpd"+chgTerm);
if(chgTerm == null || chgTerm.trim().length() == 0)
{
chgTerm = "SYSTEM" ;
}
if (acctVar_cctrcode == null)
{
acctVar_cctrcode = " ";
......@@ -494,8 +632,8 @@ public class FinCommon
{
// check for current period
sql ="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE ='"+prdCode+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE ='"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' "+
"AND CCTR_CODE ='"+acctVar_cctrcode+"'";
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE ='"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' "+
"AND CCTR_CODE ='"+acctVar_cctrcode+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next())
......@@ -504,7 +642,7 @@ public class FinCommon
}
rs.close(); rs = null;
stmt.close(); stmt = null;
System.out.println("For Period 000000 ll_cnt : " + ll_cnt);
}//try
catch(SQLException se)
......@@ -514,7 +652,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage();
retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
}
if (ll_cnt == 0 )
......@@ -523,9 +661,9 @@ public class FinCommon
{
// add record for current period
sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,"+
"ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+
"DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM) "+
"VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
"ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+
"DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM) "+
"VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctPrd);
pstmt.setString(2,prdCode);
......@@ -551,11 +689,11 @@ public class FinCommon
{
System.out.println("SQLException []:acctbalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage();
retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
}
}
......@@ -563,11 +701,61 @@ public class FinCommon
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt);
pstmt.setDouble(2,acctVar_cramt);
......@@ -588,7 +776,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage();
retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
}
}
......@@ -598,7 +786,7 @@ public class FinCommon
{
// check for closing balance
sql="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"'AND PRD_CODE ='"+closePrd+"' AND "+
" FIN_ENTITY ='"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
" FIN_ENTITY ='"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
System.out.println("Closing count sql [" + sql + "]");
System.out.println("Closing acctPrd [" + acctPrd + "]");
......@@ -615,7 +803,7 @@ public class FinCommon
}
rs.close(); rs = null;
stmt.close(); stmt = null;
System.out.println("For Period zzzzzz ll_cnt : " + ll_cnt);
}
}//try
......@@ -627,15 +815,15 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage();
retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
}
if(ll_cnt == 0)
{
// insert a record for closing balance
sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+
" DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM)"+
" VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
" DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM)"+
" VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctPrd);
pstmt.setString(2,closePrd);
......@@ -656,19 +844,70 @@ public class FinCommon
int cnt = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("INSERTED IN ACCTBAL FOR CLOSING BALANCE : " + cnt);
if(cnt<1)
{
if(cnt<1)
{
ls_errcode = "DS000";
break;
}
}
}
else
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt);
......@@ -681,8 +920,8 @@ public class FinCommon
pstmt.setString(7,chgTerm); //Changed by poonam on 28-07-16 for chg_term from map
int cnt = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
break;
......@@ -702,7 +941,7 @@ public class FinCommon
} catch (RemoteException e) {
e.printStackTrace();
}
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
}
catch(Exception e)
......@@ -718,7 +957,7 @@ public class FinCommon
try
{
acctbalMap.clear();
// ADDED BY ALKA
// ADDED BY ALKA
if (rs != null)
{
rs.close(); rs = null;
......@@ -727,7 +966,7 @@ public class FinCommon
{
pstmt.close(); pstmt = null;
}
// END ADDED BY ALKA
// END ADDED BY ALKA
}
catch(Exception e)
{
......@@ -737,7 +976,7 @@ public class FinCommon
return retString;
}
}
return retString;
return retString;
}//acctbalOpnUpd()
/**
......@@ -775,8 +1014,21 @@ public class FinCommon
double lc_cramt_b = 0.0;
double lc_dramt_b = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try
{
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
......@@ -802,7 +1054,7 @@ public class FinCommon
if(ls_cctr_upd.trim().equals("NULLFOUND"))
{
ls_errcode = "VSENVAR1";
return (ls_errcode);
return (ls_errcode);
}
else if((!ls_cctr_upd.trim().equalsIgnoreCase("Y")) && (!ls_cctr_upd.trim().equalsIgnoreCase("N")))
{
......@@ -848,7 +1100,7 @@ public class FinCommon
rs = pstmt.executeQuery();
if(!rs.next())
{ ls_errcode = "VMDATANF";
break;
break;
}
else
{
......@@ -866,7 +1118,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -874,9 +1126,9 @@ public class FinCommon
{
// look for opening balance record
sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_openprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_openprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
rs = stmt.executeQuery(sql);
if (rs.next())
......@@ -891,9 +1143,9 @@ public class FinCommon
{
// add record for opening balance
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd);
......@@ -920,10 +1172,10 @@ public class FinCommon
count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
{
ls_errcode = "DS000";
break;
}
}
System.out.println("NO. OF RECORDS INSERTED FOR OPENING PERIODE.. "+count);
}//try
catch(SQLException se)
......@@ -934,7 +1186,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
System.out.println("ls_errcode11 28-07-16"+ls_errcode);
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
......@@ -949,7 +1201,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
System.out.println("ls_errcode12 28-07-16"+ls_errcode);
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
......@@ -959,9 +1211,9 @@ public class FinCommon
{
// check for current period
sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08
rs = stmt.executeQuery(sql);
......@@ -980,7 +1232,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -990,11 +1242,11 @@ public class FinCommon
{
// add record for current period
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr);
pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd);
pstmt.setString(2,ls_prdcode);
pstmt.setString(3,ls_finentity);
......@@ -1019,10 +1271,10 @@ public class FinCommon
count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
{
ls_errcode = "DS000";
break;
}
}
System.out.println("NO. OF RECORDS INSERTED FOR CURRENT PERIODE.. "+count);
}//try
catch(SQLException se)
......@@ -1033,7 +1285,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -1042,13 +1294,61 @@ public class FinCommon
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
pstmt = conn.prepareStatement(sqlUpd);
pstmt.setDouble(1,lc_cramt);
......@@ -1064,10 +1364,10 @@ public class FinCommon
count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
{
ls_errcode = "DS000";
break;
}
}
System.out.println("NO. OF RECORDS UPDATED FOR CURRENT PERIODE... "+count);
}//try
catch(SQLException se)
......@@ -1078,7 +1378,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -1087,9 +1387,9 @@ public class FinCommon
{
// check for closing balance
sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08
rs = stmt.executeQuery(sql);
......@@ -1108,7 +1408,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -1118,11 +1418,11 @@ public class FinCommon
{
// add record for closing period
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr);
pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd);
pstmt.setString(2,ls_closeprd);
pstmt.setString(3,ls_finentity);
......@@ -1146,11 +1446,11 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count<1)
{
{
ls_errcode = "DS000";
break;
}
//Added by Varsha V for closing resultset on 19-04-2018
}
//Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null)
{
pstmt.close();
......@@ -1166,22 +1466,71 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
}//if
else
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_closeprd);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
pstmt = conn.prepareStatement(sqlUpd);
pstmt.setDouble(1,lc_cramt);
......@@ -1196,11 +1545,11 @@ public class FinCommon
pstmt.setString(8,chgTerm);//Added by poonam on 28-07-16 for chg_term from map
count = pstmt.executeUpdate();
if(count<1)
{
{
ls_errcode = "DS000";
break;
}
//Added by Varsha V for closing resultset on 19-04-2018
}
//Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null)
{
pstmt.close();
......@@ -1216,7 +1565,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
//Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -1287,9 +1636,23 @@ public class FinCommon
double ll_cnt = 0;
double lc_cramt_b = 0;
double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmdbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try
{
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmdbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("Inside acctbalMap......"+acctbalMap.toString());
stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code");
......@@ -1506,8 +1869,59 @@ public class FinCommon
}
else
{
try
{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_prdcode+"' AND "+
......@@ -1617,29 +2031,79 @@ public class FinCommon
else
{
try{ //poonam
// update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt);
pstmt.setDouble(2,acctVar_cramt);
pstmt.setDouble(3,lc_dramt_base);
pstmt.setDouble(4,lc_cramt_base);
int cnt = pstmt.executeUpdate();
//Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
break;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_closeprd);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt);
pstmt.setDouble(2,acctVar_cramt);
pstmt.setDouble(3,lc_dramt_base);
pstmt.setDouble(4,lc_cramt_base);
int cnt = pstmt.executeUpdate();
//Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
break;
}
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
......@@ -2054,8 +2518,8 @@ public class FinCommon
if(!"NULLFOUND".equalsIgnoreCase(var_value))
{
//Modified by Anjali R. on[21/09/2018][End]
//Modified by Anjali R. on[21/09/2018][End]
if(var_value.equals("Y"))
{
sql ="SELECT STD_EXRT FROM CURRENCY WHERE CURR_CODE = '"+as_curr_code.trim()+"'";
......@@ -2065,7 +2529,7 @@ public class FinCommon
{
lc_exch_rate = rs1.getDouble(1);
}
// stmt.close(); stmt = null;
// stmt.close(); stmt = null;
rs1.close(); rs1 = null;
}
else
......
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