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 TypeMethodDescription<T extends AccountancyEntry>
Tadd
(T accountancyEntry) Adds a newAccountancyEntry
to thisAccountancy
.Returns allAccountancyEntry
s that were created in the givenInterval
.find
(Interval interval, TemporalAmount duration) findAll()
Returns allAccountancyEntry
s of the specified typeclazz
and all sub-types, previously added to the accountancy.get
(AccountancyEntry.AccountancyEntryIdentifier accountancyEntryIdentifier) Returns theAccountancyEntry
of typeclazz
and all sub-types, identified byAccountancyEntry.AccountancyEntryIdentifier
.salesVolume
(Interval interval, TemporalAmount duration) Returns the sum of the fieldamount
of allAccountancyEntry
s which have theirdate
within (including)from
andto
.
-
Method Details
-
add
Adds a newAccountancyEntry
to 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 allAccountancyEntry
s of the specified typeclazz
and all sub-types, previously added to the accountancy. If no entries of the specified type exist, an emptyIterable
is returned.- Parameters:
clazz
- Class object corresponding to the type of the entries to be returned, has to implementAccountancyEntry
- Returns:
- a
Streamable
containing all entries of type clazz
-
get
Optional<AccountancyEntry> get(AccountancyEntry.AccountancyEntryIdentifier accountancyEntryIdentifier) Returns theAccountancyEntry
of typeclazz
and all sub-types, identified byAccountancyEntry.AccountancyEntryIdentifier
. null is returned, if no entry with the given identifier exists.- Parameters:
clazz
- type of the entry to be returned; has to implementAccountancyEntry
accountancyEntryIdentifier
- theAccountancyEntry.AccountancyEntryIdentifier
of the entry to be returned- Returns:
- the
AccountancyEntry
or sub type thereof of typeclazz
which has the identifierAccountancyEntry.AccountancyEntryIdentifier
-
find
Returns allAccountancyEntry
s that were created in the givenInterval
. So every entry with an time stamp <=to
and >=from
is returned. If no entries within the specified time span exist, or no entries of the specified class type exist, an emptyStreamable
is returned.- Parameters:
interval
- theInterval
we want to findAccountancyEntry
instances for.- Returns:
- a
Streamable
containing all entries in the givenInterval
.
-
find
Returns allAccountancyEntry
s which have theirdate
within the givenInterval
. TheInterval
is 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 aInterval
objects as its key, and anStreamable
as value. TheStreamable
contains 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 implementAccountancyEntry
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 betweenfrom
andto
is divided- Returns:
- a map, with intervals of
period
length betweenfrom
andto
as keys, and as value anIterable
containing all entries within the key-Interval
-
salesVolume
Returns the sum of the fieldamount
of allAccountancyEntry
s which have theirdate
within (including)from
andto
.
The time betweenfrom
andto
is divided into parts ofperiod
length. 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 aInterval
objects as its key, and aMonetaryAmount
as value. TheMonetaryAmount
object'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, aMonetaryAmount
object 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 betweenfrom
andto
is divided.- Returns:
- a
Map
, with intervals ofperiod
length betweenfrom
andto
as keys, and as value aMonetaryAmount
object, equal to the sum of the amount fields of all entries within the key-Interval
.
-