Class DunningServiceImpl
java.lang.Object
ch.tocco.nice2.optional.debitor.impl.services.dunning.DunningServiceImpl
- All Implemented Interfaces:
DunningService
-
Constructor Summary
ConstructorDescriptionDunningServiceImpl
(QueryBuilderFactory queryBuilderFactory, LogicCopyService logicCopyService, Context context, CommandExecutor commandExecutor, EntityDefaultValueService entityDefaultValueService, VoucherService voucherService, BusinessUnitManager businessUnitManager, CurrentArticlePriceService currentArticlePriceService) -
Method Summary
Modifier and TypeMethodDescription@Nullable org.joda.time.LocalDate
calculateMaturitydate
(Entity debitor, Optional<Entity> nextDunningLevelStatus, Optional<org.joda.time.LocalDate> fromDateOverride) Calculates the next dunning maturity date.createBalanceDunningVoucher
(Entity voucher, org.joda.time.LocalDate date) Creates a copy of the passed voucher, switches the accounts and sets the appropriate Voucher_type, thereby balancing the vouchervoid
finalizeDunning
(Entity debitor, Optional<Entity> newDunningLevel) Writes the maturity date and dunning level_status of the latest dunning level (attached to the given debitor) to the given debitor@Nullable Entity
getCurrentDunningLevel
(Entity debitor) getCurrentDunningLevelStatus
(Entity debitor) 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@Nullable org.joda.time.LocalDate
getLatestMaturityDate
(Entity debitor) 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.@Nullable Entity
getNextDunningLevelStatus
(Entity debitor) int
getNumberOfPaymentPlanRates
(Entity debitor) @Nullable Entity
getPreviousDunningLevelStatus
(Entity debitor) boolean
isOnHighestDunningLevel
(Entity debitor) boolean
isOnLowestDunningLevel
(Entity debitor) boolean
isOpenOrPartlyBalanced
(Entity debitor) Returns true if the clearing status of the given debitor is open or partly_balancedvoid
lowerDunningLevel
(Entity debitor) lower the dunning level for the givendebitor
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 createdvoid
resetDunningLevel
(Entity debitor) Reset the dunning level of a given debitor to the lowest available dunning levelvoid
riseDunningLevel
(Entity debitor, org.joda.time.LocalDate dunningDate, Optional<org.joda.time.LocalDate> fromDateOverride) Increase dunning level of a given debitor by 1.
-
Constructor Details
-
DunningServiceImpl
public DunningServiceImpl(QueryBuilderFactory queryBuilderFactory, LogicCopyService logicCopyService, Context context, CommandExecutor commandExecutor, EntityDefaultValueService entityDefaultValueService, VoucherService voucherService, BusinessUnitManager businessUnitManager, CurrentArticlePriceService currentArticlePriceService)
-
-
Method Details
-
getMaxDunningLevelStatus
- Specified by:
getMaxDunningLevelStatus
in interfaceDunningService
-
getMinDunningLevelStatus
- Specified by:
getMinDunningLevelStatus
in interfaceDunningService
-
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 interfaceDunningService
-
getLatestMaturityDate
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 interfaceDunningService
-
getNumberOfPaymentPlanRates
- Specified by:
getNumberOfPaymentPlanRates
in interfaceDunningService
-
getNextDunningLevelStatus
- Specified by:
getNextDunningLevelStatus
in interfaceDunningService
-
getPreviousDunningLevelStatus
- Specified by:
getPreviousDunningLevelStatus
in interfaceDunningService
-
getCurrentDunningLevelStatus
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 interfaceDunningService
-
getCurrentDunningLevel
- Specified by:
getCurrentDunningLevel
in interfaceDunningService
-
isOnLowestDunningLevel
- Specified by:
isOnLowestDunningLevel
in interfaceDunningService
-
isOnHighestDunningLevel
- Specified by:
isOnHighestDunningLevel
in interfaceDunningService
-
isOpenOrPartlyBalanced
Description copied from interface:DunningService
Returns true if the clearing status of the given debitor is open or partly_balanced- Specified by:
isOpenOrPartlyBalanced
in interfaceDunningService
- Parameters:
debitor
- the debitor entity to check- Returns:
- true, if id of clearing status is 'open' or 'partly_balanced', false otherwise
-
finalizeDunning
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 interfaceDunningService
-
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 interfaceDunningService
-
lowerDunningLevel
Description copied from interface:DunningService
lower the dunning level for the givendebitor
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 interfaceDunningService
- Parameters:
debitor
- the debitors which shall be lowered
-
createBalanceDunningVoucher
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 interfaceDunningService
-
resetDunningLevel
Description copied from interface:DunningService
Reset the dunning level of a given debitor to the lowest available dunning level- Specified by:
resetDunningLevel
in interfaceDunningService
-