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

addBlock: Clean up code, generalize history entry, make sure we have a proper default for t

parent f960dd48
Branches
Tags
No related merge requests found
......@@ -381,7 +381,7 @@ InsuranceContract = R6Class(
#'
#' @examples
#' # TODO
addBlock = function(id = NULL, block = NULL, t = block$Values$int$blockStart, comment = paste0("Additional block at time t=", t), ...) {
addBlock = function(id = NULL, block = NULL, t = block$Values$int$blockStart, comment = paste0("Additional block at time t=", t), blockType = "Dynamics", ...) {
if (getOption('LIC.debug.addBlock', FALSE)) {
browser();
}
......@@ -389,6 +389,9 @@ InsuranceContract = R6Class(
# Create a block with the same tariff and parameters as the main contract, but allow overriding params with the ... arguments
block = InsuranceContract$new(id = id, ...)
}
if (missing(t) || is.null(t)) {
t = 0
}
# declare as child of 'self', store the time offset to the parent contract
block$parent = self
block$Parameters$ContractData$blockStart = t
......@@ -408,7 +411,7 @@ InsuranceContract = R6Class(
self$consolidateBlocks(valuesFrom = t)
self$addHistorySnapshot(time = t, comment = comment,
type = "Dynamics", params = self$Parameters, values = self$Values);
type = blockType, params = self$Parameters, values = self$Values);
invisible(self)
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment