Skip to content

Commit

Permalink
Merge pull request #95 from miraisolutions/develop
Browse files Browse the repository at this point in the history
1.1.0 release
  • Loading branch information
nfarabullini authored Mar 7, 2019
2 parents 2ac3096 + 91ec141 commit 75b9d4a
Show file tree
Hide file tree
Showing 36 changed files with 848 additions and 449 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: SmaRP
Title: SmaRP: Smart Retirement Planning
Version: 1.0.1
Version: 1.1.0
Authors@R: c(person("Gabriel", "Foix", role = c("aut", "cre"),
email = "[email protected]"),
person("Francesca", "Vitalini", role = c("aut"),
email = "[email protected]"),
person("Nicoletta", "Farabullini", role = c("ctb"),
person("Nicoletta", "Farabullini", role = c("aut"),
email = "[email protected]"),
person("Riccardo", "Porreca", role = c("ctb"),
email = "[email protected]"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(changeToPercentage)
export(getRetirementCalendar)
export(getRetirementday)
export(getTaxAmount)
export(get_SmaRP_version)
export(isnotAvailable)
export(isnotAvailableReturnZero)
export(launch_application)
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# SmaRP 1.1.0

* Retirement age automatically resets to 70 if a higher number is inserted (#27)
* Retirement age changes depending on the selected genre (#72)
* Updated legal parameters (01.01.2019) and tests (#55, #68)
* Removed user_manual.Rmd vignette created with (#60) and added new one (#65)
* SmaRP version shown in the app and the report (#57)
* Report review and updates (#82, #53, #89)
* Added sentence about not storing information in disclaimer, created "Download Data" button when table is displayed (#67)
* Made "c" in "calendar" capital, added tooltip to "Generate Report" button, made "Disclaimer" bold, rephrased first sentence and removed second (#77)
* "genre" changed to "gender" (#79)
* Fixed numeric input so that it doesn't crash when no value is inserted (#81, #28)
* Support responsive embedding via iframe-resizer (#69)
* Dynamic plot size and improved labels (no underscore, space between words) in the Shiny app (#85)

# SmaRP 1.0.1

## Patch release
Expand Down
40 changes: 20 additions & 20 deletions R/TaxBenefit.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#' @title getTaxAmount
#'
#'
#' @rdname getTaxAmount
#'
#' @description This function uses 2 main sources for tax data.
#' At Kanton and Gemeinde level, the source is taxburden.list.
#' At federal level, we use the official taxrate table (BundessteueTabelle) and we try to aproximate the taxable income.
#'
#'
#' @details
#' This function assumes the following objects on the global enviornment
#' * PLZGemeinden (includes Kirchensteuer)
Expand All @@ -21,21 +21,21 @@
#' * VersicherungsL, VersicherungsV, VersicherungsK
#' * BerufsauslagenTarif, BerufsauslagenMax, BerufsauslagenMin
#' @seealso swisstax
#'
#'
#' @param Income Annual salary. `Numeric` scalar.
#' @param rate_group A (Single), B (Married), C (Married Double income) `Character`.
#' @param Age Age of the person. `Numeric`
#' @param NChildren Number of children. `Numeric` scalar.
#' @param postalcode Zip code `Character`
#' @param churchtax Y/N `Character` Y/N
#'
#'
#' @import dplyr
#'
#'
#' @return Tax Amount
#'
#' @examples
#' \dontrun{
#' getTaxAmount(Income = 200000, rate_group = "C", Age = 32,
#' getTaxAmount(Income = 200000, rate_group = "C", Age = 32,
#' NChildren = 5, postalcode = 8400, churchtax = "Y")
#' }
#' @export
Expand Down Expand Up @@ -128,16 +128,16 @@ getTaxAmount <- function(Income,


#' @title lookupTaxAmount
#'
#'
#' @rdname lookupTaxAmount
#'
#'
#' @description Search the tax amount to be paig given one income on the tax tables.
#' @seealso swisstax
#'
#'
#' @param Income Annual stipend.
#' @param Tabelle Income - Tax rate table at Federal level.
#' @param CivilStatus Marital status.
#'
#'
#' @return Tax amount to be paid.
#' @examples
#' \dontrun{
Expand All @@ -162,22 +162,22 @@ lookupTaxAmount <- function(Income, Tabelle, CivilStatus) {
}

#' @title buildTaxBenefits
#'
#'
#' @rdname buildTaxBenefits
#'
#' @description All inputs are scalars. Builds a data frame as long as the years to retirement.
#' Calls 'getTaxAmount()' through 'calcTaxBenefitSwiss()', therefore, it assumes objects on the global enviornment.
#' @seealso swisstax
#'
#'
#' @inheritParams getTaxAmount
#' @param RetirementAge Age of retirement.
#' @template given_bday
#' @template P2
#' @template P3
#' @template salary
#'
#'
#' @import dplyr
#'
#'
#' @return data.frame tax benefit path.
#' @examples
#' \dontrun{buildTaxBenefits(
Expand Down Expand Up @@ -210,7 +210,7 @@ buildTaxBenefits <- function(birthday,
rate_group,
givenday = today("UTC"),
RetirementAge) {
TaxBenefitsPath <- data.frame(calendar = getRetirementCalendar(birthday, givenday, RetirementAge = RetirementAge))
TaxBenefitsPath <- data.frame(Calendar = getRetirementCalendar(birthday, givenday, RetirementAge = RetirementAge))
ncp <- nrow(TaxBenefitsPath)

TaxBenefitsPath <- TaxBenefitsPath %>%
Expand All @@ -220,7 +220,7 @@ buildTaxBenefits <- function(birthday,
TotalContr = BVGpurchase + P3purchase,
ExpectedSalaryPath = calcExpectedSalaryPath(Salary, SalaryGrowthRate, ncp),
TaxableIncome = pmax(ExpectedSalaryPath - pmin(TotalContr, MaxContrTax), 0),
AgePath = as.integer(sapply(calendar, calcAge, birthday = birthday)),
AgePath = as.integer(sapply(Calendar, calcAge, birthday = birthday)),
TaxBenefits = calcTaxBenefitSwiss(ExpectedSalaryPath, TaxableIncome, rate_group, AgePath, NChildren, postalcode, churchtax),
t = buildt(birthday, givenday, RetirementAge = RetirementAge),
TotalTax = calcAnnuityAcumPath(TaxBenefits, t, returnP3),
Expand All @@ -233,18 +233,18 @@ buildTaxBenefits <- function(birthday,
}

#' @title calcTaxBenefitSwiss
#'
#'
#' @rdname calcTaxBenefitSwiss
#'
#'
#' @description Calculates the tax benefit as a difference of the taxes paid with and without retirement contributions.
#' Calls 'getTaxAmount()', therefore, it assumes objects in the global environment.
#' @seealso [getTaxAmount()]
#' @seealso swisstax
#'
#'
#' @param ExpectedSalaryPath Vector of annual salaries until retirement.
#' @param TaxableIncome Vector of annual taxable income until retirement.
#' @inheritParams getTaxAmount
#'
#'
#' @return Single tax benefit (tax relief) of one contribution.
#' @examples
#' \dontrun{
Expand Down
2 changes: 1 addition & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ utils::globalVariables(
"Kirchensteuer", "MaxBVG", "MaxContrTax", "MinBVG", "NBU", "NetSalary",
"P3ContributionPath", "PLZ", "PLZGemeinden", "TaxBenefits", "TaxableIncome",
"TotalContr", "TotalP3", "TotalTax", "VM", "Verheiratet", "Versicherung",
"VersicherungsK", "VersicherungsL", "VersicherungsV", "calendar", "h4", "icon", "maxALV",
"VersicherungsK", "VersicherungsL", "VersicherungsV", "Calendar", "h4", "icon", "maxALV",
"maxNBU", "modalDialog", "removeModal", "showModal", "taxburden.list")
)
Loading

0 comments on commit 75b9d4a

Please sign in to comment.