@Service @Transactional class PersistentAccountancy<T extends AccountancyEntry> extends Object implements Accountancy<T>
AccountancyEntry
s.Constructor and Description |
---|
PersistentAccountancy(BusinessTime businessTime,
AccountancyEntryRepository<T> repository)
|
Modifier and Type | Method and Description |
---|---|
T |
add(T accountancyEntry)
Adds a new
AccountancyEntry to this Accountancy . |
Iterable<T> |
find(LocalDateTime from,
LocalDateTime to)
Returns all
AccountancyEntry s in between the dates from and to of the specified class type
clazz and all sub-types, including from and to. |
Map<Interval,Iterable<T>> |
find(LocalDateTime from,
LocalDateTime to,
Duration duration)
Returns all
AccountancyEntry s of type clazz and all sub-types, which have their date within
(including) from and to . |
Iterable<T> |
findAll()
Returns all
AccountancyEntry s of the specified type clazz and all sub-types, previously added to
the accountancy. |
Optional<T> |
get(AccountancyEntryIdentifier accountancyEntryIdentifier)
Returns the
AccountancyEntry of type clazz and all sub-types, identified by
AccountancyEntryIdentifier . |
Map<Interval,org.joda.money.Money> |
salesVolume(LocalDateTime from,
LocalDateTime to,
Duration period)
Returns the sum of the field
amount of all AccountancyEntry s of type clazz and its
sub-types, which have their date within (including) from and to . |
@Autowired public PersistentAccountancy(BusinessTime businessTime, AccountancyEntryRepository<T> repository)
businessTime
- must not be null.repository
- must not be null.public final T add(T accountancyEntry)
Accountancy
AccountancyEntry
to this Accountancy
.add
in interface Accountancy<T extends AccountancyEntry>
accountancyEntry
- entry to be added to the accountancypublic final Optional<T> get(AccountancyEntryIdentifier accountancyEntryIdentifier)
Accountancy
AccountancyEntry
of type clazz
and all sub-types, identified by
AccountancyEntryIdentifier
. null is returned, if no entry with the given identifier exists.get
in interface Accountancy<T extends AccountancyEntry>
accountancyEntryIdentifier
- the AccountancyEntryIdentifier
of the entry to be returnedAccountancyEntry
or sub type thereof of type clazz
which has the identifier
AccountancyEntryIdentifier
public final Iterable<T> findAll()
Accountancy
AccountancyEntry
s of the specified type clazz
and all sub-types, previously added to
the accountancy. If no entries of the specified type exist, an empty Iterable
is returned.findAll
in interface Accountancy<T extends AccountancyEntry>
Iterable
containing all entries of type clazzpublic final Iterable<T> find(LocalDateTime from, LocalDateTime to)
Accountancy
AccountancyEntry
s in between the dates from
and to
of the specified class type
clazz
and all sub-types, including from and to. 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 empty Iterable is returned.find
in interface Accountancy<T extends AccountancyEntry>
from
- LocalDateTime
denoting the start of the requested time periodto
- LocalDateTime
denoting the end of the requested time periodIterable
containing all entries between from and to of type Epublic final Map<Interval,Iterable<T>> find(LocalDateTime from, LocalDateTime to, Duration duration)
Accountancy
AccountancyEntry
s of type clazz
and all sub-types, which have their date
within
(including) from
and to
. from
and to
is divided into parts of period
length. According to their
respective date, entries are sorted in exactly one of the time intervals. The last time interval may be shorter
than period
.Interval
objects as its key, and an Iterable
as value. The
Iterable
contains all entries of the specific type with its date in the interval specified by the key.Iterable
.find
in interface Accountancy<T extends AccountancyEntry>
from
- all returned entries will have a time stamp after from
to
- all returned entries will have a time stamp before to
duration
- length of the time intervals, the period between from
and to
is dividedperiod
length between from
and to
as keys, and as value an
Iterable
containing all entries within the key- Interval
public final Map<Interval,org.joda.money.Money> salesVolume(LocalDateTime from, LocalDateTime to, Duration period)
Accountancy
amount
of all AccountancyEntry
s of type clazz
and its
sub-types, which have their date
within (including) from
and to
. from
and to
is divided into parts of period
length. According to their
time stamp, entries are sorted in exactly one of the time intervals. The last time interval may be shorter than
period
.Interval
objects as its key, and an Money
as value. The Money
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, a Money
object with a value
of zero is added as value for that interval.salesVolume
in interface Accountancy<T extends AccountancyEntry>
from
- all returned entries will have a time stamp after from
.to
- all returned entries will have a time stamp before to
.period
- length of the time intervals, the period between from
and to
is divided.Map
, with intervals of period
length between from
and to
as keys, and as
value a Money
object, equal to the sum of the amount fields of all entries within the key-
Interval
.Copyright © 2014 Pivotal Software, Inc.. All rights reserved.