diff --git a/R/InsuranceContract.R b/R/InsuranceContract.R index f771fcb9172f0fcad73c4ad8d1e0eaaed4ec5d05..078c9100ae56618493869fa40c3370a9458b2ac3 100644 --- a/R/InsuranceContract.R +++ b/R/InsuranceContract.R @@ -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) },