Commit ca6b02ba authored by pdas's avatar pdas

Request Id-F14ISUN012

Calculation of Due Date With Holidays.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97281 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f2355195
......@@ -2,17 +2,14 @@ package ibase.webitm.ejb.fin;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import java.sql.*;
import java.text.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.HashMap;
import java.util.Date;
import javax.naming.InitialContext;
import org.w3c.dom.*;
......@@ -1863,9 +1860,196 @@ public class CreatePoRcpVoucher
catch(Exception e)
{
throw new ITMException(e);
}
}
/*String as_cr_term;
Date ad_due_date;
Connection conn;
String dueDate = calcDueDate_with_holidays(as_cr_term,ad_due_date,conn);*/
return begPart + mainMsg + "</message><description>" + subMsg + endDesc;
}
public Timestamp calcDueDateWithHolidays(String AsCrTerm, String siteCode, Timestamp adDueDate, Connection conn) throws ITMException
{
UtilMethods utilMethods = UtilMethods.getInstance();
String adjBankHoliday = null;
String merrcode = " ";
String lsHolTblno = "";
long llcnt = 0;
try
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
// Timestamp ad_due_date = null;
sql = "select adj_bank_holiday from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, AsCrTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
adjBankHoliday = rs.getString("adj_bank_holiday");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("Y".equalsIgnoreCase(adjBankHoliday)) {
sql = "select hol_tblno from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, AsCrTerm);
rs = pstmt.executeQuery();
if (rs.next()) {
lsHolTblno = 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()) {
lsHolTblno = rs.getString("hol_tblno");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
while(true)
{
sql = "select count (*) cnt from holiday where where hol_tblno = ? and hol_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsHolTblno);
pstmt.setTimestamp(2, adDueDate);
rs = pstmt.executeQuery();
if (rs.next()) {
llcnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (llcnt > 0) {
adDueDate = utilMethods.RelativeDate((adDueDate), (-1));
} else {
break;
}
}
return adDueDate;
}
catch(Exception e)
{
throw new ITMException(e);
}
}
//public String calcDueDate_with_holidays (String as_cr_term, String ad_due_date, Connection conn) throws ITMException
/*public String calcDueDate_with_holidays(String as_cr_term, Date ad_due_date, Connection conn) throws ITMException
{
String adjBankHoliday=null;
String merrcode=" ";
String ls_hol_tblno ="";
long ll_cnt=0;
java.sql.Timestamp ld_duedate;
PreparedStatement pstmt = null;
ResultSet rs = null;
java.sql.Timestamp ad_dueDate = null;
String sql = "";
//Timestamp ad_due_date = null;
try
{
sql ="select adj_bank_holiday from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, as_cr_term);
rs = pstmt.executeQuery();
if(rs.next())
{
ad_due_date= rs.getTimestamp("ad_due_date");
String adj_bank_holiday= rs.getString("adj_bank_holiday");
adjBankHoliday = rs.getString("ls_adj_bank_holiday");
merrcode= rs.getString("merrcode");
ls_hol_tblno= rs.getString("ls_hol_tblno");
if("Y".equalsIgnoreCase(adjBankHoliday))
{
sql="select hol_tblno from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, as_cr_term);
rs = pstmt.executeQuery();
}
else
{
sql="select hol_tblno from site where site_code =?";
String hol_tblno= rs.getString("hol_tblno");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, as_cr_term);
rs = pstmt.executeQuery();
}
do
{
int ll_count;
sql="select count (*) from holiday where hol_tblno=ls_hol_tblno and hol_date =ad_due_date";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, ll_count);
rs = pstmt.executeQuery();
if(ll_count>0)
{
ad_due_date = datetime(relativedate(date(ad_due_date),(-1));
}
}
while
{
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
merrcode="DS000";
return merrcode;
}
catch(Exception e)
{
throw new ITMException(e);
}
return ""+ad_due_date;
}*/
public java.sql.Timestamp calcDueDate(String crTerm, java.sql.Timestamp recDate, java.sql.Timestamp effDate, java.sql.Timestamp billDate, Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment