Interface Accountancy
@Service public interface Accountancy
The
Accountancy interface is implemented by classes offering a basic accounting service. Generally, an
Accountancy aggregates objects of the type AccountancyEntry and subclasses thereof. Additionally, an
Accountancy offers methods for querying of entries and financial statistics.- Author:
- Hannes Weisbach, Oliver Gierke
-
Method Summary
Modifier and Type Method Description <T extends AccountancyEntry>
Tadd(T accountancyEntry)Adds a newAccountancyEntryto thisAccountancy.Streamable<AccountancyEntry>find(Interval interval)Returns allAccountancyEntrys that were created in the givenInterval.Map<Interval,Streamable<AccountancyEntry>>find(Interval interval, TemporalAmount duration)Streamable<AccountancyEntry>findAll()Returns allAccountancyEntrys of the specified typeclazzand all sub-types, previously added to the accountancy.Optional<AccountancyEntry>get(AccountancyEntryIdentifier accountancyEntryIdentifier)Returns theAccountancyEntryof typeclazzand all sub-types, identified byAccountancyEntryIdentifier.Map<Interval,javax.money.MonetaryAmount>salesVolume(Interval interval, TemporalAmount duration)Returns the sum of the fieldamountof allAccountancyEntrys which have theirdatewithin (including)fromandto.
-
Method Details
-
add
Adds a newAccountancyEntryto thisAccountancy. TheAccountancyEntry's date will be set to the value returned byBusinessTime.getTime()in case it is not set already.- Parameters:
accountancyEntry- entry to be added to the accountancy, must not be null.- Returns:
- the added
AccountancyEntry.
-
findAll
Streamable<AccountancyEntry> findAll()Returns allAccountancyEntrys of the specified typeclazzand all sub-types, previously added to the accountancy. If no entries of the specified type exist, an emptyIterableis returned.- Parameters:
clazz- Class object corresponding to the type of the entries to be returned, has to implementAccountancyEntry- Returns:
- a
Streamablecontaining all entries of type clazz
-
get
Returns theAccountancyEntryof typeclazzand all sub-types, identified byAccountancyEntryIdentifier. null is returned, if no entry with the given identifier exists.- Parameters:
clazz- type of the entry to be returned; has to implementAccountancyEntryaccountancyEntryIdentifier- theAccountancyEntryIdentifierof the entry to be returned- Returns:
- the
AccountancyEntryor sub type thereof of typeclazzwhich has the identifierAccountancyEntryIdentifier
-
find
Returns allAccountancyEntrys that were created in the givenInterval. So every entry with an time stamp <=toand >=fromis returned. If no entries within the specified time span exist, or no entries of the specified class type exist, an emptyStreamableis returned.- Parameters:
interval- theIntervalwe want to findAccountancyEntryinstances for.- Returns:
- a
Streamablecontaining all entries in the givenInterval.
-
find
Returns allAccountancyEntrys which have theirdatewithin the givenInterval. TheIntervalis divided into parts of length of the givenDuration. According to their respective date, entries are sorted in exactly one of the time intervals. The last time interval may be shorter than the givenDuration. Returned is a map, having aIntervalobjects as its key, and anStreamableas value. TheStreamablecontains all entries of the specific type with its date in the interval specified by the key.- Type Parameters:
T- common super type of all entries returned- Parameters:
clazz- class type of the requested entries; has to implementAccountancyEntryfrom- all returned entries will have a time stamp afterfromto- all returned entries will have a time stamp beforetoduration- length of the time intervals, the period betweenfromandtois divided- Returns:
- a map, with intervals of
periodlength betweenfromandtoas keys, and as value anIterablecontaining all entries within the key-Interval
-
salesVolume
Returns the sum of the fieldamountof allAccountancyEntrys which have theirdatewithin (including)fromandto.
The time betweenfromandtois divided into parts ofperiodlength. According to their time stamp, entries are sorted in exactly one of the time intervals. The last time interval may be shorter thanperiod.
Returned is a map, having aIntervalobjects as its key, and aMonetaryAmountas value. TheMonetaryAmountobject's value is equal to the sum of all entries'amount-field, with a date within the key-Interval. If within an interval no entries of the specified type exist, aMonetaryAmountobject with a value of zero is added as value for that interval.- Parameters:
from- all returned entries will have a time stamp afterfrom.to- all returned entries will have a time stamp beforeto.duration- length of the time intervals, the period betweenfromandtois divided.- Returns:
- a
Map, with intervals ofperiodlength betweenfromandtoas keys, and as value aMonetaryAmountobject, equal to the sum of the amount fields of all entries within the key-Interval.
-