Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BudgetCategory |
|
| 1.0;1 |
1 | /* | |
2 | * Created on Jul 30, 2007 by wyatt | |
3 | */ | |
4 | package org.homeunix.thecave.buddi.model; | |
5 | ||
6 | import java.util.Date; | |
7 | import java.util.List; | |
8 | ||
9 | import org.homeunix.thecave.buddi.plugin.api.exception.InvalidValueException; | |
10 | ||
11 | public interface BudgetCategory extends Source, Expandable { | |
12 | ||
13 | /** | |
14 | * Returns the budgeted amount associated with this given budget category, for | |
15 | * the date in which the given period date exists. | |
16 | * @param periodDate | |
17 | * @return | |
18 | */ | |
19 | public long getAmount(Date periodDate); | |
20 | ||
21 | /** | |
22 | * Returns the budgeted amount associated with this budget category, over | |
23 | * the given date range. If the start and / or end dates do not fall exactly | |
24 | * on a budget period, then we calculate how much of the budget period | |
25 | * is contained. | |
26 | * | |
27 | * For instance, assume that we pass in April 15 and July 20 as the dates, and that | |
28 | * the associated budget category type is 'Monthly'. Assume that for April we have | |
29 | * budgeted $100, for May and June we have budgeted $200 each, and for July we have | |
30 | * budgeted $300. | |
31 | * | |
32 | * To find the final amount, we will add $50 (15 days / 30 days for April * $100) | |
33 | * and $200 (May) and $200 (June) and $193 (20 days / 31 days for July * $300), for a | |
34 | * total of $643. | |
35 | * | |
36 | * If you pass in the start date as the first day in the period, and the end day | |
37 | * as the last day, you will get back the same number as if you called getAmount(Date) | |
38 | * with a day in the same budget period. | |
39 | * @param startDate | |
40 | * @param endDate | |
41 | * @return | |
42 | */ | |
43 | public long getAmount(Date startDate, Date endDate); | |
44 | ||
45 | /** | |
46 | * Returns the Budget Period type. One of the values in Enum BudgePeriodKeys. | |
47 | * @return | |
48 | */ | |
49 | public BudgetCategoryType getBudgetPeriodType(); | |
50 | ||
51 | /** | |
52 | * Returns the parent budget category | |
53 | * @return | |
54 | */ | |
55 | public BudgetCategory getParent(); | |
56 | ||
57 | /** | |
58 | * Returns a list of children for this budget category. The contents of this list | |
59 | * will include only children which match the current preferences for deleted items. | |
60 | * This means that if the user has specified to only show non-deleted sources, we | |
61 | * will not return deleted children here. To get a list of all children, regardles | |
62 | * of deleted state, use the getAllChildren() method. | |
63 | * @return | |
64 | */ | |
65 | public List<BudgetCategory> getChildren(); | |
66 | ||
67 | /** | |
68 | * Returns a list of all children for this budget category, inluding deleted ones. | |
69 | * @return | |
70 | */ | |
71 | public List<BudgetCategory> getAllChildren(); | |
72 | ||
73 | /** | |
74 | * Does this budget category represent an income category? | |
75 | * @return | |
76 | */ | |
77 | public boolean isIncome(); | |
78 | ||
79 | /** | |
80 | * Sets the budgeted amount for the given time period. | |
81 | * @param periodDate | |
82 | * @param amount | |
83 | */ | |
84 | public void setAmount(Date periodDate, long amount) throws InvalidValueException; | |
85 | ||
86 | /** | |
87 | * Sets the income flag on this budget category | |
88 | * @param income | |
89 | * @throws InvalidValueException | |
90 | */ | |
91 | public void setIncome(boolean income) throws InvalidValueException; | |
92 | ||
93 | /** | |
94 | * Sets the parent for this budget category. | |
95 | * @param parent | |
96 | * @throws InvalidValueException | |
97 | */ | |
98 | public void setParent(BudgetCategory parent) throws InvalidValueException; | |
99 | ||
100 | /** | |
101 | * Sets the Budget Period type. | |
102 | * @param periodType | |
103 | */ | |
104 | public void setPeriodType(BudgetCategoryType periodType) throws InvalidValueException; | |
105 | ||
106 | /** | |
107 | * Returns a list of all dates for this budget period which have budget information | |
108 | * set for them. We basically look at the budget backing map, and return all keys for | |
109 | * non-zero values. | |
110 | * @return | |
111 | */ | |
112 | public List<Date> getBudgetedDates(); | |
113 | } |