KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > report > FinReportPeriod


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.report;
15
16 import java.sql.*;
17 import java.util.*;
18
19 import org.compiere.util.*;
20
21 /**
22  * Financial Report Periods
23  *
24  * @author Jorg Janke
25  * @version $Id: FinReportPeriod.java,v 1.3 2003/02/11 06:22:10 jjanke Exp $
26  */

27 public class FinReportPeriod
28 {
29     /**
30      * Constructor
31      * @param C_Period_ID period
32      * @param Name name
33      * @param StartDate period start date
34      * @param EndDate period end date
35      * @param YearStartDate year start date
36     */

37     public FinReportPeriod (int C_Period_ID, String JavaDoc Name, Timestamp StartDate, Timestamp EndDate,
38         Timestamp YearStartDate)
39     {
40         m_C_Period_ID = C_Period_ID;
41         m_Name = Name;
42         m_StartDate = StartDate;
43         m_EndDate = EndDate;
44         m_YearStartDate = YearStartDate;
45     } //
46

47     private int m_C_Period_ID;
48     private String JavaDoc m_Name;
49     private Timestamp m_StartDate;
50     private Timestamp m_EndDate;
51     private Timestamp m_YearStartDate;
52
53
54     /**
55      * Get Period Balance
56      * @return BETWEEN start AND end
57      */

58     public String JavaDoc getPeriodBalanceWhere ()
59     {
60         StringBuffer JavaDoc sql = new StringBuffer JavaDoc ("BETWEEN ");
61         sql.append(DB.TO_DATE(m_StartDate))
62             .append(" AND ")
63             .append(DB.TO_DATE(m_EndDate));
64         return sql.toString();
65     } // getPeriodBalanceWhere
66

67     /**
68      * Get Year Balance
69      * @return BETWEEN start AND end
70      */

71     public String JavaDoc getYearBalanceWhere ()
72     {
73         StringBuffer JavaDoc sql = new StringBuffer JavaDoc ("BETWEEN ");
74         sql.append(DB.TO_DATE(m_YearStartDate))
75               .append(" AND ")
76               .append(DB.TO_DATE(m_EndDate));
77         return sql.toString();
78     } // getPeriodBalanceWhere
79

80     /**
81      * Get Total Balance
82      * @return <= end
83      */

84     public String JavaDoc getTotalBalanceWhere ()
85     {
86         StringBuffer JavaDoc sql = new StringBuffer JavaDoc ("<= ");
87         sql.append(DB.TO_DATE(m_EndDate));
88         return sql.toString();
89     } // getPeriodBalanceWhere
90

91     /**
92      * Is date in period
93      * @param date date
94      * @return true if in period
95      */

96     public boolean inPeriod (Timestamp date)
97     {
98         if (date == null)
99             return false;
100         if (date.before(m_StartDate))
101             return false;
102         if (date.after(m_EndDate))
103             return false;
104         return true;
105     } // inPeriod
106

107
108     public int getC_Period_ID()
109     {
110         return m_C_Period_ID;
111     }
112     public Timestamp getEndDate()
113     {
114         return m_EndDate;
115     }
116     public String JavaDoc getName()
117     {
118         return m_Name;
119     }
120     public Timestamp getStartDate()
121     {
122         return m_StartDate;
123     }
124     public Timestamp getYearStartDate()
125     {
126         return m_YearStartDate;
127     }
128
129 } // FinReportPeriod
130
Popular Tags