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 Details

    • add

      <T extends AccountancyEntry> T add​(T accountancyEntry)
      Adds a new AccountancyEntry to this Accountancy. The AccountancyEntry's date will be set to the value returned by BusinessTime.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

      Returns all AccountancyEntrys 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.
      Parameters:
      clazz - Class object corresponding to the type of the entries to be returned, has to implement AccountancyEntry
      Returns:
      a Streamable containing all entries of type clazz
    • get

      Optional<AccountancyEntry> get​(AccountancyEntryIdentifier accountancyEntryIdentifier)
      Returns the AccountancyEntry of type clazz and all sub-types, identified by AccountancyEntryIdentifier. null is returned, if no entry with the given identifier exists.
      Parameters:
      clazz - type of the entry to be returned; has to implement AccountancyEntry
      accountancyEntryIdentifier - the AccountancyEntryIdentifier of the entry to be returned
      Returns:
      the AccountancyEntry or sub type thereof of type clazz which has the identifier AccountancyEntryIdentifier
    • find

      Streamable<AccountancyEntry> find​(Interval interval)
      Returns all AccountancyEntrys that were created in the given Interval. 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 Streamable is returned.
      Parameters:
      interval - the Interval we want to find AccountancyEntry instances for.
      Returns:
      a Streamable containing all entries in the given Interval.
    • find

      Map<Interval,​Streamable<AccountancyEntry>> find​(Interval interval, TemporalAmount duration)
      Returns all AccountancyEntrys which have their date within the given Interval. The Interval is divided into parts of length of the given Duration. According to their respective date, entries are sorted in exactly one of the time intervals. The last time interval may be shorter than the given Duration. Returned is a map, having a Interval objects as its key, and an Streamable as value. The Streamable 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 implement 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 divided
      Returns:
      a map, with intervals of period length between from and to as keys, and as value an Iterable containing all entries within the key- Interval
    • salesVolume

      Map<Interval,​javax.money.MonetaryAmount> salesVolume​(Interval interval, TemporalAmount duration)
      Returns the sum of the field amount of all AccountancyEntrys which have their date within (including) from and to.
      The time between 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.
      Returned is a map, having a Interval objects as its key, and a MonetaryAmount as value. The MonetaryAmount 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 MonetaryAmount object with a value of zero is added as value for that interval.
      Parameters:
      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 divided.
      Returns:
      a Map, with intervals of period length between from and to as keys, and as value a MonetaryAmount object, equal to the sum of the amount fields of all entries within the key- Interval.