Class DunningServiceImpl

java.lang.Object
ch.tocco.nice2.optional.debitor.impl.services.dunning.DunningServiceImpl
All Implemented Interfaces:
DunningService

public class DunningServiceImpl extends Object implements DunningService
  • Constructor Details

  • Method Details

    • getMaxDunningLevelStatus

      public Entity getMaxDunningLevelStatus()
      Specified by:
      getMaxDunningLevelStatus in interface DunningService
    • getMinDunningLevelStatus

      public Entity getMinDunningLevelStatus()
      Specified by:
      getMinDunningLevelStatus in interface DunningService
    • calculateMaturitydate

      @Nullable public @Nullable org.joda.time.LocalDate calculateMaturitydate(Entity debitor, Optional<Entity> nextDunningLevelStatus, Optional<org.joda.time.LocalDate> fromDateOverride)
      Description copied from interface: DunningService
      Calculates the next dunning maturity date. Uses either the given optional fromDateOverride or the return value of getLatestMaturityDate as base and adds the maturity_in_days of the next dunning level status. If no next dunning level status is selectable (e.g. the highest dunning level status is already selected) null is returned.
      Specified by:
      calculateMaturitydate in interface DunningService
    • getLatestMaturityDate

      @Nullable public @Nullable org.joda.time.LocalDate getLatestMaturityDate(Entity debitor)
      Description copied from interface: DunningService
      Returns the latest maturity date of a given debitor - if the current Dunning_level_status.level is higher then the current dunning_level_status.level, the maturity date of the current dunning_level_status is returned - if the current Dunnint_level_status.level equals the lowest Dunning_level_status.level (e.g. "Zahlungsfrist"), either the debitors maturity date or the debitors rate maturity date is returned, depending on the quantity of rates (relPayment_schedule.quantity). If more than one rate is planned, the rate maturity date is used, else the debitors maturity date is returned.
      Specified by:
      getLatestMaturityDate in interface DunningService
    • getNumberOfPaymentPlanRates

      public int getNumberOfPaymentPlanRates(Entity debitor)
      Specified by:
      getNumberOfPaymentPlanRates in interface DunningService
    • getNextDunningLevelStatus

      @Nullable public @Nullable Entity getNextDunningLevelStatus(Entity debitor)
      Specified by:
      getNextDunningLevelStatus in interface DunningService
    • getPreviousDunningLevelStatus

      @Nullable public @Nullable Entity getPreviousDunningLevelStatus(Entity debitor)
      Specified by:
      getPreviousDunningLevelStatus in interface DunningService
    • getCurrentDunningLevelStatus

      public Entity getCurrentDunningLevelStatus(Entity debitor)
      Description copied from interface: DunningService
      Gets the status of the highest dunning level of a given debitor If no dunning level is attached to this debitor, the lowest available dunning level status is returned
      Specified by:
      getCurrentDunningLevelStatus in interface DunningService
    • getCurrentDunningLevel

      @Nullable public @Nullable Entity getCurrentDunningLevel(Entity debitor)
      Specified by:
      getCurrentDunningLevel in interface DunningService
    • isOnLowestDunningLevel

      public boolean isOnLowestDunningLevel(Entity debitor)
      Specified by:
      isOnLowestDunningLevel in interface DunningService
    • isOnHighestDunningLevel

      public boolean isOnHighestDunningLevel(Entity debitor)
      Specified by:
      isOnHighestDunningLevel in interface DunningService
    • isOpenOrPartlyBalanced

      public boolean isOpenOrPartlyBalanced(Entity debitor)
      Description copied from interface: DunningService
      Returns true if the clearing status of the given debitor is open or partly_balanced
      Specified by:
      isOpenOrPartlyBalanced in interface DunningService
      Parameters:
      debitor - the debitor entity to check
      Returns:
      true, if id of clearing status is 'open' or 'partly_balanced', false otherwise
    • finalizeDunning

      public void finalizeDunning(Entity debitor, Optional<Entity> newDunningLevel)
      Description copied from interface: DunningService
      Writes the maturity date and dunning level_status of the latest dunning level (attached to the given debitor) to the given debitor
      Specified by:
      finalizeDunning in interface DunningService
    • riseDunningLevel

      public void riseDunningLevel(Entity debitor, org.joda.time.LocalDate dunningDate, Optional<org.joda.time.LocalDate> fromDateOverride)
      Description copied from interface: DunningService
      Increase dunning level of a given debitor by 1. Do nothing if the debitor already is at the highest dunning level The maturitydate is calculated as follows:

       1. If fromDateOverride is set: fromDateOverride + nextDunningLevelStatus.maturity_in_days
       2. If fromDateOverride is not set: latestMaturityDate of Debitor + nextDunningLevelStatus.maturity_in_days
       
      Specified by:
      riseDunningLevel in interface DunningService
    • lowerDunningLevel

      public void lowerDunningLevel(Entity debitor)
      Description copied from interface: DunningService
      lower the dunning level for the given debitor if the current dunning level of the debitor has dunning vouchers which are not exported the dunning vouchers will be deleted if the current dunning level of the debitor has dunning vouchers which are exported balance dunning vouchers will be created
      Specified by:
      lowerDunningLevel in interface DunningService
      Parameters:
      debitor - the debitors which shall be lowered
    • createBalanceDunningVoucher

      public Entity createBalanceDunningVoucher(Entity voucher, org.joda.time.LocalDate date)
      Description copied from interface: DunningService
      Creates a copy of the passed voucher, switches the accounts and sets the appropriate Voucher_type, thereby balancing the voucher
      Specified by:
      createBalanceDunningVoucher in interface DunningService
    • resetDunningLevel

      public void resetDunningLevel(Entity debitor)
      Description copied from interface: DunningService
      Reset the dunning level of a given debitor to the lowest available dunning level
      Specified by:
      resetDunningLevel in interface DunningService