Commit fb9b7a09 authored by smanohar's avatar smanohar

new methods for calculating due_date added, also multiple try... cach block...

new methods for calculating due_date added, also multiple try... cach  block within single method removed and exception thrown at the end

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@210926 ce508802-f39f-4f6c-b175-0d175dae99d5
parent bea8f0bb
......@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.Calendar;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
......@@ -131,8 +132,8 @@ public class FinCommon
}
while (true)
{
try
{
//try
//{
// check for period 000000
sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? "
......@@ -158,23 +159,23 @@ public class FinCommon
rs.close(); rs = null;
pstmt.close(); pstmt = null;
//Modified by Anjali R. on [20/09/2018][End]
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
if (sundrybalCnt == 0)
{
try
{
//try
//{
// add record for period 000000
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, "
......@@ -205,30 +206,30 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count < 1)
{
errCode = "DS000 : Insert Into SUNDRYBAL Failed";
errCode = "DS000NR : Insert Into SUNDRYBAL Failed";
System.out.println("DS000 : Insert Into SUNDRYBAL Failed For Period : " +prdCode);
break;
}
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS INSERTED FOR CURRENT PERIODE.. "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//if
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
......@@ -306,28 +307,28 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count < 1)
{
errCode = "DS000";
errCode = "DS000NR";
System.out.println("DS000 : Update SUNDRYBAL Failed For Period : " +prdCode);
break;
}
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS UPDATED FOR CURRENT PERIODE... "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//else
try
{
//try
//{
if (sundrybalCnt != 0)
{
// check for closing balance
......@@ -346,23 +347,23 @@ public class FinCommon
System.out.println("For Closing Prd : sundrybalCnt : " + sundrybalCnt);
}
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
if (sundrybalCnt == 0 )
{
try
{
//try
//{
// 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, "
......@@ -393,30 +394,30 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count < 1)
{
errCode = "DS000";
errCode = "DS000NR";
System.out.println("DS000 : Insert Into SUNDRYBAL Failed For Period : " +prdCode);
break;
}
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS INSERTED FOR CLOSING PERIODE.. "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//if
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -493,25 +494,25 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count < 1)
{
errCode = "DS000";
errCode = "DS000NR";
System.out.println("DS000 : Update SUNDRYBAL Failed For Period : " +closePrd);
break;
}
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS UPDATED FOR CLOSING PERIODE... "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errCode = se.getMessage();
errCode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errCode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:sundrybalOpnUpd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errCode = se.getMessage();
// errCode = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errCode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//else
break;
}//while
......@@ -639,8 +640,8 @@ public class FinCommon
}
while (true)
{
try
{
//try
//{
// check for current period
sql ="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND "+
"FIN_ENTITY = ? AND SITE_CODE = ? AND ACCT_CODE = ? "+
......@@ -666,21 +667,21 @@ public class FinCommon
pstmt.close(); pstmt = null;
System.out.println("For Period 000000 ll_cnt : " + ll_cnt);
}//try
catch(SQLException se)
{
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
return retString;
}
//}//try
//catch(SQLException se)
//{
// 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
// return retString;
//}
if (ll_cnt == 0 )
{
try
{
//try
//{
// 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,"+
......@@ -706,23 +707,23 @@ public class FinCommon
int cnt = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("INSERTED IN ACCTBAL FOR CURRENT PERIODE : " + cnt);
}//try
catch(SQLException se)
{
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
return retString;
}
//}//try
//catch(SQLException se)
//{
// 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
// return retString;
//}
}
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -790,20 +791,20 @@ public class FinCommon
count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CURRENT) :"+count);
}//try
catch(SQLException se)
{
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
return retString;
}
}
try
{
//}//try
//catch(SQLException se)
//{
// 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
// return retString;
//}
}
//try
//{
if(ll_cnt > 0)
{
// check for closing balance
......@@ -831,18 +832,17 @@ public class FinCommon
System.out.println("For Period zzzzzz ll_cnt : " + ll_cnt);
}
}//try
catch(SQLException se)
{
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
return retString;
}
//}//try
//catch(SQLException se)
//{
// 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
// return retString;
//}
if(ll_cnt == 0)
{
// insert a record for closing balance
......@@ -871,7 +871,7 @@ public class FinCommon
System.out.println("INSERTED IN ACCTBAL FOR CLOSING BALANCE : " + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
}
......@@ -948,7 +948,7 @@ public class FinCommon
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
}
......@@ -967,7 +967,8 @@ public class FinCommon
e.printStackTrace();
}
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
//return retString;
throw new ITMException(se); // 01-nov-2019 manoharan throw all exception
}
catch(Exception e)
{
......@@ -1116,8 +1117,8 @@ public class FinCommon
}
while (true)
{
try
{
//try
//{
sql = "SELECT ACCT_PRD, CODE FROM PERIOD WHERE FR_DATE <= ? AND TO_DATE >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,ld_postdate);
......@@ -1134,21 +1135,22 @@ public class FinCommon
}
pstmt.close(); pstmt = null; // ADDED BY ALKA
rs.close(); rs = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
try
{
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
//
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
//try
//{
// 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 +"' "
......@@ -1166,8 +1168,8 @@ public class FinCommon
pstmt.close(); pstmt = null;
if (ll_cnt == 0 )
{
try
{
//try
//{
// 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, "
......@@ -1200,42 +1202,42 @@ public class FinCommon
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
System.out.println("NO. OF RECORDS INSERTED FOR OPENING PERIODE.. "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
System.out.println("ls_errcode11 28-07-16"+ls_errcode);
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// System.out.println("ls_errcode11 28-07-16"+ls_errcode);
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//if
}//outer try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
System.out.println("ls_errcode12 28-07-16"+ls_errcode);
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
try
{
//}//outer try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// System.out.println("ls_errcode12 28-07-16"+ls_errcode);
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
//try
//{
// 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 +"' "
......@@ -1252,23 +1254,23 @@ public class FinCommon
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
if (ll_cnt == 0 )
{
try
{
//try
//{
// 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, "
......@@ -1301,28 +1303,28 @@ public class FinCommon
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
System.out.println("NO. OF RECORDS INSERTED FOR CURRENT PERIODE.. "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//if
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -1394,26 +1396,26 @@ public class FinCommon
pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
System.out.println("NO. OF RECORDS UPDATED FOR CURRENT PERIODE... "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//else
try
{
//try
//{
// 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 +"' "
......@@ -1430,23 +1432,23 @@ public class FinCommon
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
if (ll_cnt == 0 )
{
try
{
//try
//{
// 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, "
......@@ -1478,7 +1480,7 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
//Added by Varsha V for closing resultset on 19-04-2018
......@@ -1488,25 +1490,25 @@ public class FinCommon
pstmt = null;
}
System.out.println("NO. OF RECORDS INSERTED FOR CLOSING PERIODE.. "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlnstr +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//if
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -1577,7 +1579,7 @@ public class FinCommon
count = pstmt.executeUpdate();
if(count<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
//Added by Varsha V for closing resultset on 19-04-2018
......@@ -1587,19 +1589,19 @@ public class FinCommon
pstmt = null;
}
System.out.println("NO. OF RECORDS UPDATED FOR CLOSING PERIODE... "+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
//Added by poonam on 28-07-16 for exception handling:Start
se.printStackTrace();
//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
return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sqlUpd +se.getMessage());
// //Added by poonam on 28-07-16 for exception handling:Start
// se.printStackTrace();
// //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
// return ls_errcode ;
// //Added by poonam on 28-07-16 for exception handling:End
//}
}//else
break;
}//while
......@@ -1721,8 +1723,8 @@ public class FinCommon
}
while (true)
{
try
{
//try
//{
sql = "SELECT ACCT_PRD, CODE FROM PERIOD WHERE FR_DATE <= ? AND TO_DATE >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,ld_postdate);
......@@ -1746,22 +1748,22 @@ public class FinCommon
pstmt = null;
}
System.out.println("ls_acctprd +++++++++++++++++++++++++ "+ls_acctprd);
}
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
//}
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
// update acctbal
// check for existence of opening balances in acctbal
// insert if not found
try
{
//try
//{
sql="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD ? AND PRD_CODE = ? AND "+
"FIN_ENTITY = ? AND SITE_CODE = ? AND ACCT_CODE = ? "+
"AND CCTR_CODE = ? ";
......@@ -1782,8 +1784,8 @@ public class FinCommon
pstmt.close(); pstmt = null;
if (ll_cnt == 0 )
{
try
{
//try
//{
sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, ACCT_CODE, CCTR_CODE, CR_AMT,DR_AMT,CURR_CODE__AC, "+
"CR_AMT__BASE,DR_AMT__BASE, CHG_DATE,CHG_USER, CHG_TERM,SITE_CODE) "+
"VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
......@@ -1812,31 +1814,31 @@ public class FinCommon
pstmt = null;
}
System.out.println("No of Records Inserted in ACCTBAL : " + cnt);
}
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
}
}//outer try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
try
{
//}
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
}
//}//outer try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
//try
//{
//stmt = conn.createStatement();
// check for current period
sql ="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND "+
......@@ -1859,21 +1861,21 @@ public class FinCommon
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
if (ll_cnt == 0 )
{
try
{
//try
//{
// 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,"+
......@@ -1903,23 +1905,23 @@ public class FinCommon
pstmt = null;
}
System.out.println("INSERTED IN ACCTBAL FOR CURRENT PERIODE : " + cnt);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
}
else
{
try
{
//try
//{
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -1988,20 +1990,20 @@ public class FinCommon
pstmt = null;
}
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CURRENT) :"+count);
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
}
try
{
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
}
//try
//{
// check for closing balance
//Added by Varsha V for closing resultset on 19-04-2018
//stmt = conn.createStatement();
......@@ -2017,21 +2019,21 @@ public class FinCommon
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:gbf_acctbal_upd()[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
return retString;
}
//}//try
//catch(SQLException se)
//{
// System.out.println("SQLException []:gbf_acctbal_upd()[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
// return retString;
//}
if(ll_cnt == 0)
{
// insert a record for closing balance
try{ //poonam
//try{ //poonam
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 ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
......@@ -2061,26 +2063,26 @@ public class FinCommon
System.out.println("INSERTED IN ACCTBAL FOR CLOSING BALANCE : " + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//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
return ls_errcode ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// se.printStackTrace();
// //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
// return ls_errcode ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
else
{
try{ //poonam
//try{ //poonam
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
......@@ -2151,21 +2153,21 @@ public class FinCommon
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
ls_errcode = "DS000NR";
break;
}
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//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
return ls_errcode ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
// se.printStackTrace();
// //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
// return ls_errcode ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
break;
......@@ -2183,7 +2185,8 @@ public class FinCommon
e.printStackTrace();
}
//Ended by Varsha V to change msg descr on 30-04-18
return retString;
//return retString;
throw new ITMException(se);
}
catch(Exception e)
{
......@@ -3002,7 +3005,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isSundryCode(String siteCode, String sundryType, String sundryCode, String refSer, Connection conn)
public String isSundryCode(String siteCode, String sundryType, String sundryCode, String refSer, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -3097,6 +3100,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3131,7 +3135,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isStrgCustomer(String siteCode,String custCode,String refSer, Connection conn)
public String isStrgCustomer(String siteCode,String custCode,String refSer, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -3160,6 +3164,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3195,7 +3200,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isAnalysis(String acctCode, String analCode, String refSer, Connection conn)
public String isAnalysis(String acctCode, String analCode, String refSer, Connection conn) throws ITMException
{
// To check Analysis code in analysis table
PreparedStatement pstmt = null, pstmt1 = null;
......@@ -3262,6 +3267,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3304,7 +3310,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isLoanParty(String siteCode,String loanCode,String refSer, Connection conn)
public String isLoanParty(String siteCode,String loanCode,String refSer, Connection conn)throws ITMException
{
// CHECKING WHETHER LOANPARTY HAS TO BE CHECKED IN SITE TABLE OR NOT
// IF VAR VALUE IN FINPARM IS Y CHECK IN SITE_LOANPARTY AND IF 'N'
......@@ -3358,6 +3364,7 @@ public class FinCommon
errCode = ie.getMessage();
System.out.println("Exception ::"+ ie);
ie.printStackTrace();
throw new ITMException(ie);
}
catch (Exception e)
{
......@@ -3378,7 +3385,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isTaxAuth(String siteCode,String tauthCode,String refSer, Connection conn)
public String isTaxAuth(String siteCode,String tauthCode,String refSer, Connection conn) throws ITMException
{
// CHECKING IN TAX AUTHORITY MASTER
......@@ -3409,6 +3416,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
return errCode;
}
......@@ -3422,7 +3430,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isSupplier(String siteCode,String suppCode,String refSer, Connection conn)
public String isSupplier(String siteCode,String suppCode,String refSer, Connection conn) throws ITMException
{
String errCode = "";
PreparedStatement pstmt = null;
......@@ -3503,6 +3511,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+ e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3537,7 +3546,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isEmployee(String siteCode,String empCode,String refSer, Connection conn)
public String isEmployee(String siteCode,String empCode,String refSer, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -3567,6 +3576,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3601,7 +3611,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isSalesPerson(String siteCode,String spersCode,String refSer, Connection conn)
public String isSalesPerson(String siteCode,String spersCode,String refSer, Connection conn) throws ITMException
{
// CHECKING WHETHER SALES_PERSON HAS TO BE CHECKED IN SITE TABLE OR NOT
// IF VAR VALUE IN DISPARM IS Y CHECK IN SITE_SALES_PERS AND IF 'N'
......@@ -3666,6 +3676,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+ e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3700,7 +3711,7 @@ public class FinCommon
* @return Error code if not valid
* @exception ITMException
*/
public String isAcctType(String acctCode, String sundryCode, String sundryType, Connection conn)
public String isAcctType(String acctCode, String sundryCode, String sundryType, Connection conn) throws ITMException
{
String errCode = null;
PreparedStatement pstmt = null;
......@@ -3760,6 +3771,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+ e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3795,7 +3807,7 @@ public class FinCommon
*/
//Pavan R 17sep19[Changed below method signature to validate tax environment in all transaction]
//public String checkTaxEnvStatus(String taxEnv, Timestamp date, Connection conn)
public String checkTaxEnvStatus(String taxEnv, Timestamp date, String busiType, Connection conn)
public String checkTaxEnvStatus(String taxEnv, Timestamp date, String busiType, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -3857,6 +3869,7 @@ public class FinCommon
errCode = e.getMessage();
System.out.println("Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -3891,7 +3904,7 @@ public class FinCommon
* @return Name or cheque name
* @exception ITMException
*/
public String getChequeName(String sundryType, String sundryCode, String cheque_or_name, Connection conn)
public String getChequeName(String sundryType, String sundryCode, String cheque_or_name, Connection conn) throws ITMException
{
String sName = null, chqName = null, fName = null, mName = null, lName = null;
PreparedStatement pstmt = null;
......@@ -4163,6 +4176,7 @@ public class FinCommon
{
System.out.println("Exception in getChequeName ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -11497,7 +11511,7 @@ public class FinCommon
System.out.println("Tran id for preview>>>****************"+tranId);
System.out.println("CR AMT for preview*****************"+crAmt);
try{
//try{
sql = "insert into "+tableName+" (tran_id, tran_date, eff_date, ref_type, ref_ser," +
"ref_id, fin_entity, site_code, sundry_type," +
"sundry_code, acct_code, cctr_code, curr_code," +
......@@ -11598,20 +11612,20 @@ public class FinCommon
System.out.println("EXCH_RATE :"+exchRate);
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException P []:TRACE()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
System.out.println("errString TRACE(" + errString );
return errString ;
}
// }
// catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException P []:TRACE()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// System.out.println("errString TRACE(" + errString );
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
System.out.println("errString :::: ["+errString+"]["+isPreview+"]");
......@@ -11950,8 +11964,8 @@ public class FinCommon
return errString;
}else if(cnt == 1){
try //added by poonam
{
//try //added by poonam
//{
sql = "update gltran set dr_amt = dr_amt + ? ," +
"cr_amt = cr_amt + ? ," +
"tran_date = ? ," +
......@@ -11984,18 +11998,18 @@ public class FinCommon
pstmt.close();
pstmt = null;
}
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:glTranUpdate()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:glTranUpdate()[Excuting Query Failed]" + sql +se.getMessage());
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
}
......@@ -12029,7 +12043,7 @@ public class FinCommon
tranIdTrace = glTran.get("tran_id__trace").toString().trim();
}
try{ //added by poonam
//try{ //added by poonam
sql = "insert into gltran (tran_id, tran_date, eff_date, ref_ser," +
"ref_id, fin_entity, site_code, acct_code, cctr_code," +
......@@ -12109,19 +12123,19 @@ public class FinCommon
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:glTranUpdate()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:glTranUpdate()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -12142,7 +12156,7 @@ public class FinCommon
pstmt.close();pstmt=null;
if(cnt == 0){
try{ //added by poonam
//try{ //added by poonam
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) " +
......@@ -12170,19 +12184,19 @@ public class FinCommon
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 27-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 27-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
sql = "select count(*) from acctbal where acct_prd = '"+glTran.get("acct_prd").toString()+"' " +
......@@ -12210,7 +12224,7 @@ public class FinCommon
}
if(cnt == 0){
try{ //Added by poonam
//try{ //Added by poonam
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) " +
......@@ -12237,23 +12251,23 @@ public class FinCommon
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}else{
try{ //added by poonam
//try{ //added by poonam
sql = "update acctbal set dr_amt = dr_amt + "+Double.parseDouble(glTran.get("dr_amt").toString())+" ," +
"cr_amt = cr_amt + "+Double.parseDouble(glTran.get("cr_amt").toString())+", " +
......@@ -12269,19 +12283,19 @@ public class FinCommon
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -12301,7 +12315,7 @@ public class FinCommon
pstmt.close(); pstmt=null;
if(cnt == 0){
try{ //added by poonam
//try{ //added by poonam
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) " +
......@@ -12328,23 +12342,23 @@ public class FinCommon
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}else{
try { //Added by poonam
//try { //Added by poonam
sql = "update acctbal set dr_amt = dr_amt + "+Double.parseDouble(glTran.get("dr_amt").toString())+"," +
"cr_amt = cr_amt + "+Double.parseDouble(glTran.get("cr_amt").toString())+"," +
"dr_amt__base = dr_amt__base + "+drAmtBase+"," +
......@@ -12360,19 +12374,19 @@ public class FinCommon
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbf_sundrybal_upd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
}catch(Exception e){
......@@ -13888,7 +13902,7 @@ public class FinCommon
pstmt.close(); pstmt = null;
//amountBc = gf_get_rndamt(lc_amount_bc, ls_rndto, lc_rndoff)
try{ //poonam
//try{ //poonam
sqlTemp = "INSERT INTO BANKTRAN_LOG "
+" (TRAN_ID, BANK_CODE, TRAN_DATE, TRAN_SER, TRAN_NO, REF_NO, REF_DATE, "
+" REF_MODE, AMOUNT, TRAN_TYPE, SITE_CODE, ACCT_CODE, CCTR_CODE, SUNDRY_TYPE, "
......@@ -13924,23 +13938,23 @@ public class FinCommon
{
errCode = "VTBKLOGUPD";
//errString = validator.getErrorString("TRAN_ID",errCode,chgUser);//errCode
errString = itmDBAccessEJB.getErrorString("TRAN_ID",errCode,chgUser,"",conn);
}
//Added by Varsha V for closing resultset on 19-04-2018
pstmt.close();
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:bankTranLogUpdate()[Excuting Query Failed]" + sqlTemp +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
errString = itmDBAccessEJB.getErrorString("TRAN_ID",errCode,chgUser,"",conn);
}
//Added by Varsha V for closing resultset on 19-04-2018
pstmt.close();
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:bankTranLogUpdate()[Excuting Query Failed]" + sqlTemp +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
break;
}
......@@ -14963,7 +14977,7 @@ public class FinCommon
//added by Dadaso Pawar on 15/JUL/2014 [F14CSUN002] [End]
if (acctCode == null) acctCode = "";
if (cctrCode == null) cctrCode = "";
} catch (SQLException e) {
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
......@@ -15348,7 +15362,7 @@ public class FinCommon
payblsTranID = tg.generateTranSeqID("PAYL", "tran_id", keyStr, conn);
System.out.println("Transaction Id Generated for Payables :"+payblsTranID);
try{ //poonam
//try{ //poonam
sql = "INSERT INTO MISC_PAYABLES (TRAN_ID,TRAN_SER,TRAN_DATE,REF_NO,REF_DATE,CURR_CODE,EXCH_RATE,"
+ "SUNDRY_TYPE,SUNDRY_CODE,ACCT_CODE,CCTR_CODE,DUE_DATE,FIN_ENTITY,SITE_CODE,BILL_NO,BILL_DATE,"
+ "TOT_AMT,ADJ_AMT,STATUS,STATUS_DATE,BANK_CODE,AUTO_PAY,PAY_MODE,PAID,ADV_AMT,HOLD_AMT,"
......@@ -15393,19 +15407,19 @@ public class FinCommon
return errString;
}
pstmt.close();pstmt = null;
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbfMiscPayUpd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbfMiscPayUpd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}// end of try
catch(Exception e)
......@@ -15565,7 +15579,7 @@ public class FinCommon
recvTranID = tg.generateTranSeqID("RCVL","tran_id",keyString,conn);
System.out.println("Transaction Id Generated for Receivables :"+recvTranID);
try{ //poonam
//try{ //poonam
sql =" INSERT INTO RECEIVABLES (TRAN_ID,TRAN_SER,TRAN_DATE,REF_NO,REF_DATE,CURR_CODE,EXCH_RATE,"
+" CUST_CODE,ACCT_CODE,CCTR_CODE,DUE_DATE,FIN_ENTITY,SITE_CODE,TOT_AMT,ADJ_AMT,STATUS, "
+" STAT_DATE,DISCOUNT,TAX_AMT,AUTO_RCP,BANK_CODE,RECD,REF_TYPE,CR_TERM,SALES_PERS,ITEM_SER, "
......@@ -15644,19 +15658,19 @@ public class FinCommon
}
pstmt.close();
pstmt =null;
}
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{
System.out.println("SQLException []:gbfReceivablesUpd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18
//errString = se.getMessage();
errString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18
return errString ;
}
//}
//catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
//{
// System.out.println("SQLException []:gbfReceivablesUpd()[Excuting Query Failed]" + sql +se.getMessage());
//
// se.printStackTrace();
// //Modified by Varsha V to change msg descr on 30-04-18
// //errString = se.getMessage();
// errString = getErrorMessage(se, "");
// //Ended by Varsha V to change msg descr on 30-04-18
// return errString ;
//
//}
//Added by poonam on 28-07-16 for exception handling:End
}
......@@ -16779,7 +16793,7 @@ public class FinCommon
//Added by Anjali R. on[30/04/2018][Migrated method gbf_calc_discountdate][End]
//Added by Anjali R. on[30/04/2018][Migrated method gf_bankcharges_calc][Start]
public double getBankChargesCalc(String bankCode,String payMode,java.util.Date date ,double amount,Connection conn)
public double getBankChargesCalc(String bankCode,String payMode,java.util.Date date ,double amount,Connection conn) throws ITMException
{
String sql = "";
PreparedStatement pstmt = null;
......@@ -16906,6 +16920,7 @@ public class FinCommon
{
System.out.println("Exception from getBankChargesCalc--["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -16933,7 +16948,7 @@ public class FinCommon
//Added by Anjali R. on[02/05/2018][Migrated method gbf_payable_at from nvo_business_object_fin component][Start]
public String getPayableAt(String sundryType,String sundryCode,String bankCode,Connection conn)
public String getPayableAt(String sundryType,String sundryCode,String bankCode,Connection conn)throws ITMException
{
String sql = "";
PreparedStatement pstmt = null;
......@@ -17097,6 +17112,7 @@ public class FinCommon
{
System.out.println("Exception from getPayableAt--["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
......@@ -17995,4 +18011,316 @@ public class FinCommon
return acctCode + "," + cctrCode;
}
//Ended by Varsha V on 06-12-18 getAcctDetrtType with site code
// function change by pravin -- fi1fsun001 -- 01/05/12
public Timestamp getDueDate (String crTerm, Timestamp tranDate, Timestamp effDate, Timestamp billDate, Timestamp lrDate, int crDays,Connection conn) throws Exception, ITMException
{
int liDays = 0;
Timestamp ldDate = null,ldDiscDate = null,ldToDate = null;
Timestamp ldDueDate = null,ldTranDate = null,ldTemp = null,ldTempDate = null;
String strStart ="",strOverrideDueDate = "",strTranDate = "",strMonth = "",strMonthOrg = "", sql = "",strCrDays = "";
int liCount = 0,liDatys = 0,liMonth = 0,liMonthOrd = 0,liNextMonth = 0,liCrDays = 0,liMonthOrg = 0,liCurrDays = 0,liDueDays =0;
boolean isResult;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
UtilMethods utlMethods = UtilMethods.getInstance();
sql = "select start_from from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
strStart = rs.getString("start_from");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("R".equals(strStart))
{
ldTranDate = tranDate;
}
else if ("Q".equals(strStart) || "D".equals(strStart))
{
ldTranDate = effDate;
}
else if ("B".equals(strStart))
{
ldTranDate = billDate;
}
else if ("L".equals(strStart))
{
ldTranDate = lrDate;
}
Calendar cal = Calendar.getInstance();
cal.setTime(ldTranDate);
liMonth = cal.get(Calendar.MONTH);
//strTranDate = string(ldTranDate,'MMDD')
//liDatys = day(date(ldTranDate))
//liMonthOrg = liMonth
//liNextMonth = liMonthOrg
if (liMonth == 12 )
{
liMonth = 1;
strMonth = "01";
}
else
{
liMonth = liMonth + 1;
if (liMonth > 9 )
{
strMonth = "" + liMonth;
}
else
{
strMonth = "0"+ liMonth;
}
}
isResult = false;
sql = "select c.cr_days ,d.override_due_date from crterm c,crterm_disc d where c.cr_term = d.cr_term "
+ " and c.cr_term = ? and d.cr_month = ? and d.override_due_date is not null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
pstmt.setString(2, strMonth);
rs = pstmt.executeQuery();
if (rs.next())
{
liDueDays = rs.getInt("cr_days");
strOverrideDueDate = rs.getString("override_due_date");
isResult = true;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (strOverrideDueDate != null && strOverrideDueDate.trim().length() > 0 )
{
strCrDays = strOverrideDueDate.substring(strOverrideDueDate.length() - 2,strOverrideDueDate.length());
liCrDays = Integer.valueOf(strCrDays);
}
else
{
if(!isResult)
{
isResult = false;
sql = "select c.cr_days ,d.override_due_date from crterm c,crterm_disc d where c.cr_term = d.cr_term "
+ " and c.cr_term = ? and d.cr_month='99' and d.override_due_date is not null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
liDueDays = rs.getInt("cr_days");
strOverrideDueDate = rs.getString("override_due_date");
isResult = true;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (isResult)
{
strCrDays = strOverrideDueDate.substring(strOverrideDueDate.length() - 2,strOverrideDueDate.length());
liCrDays = Integer.valueOf(strCrDays);
}
else
{
sql = "select cr_days from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
liDays = rs.getInt("cr_days");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
if (strOverrideDueDate != null && strOverrideDueDate.trim().length() > 0 )
{
sql = "select to_date from period where fr_date <= ? and to_date >= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, ldTranDate);
pstmt.setTimestamp(2, ldTranDate);
rs = pstmt.executeQuery();
if (rs.next())
{
ldToDate = rs.getTimestamp("to_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
liCurrDays= (int) utlMethods.DaysAfter(ldTranDate, ldToDate);
liDays = liCurrDays + liCrDays + liDueDays;
}
if (crDays != -999 )
{
ldDueDate=utlMethods.RelativeDate(ldTranDate, crDays);
}
else
{
ldDueDate=utlMethods.RelativeDate(ldTranDate, liDays);
}
}
catch(Exception e)
{
System.out.println("Exception in getDueDate with siteCode --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e1)
{
System.out.println("Inside catch of finally block--["+e1.getMessage()+"]");
e1.printStackTrace();
throw new ITMException(e1);
}
}
return ldDueDate;
}
public Timestamp CalcDueDateWithHolidays (String crTerm, Timestamp adDueDate, String siteCode,Connection conn) throws Exception, ITMException
{
String adjBankHoliday = "", errCode = "",holTblNo = "",sql = "";
int count = 0;
Timestamp dueDate = null, ldTemp = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
UtilMethods utlMethods = UtilMethods.getInstance();
try
{
sql = "select adj_bank_holiday from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
adjBankHoliday = rs.getString("adj_bank_holiday");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("Y".equals(adjBankHoliday) )
{
sql = "select hol_tblno from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
holTblNo = rs.getString("hol_tblno");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
sql = "select hol_tblno from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
holTblNo = rs.getString("hol_tblno");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
ldTemp = adDueDate;
sql = "select count (*) from holiday where hol_tblno = ? and hol_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo);
pstmt.setTimestamp(2, ldTemp);
rs = pstmt.executeQuery();
while (rs.next())
{
if (rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
if (count> 0)
{
ldTemp = utlMethods.RelativeDate(ldTemp, -1);
}
else
{
adDueDate = ldTemp;
break;
}
}
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in CalcDueDateWithHolidays ["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e1)
{
System.out.println("Inside catch of finally block--["+e1.getMessage()+"]");
e1.printStackTrace();
throw new ITMException(e1);
}
}
return adDueDate;
}
}
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