Class Budget
java.lang.Object
com.infinitekind.moneydance.model.MoneydanceSyncableItem
com.infinitekind.moneydance.model.Budget
- All Implemented Interfaces:
com.infinitekind.tiksync.SyncableItem
public final class Budget extends MoneydanceSyncableItem
Represents one item in a budget
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Budget.CalculationResults
Holds the results of a budget calculation, including totals for income and expenses separately, and for multiple date ranges. -
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SYNCABLE_TYPE_VALUE
Fields inherited from class com.infinitekind.moneydance.model.MoneydanceSyncableItem
book, info, SECURITY_SUBTYPES_ITEM_TYPE
-
Constructor Summary
Constructors Constructor Description Budget(AccountBook book)
Construct a new budget in the context of the given account.Budget(AccountBook book, java.lang.String key, StreamTable infoTable)
-
Method Summary
Modifier and Type Method Description void
addBudgetListener(BudgetListener listener)
Budget.CalculationResults
calculate(int startDate, int endDate, boolean showAllCategories, boolean showZeroes)
Compute budgeted and actual values based upon a single date range, for this budget.Budget.CalculationResults
calculate(DateRange[] intervals, boolean showAllCategories, boolean showZeroes)
Compute budgeted and actual values based upon a series of graph intervals, for this budget.Budget.CalculationResults
calculate(DateRange[] intervals, boolean showAllCategories, boolean showZeroes, boolean rollupUnbudgetedCats)
Compute budgeted and actual values based upon a series of graph intervals, for this budget.static Budget.CalculationResults
calculate(DateRange[] dateRanges, AccountBook book, java.util.List<BudgetItem> items, boolean showAllCategories, boolean showZeroes)
Compute budgeted and actual amounts, store them in an object that can be used by various clients including the report, dashboard, and budget bars.static Budget.CalculationResults
calculate(DateRange[] dateRanges, AccountBook book, java.util.List<BudgetItem> items, boolean showAllCategories, boolean showZeroes, boolean rollupUnbudgetedCats)
Compute budgeted and actual amounts, store them in an object that can be used by various clients including the report, dashboard, and budget bars.boolean
containsDate(int dateInt)
Determine if this budget contains any items that span the date given.BudgetItem
createItem()
Create a new item, add it to the list, and return itboolean
deleteItem()
Deletes this item and writes a remove-item entry to the syncing system.Budget
duplicateAsNew(java.lang.String newBudgetName)
Make a new budget with the same items as this one and the given namejava.util.List<BudgetItem>
getAllItems()
BudgetList
getBudgetList()
Return the list that contains this budgetstatic int
getIntervalIdx(DateRange[] intervals, int date)
Given a date range list and a date, find the index of the date range in which the date belongs.BudgetItemList
getItemList()
java.lang.String
getKey()
Return the unique key needed to identify this budget for storagejava.lang.String
getName()
Get the name of this budgetPeriodType
getPeriodType()
java.lang.String
getSyncItemType()
Subclasses should override this to return a static string identifying their type of objectboolean
isModified()
boolean
isNewStyle()
protected void
itemWasUpdated()
Load the list of budget items from the underlying table.void
removeBudgetListener(BudgetListener listener)
void
setBudgetInfo(Budget budget)
Copies the information from the given budget into this budget.void
setModified()
void
setName(java.lang.String newName)
Set the name for this budgetvoid
setPeriodType(PeriodType periodType)
java.lang.String
toString()
Return the string representation of this budgetMethods inherited from class com.infinitekind.moneydance.model.MoneydanceSyncableItem
addParameters, addTags, autoSyncsChanges, decodeKeywordList, doesParameterExist, duplicate, encodeKeywordList, equals, getAccountParameter, getAddress, getAddressParameter, getBook, getBooleanParameter, getCurrencyParameter, getCurrencyParameter, getCurrencyParameter, getDoubleParameter, getIntParameter, getKeywords, getLongParameter, getOriginalItem, getParameter, getParameter, getParameterCount, getParameterKeys, getPreference, getPreferenceBoolean, getPreferenceDouble, getPreferenceInt, getPreferenceIntArray, getPreferenceLong, getPreferenceStringList, getPreferenceSublist, getPreferenceSubset, getStringListParameter, getSyncInfo, getSyncTimestamp, getUUID, hasBeenSynced, hashCode, hasKeywordSubstring, initialize, isInEditingMode, isSyncable, itemWasUpdated, itemWillSync, itemWillSync, makeSyncableItem, removeParameter, setAccountParameter, setAddress, setAddressParameter, setCurrencyParameter, setCurrencyParameter, setCurrencyParameter, setDirty, setEditingMode, setKeywords, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameterNoNotify, setPreference, setPreference, setPreference, syncItem
-
Field Details
-
SYNCABLE_TYPE_VALUE
public static final java.lang.String SYNCABLE_TYPE_VALUE- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
getSyncItemType
public final java.lang.String getSyncItemType()Description copied from class:MoneydanceSyncableItem
Subclasses should override this to return a static string identifying their type of object- Specified by:
getSyncItemType
in interfacecom.infinitekind.tiksync.SyncableItem
- Overrides:
getSyncItemType
in classMoneydanceSyncableItem
-
itemWasUpdated
protected void itemWasUpdated()Load the list of budget items from the underlying table.- Overrides:
itemWasUpdated
in classMoneydanceSyncableItem
-
duplicateAsNew
Make a new budget with the same items as this one and the given name -
setModified
public void setModified() -
isModified
public boolean isModified() -
addBudgetListener
-
removeBudgetListener
-
setBudgetInfo
Copies the information from the given budget into this budget. This is most useful for applying changes from a "working copy" of a budget. A working copy can be obtained by calling cloneBudget(). -
getAllItems
-
deleteItem
public boolean deleteItem()Deletes this item and writes a remove-item entry to the syncing system. Use with caution!- Overrides:
deleteItem
in classMoneydanceSyncableItem
-
containsDate
public boolean containsDate(int dateInt)Determine if this budget contains any items that span the date given.- Parameters:
dateInt
- The date to test.- Returns:
- True if any item spans the date, false otherwise.
-
getKey
public final java.lang.String getKey()Return the unique key needed to identify this budget for storage -
getBudgetList
Return the list that contains this budget -
getName
public java.lang.String getName()Get the name of this budget -
setName
public void setName(java.lang.String newName)Set the name for this budget -
createItem
Create a new item, add it to the list, and return it -
getItemList
-
toString
public java.lang.String toString()Return the string representation of this budget- Overrides:
toString
in classjava.lang.Object
-
calculate
public Budget.CalculationResults calculate(DateRange[] intervals, boolean showAllCategories, boolean showZeroes)Compute budgeted and actual values based upon a series of graph intervals, for this budget.- Parameters:
intervals
- Graphing/reporting intervals representing a series of date ranges.showAllCategories
- True if all categories, including unbudgeted ones, are to be shown.showZeroes
- True if budget items with no spending and no budgeted amount are to be included.- Returns:
- Object containing the budget results, including actual and budgeted values.
-
calculate
public Budget.CalculationResults calculate(DateRange[] intervals, boolean showAllCategories, boolean showZeroes, boolean rollupUnbudgetedCats)Compute budgeted and actual values based upon a series of graph intervals, for this budget.- Parameters:
intervals
- Graphing/reporting intervals representing a series of date ranges.showAllCategories
- True if all categories, including unbudgeted ones, are to be shown.showZeroes
- True if budget items with no spending and no budgeted amount are to be included.- Returns:
- Object containing the budget results, including actual and budgeted values.
-
calculate
public Budget.CalculationResults calculate(int startDate, int endDate, boolean showAllCategories, boolean showZeroes)Compute budgeted and actual values based upon a single date range, for this budget.- Parameters:
startDate
- Starting date to include.endDate
- Ending date to include.showAllCategories
- True if all categories, including unbudgeted ones, are to be shown.showZeroes
- True if budget items with no spending and no budgeted amount are to be included.- Returns:
- Object containing the budget results, including actual and budgeted values.
-
calculate
public static Budget.CalculationResults calculate(DateRange[] dateRanges, AccountBook book, java.util.List<BudgetItem> items, boolean showAllCategories, boolean showZeroes)Compute budgeted and actual amounts, store them in an object that can be used by various clients including the report, dashboard, and budget bars.- Parameters:
dateRanges
- List of date ranges to compute actual and budgeted for.book
- AccountBook containing the main dadtaset.items
- List of budget items to compute with.showAllCategories
- True if all categories, including unbudgeted ones, are to be shown.showZeroes
- True if budget items with no spending and no budgeted amount are to be included.- Returns:
- Object containing the budget results, including actual and budgeted values.
-
calculate
public static Budget.CalculationResults calculate(DateRange[] dateRanges, AccountBook book, java.util.List<BudgetItem> items, boolean showAllCategories, boolean showZeroes, boolean rollupUnbudgetedCats)Compute budgeted and actual amounts, store them in an object that can be used by various clients including the report, dashboard, and budget bars.- Parameters:
dateRanges
- List of date ranges to compute actual and budgeted for.book
- AccountBook containing the main dadtaset.items
- List of budget items to compute with.showAllCategories
- True if all categories, including unbudgeted ones, are to be shown.showZeroes
- True if budget items with no spending and no budgeted amount are to be included.rollupUnbudgetedCats
- Whether or not to rollup unbudgeted category amonts into parent.- Returns:
- Object containing the budget results, including actual and budgeted values.
-
getIntervalIdx
Given a date range list and a date, find the index of the date range in which the date belongs.- Parameters:
intervals
- A list of date intervals.date
- The date to find.- Returns:
- An index into the date range list, or -1 if it doesn't fit in any of the ranges.
-
isNewStyle
public boolean isNewStyle() -
setPeriodType
-
getPeriodType
-