Skip to content
Snippets Groups Projects
Commit 9a091abf authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Premium waiver: apply shifted time to child blocks

parent 5b196100
Branches
Tags
No related merge requests found
...@@ -544,10 +544,22 @@ InsuranceContract = R6Class( ...@@ -544,10 +544,22 @@ InsuranceContract = R6Class(
} }
if (!is.null(self$blocks)) { if (!is.null(self$blocks)) {
for (b in self$blocks) { for (b in self$blocks) {
.args = as.list(match.call()[-1]) #
# correctly shift the valuesFrom by each block's blockStart parameter # .args = as.list(match.call()[-1])
.args$valuesFrom = max(0, .args$valuesFrom - b$Parameters$ContractData$blockStart) # # correctly shift the valuesFrom by each block's blockStart parameter
do.call(b$calculateContract, .args) # .args$valuesFrom = max(0, .args$valuesFrom - b$Parameters$ContractData$blockStart)
# do.call(b$calculateContract, .args)
#
b$calculateContract(
calculate = calculate,
valuesFrom = max(0, valuesFrom - b$Parameters$ContractData$blockStart),
premiumCalculationTime = max(0, premiumCalculationTime - b$Parameters$ContractData$blockStart),
preservePastPV = preservePastPV,
additionalCapital = additionalCapital,
recalculatePremiums = recalculatePremiums,
recalculatePremiumSum = recalculatePremiumSum,
history_comment = history_comment,
history_type = history_type)
} }
} }
self$Values$int = private$determineInternalValues() self$Values$int = private$determineInternalValues()
...@@ -775,19 +787,26 @@ InsuranceContract = R6Class( ...@@ -775,19 +787,26 @@ InsuranceContract = R6Class(
#' \code{sumInsured} is adjusted according to the existing reserves. #' \code{sumInsured} is adjusted according to the existing reserves.
#' #'
#' @param t Time of the premium waiver. #' @param t Time of the premium waiver.
#' @param ... Further parameters (currently unused)
#' #'
#' @examples #' @examples
#' # TODO #' # TODO
premiumWaiver = function(t) { premiumWaiver = function(t, ...) {
if (getOption('LIC.debug.premiumWaiver', FALSE)) { if (getOption('LIC.debug.premiumWaiver', FALSE)) {
browser(); browser();
} }
newSumInsured = self$Values$reserves[[toString(t), "PremiumFreeSumInsured"]]; if (length(self$blocks) > 0) {
for (b in self$blocks) {
b$premiumWaiver(t - b$Parameters$ContractData$blockStart, ...)
}
} else {
newSumInsured = self$Values$reserves[[toString(t), "PremiumFreeSumInsured"]];
self$Parameters$ContractData$sumInsured = newSumInsured;
}
self$Parameters$ContractState$premiumWaiver = TRUE; self$Parameters$ContractState$premiumWaiver = TRUE;
self$Parameters$ContractState$surrenderPenalty = FALSE; # Surrender penalty has already been applied, don't apply a second time self$Parameters$ContractState$surrenderPenalty = FALSE; # Surrender penalty has already been applied, don't apply a second time
self$Parameters$ContractState$alphaRefunded = TRUE; # Alpha cost (if applicable) have already been refunded partially, don't refund again self$Parameters$ContractState$alphaRefunded = TRUE; # Alpha cost (if applicable) have already been refunded partially, don't refund again
# TODO: Extract current amount of premium refund and feed that into the calculateContract function...
self$Parameters$ContractData$sumInsured = newSumInsured;
self$calculateContract( self$calculateContract(
valuesFrom = t, valuesFrom = t,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment