loan,-class {businessPlanR}R Documentation

S4 Class loan

Description

This is a special case of the generic class transaction.

Usage

## S4 method for signature 'loan'
initialize(
  .Object,
  type,
  category,
  name,
  amount,
  period,
  interest,
  first_month = format(Sys.Date(), "%Y.%m"),
  schedule = c("annuity", "amortization", "maturity"),
  due_month = NA,
  valid_types = "default",
  value
)

Arguments

.Object

The object to initialize.

type

A character string defining the type of transaction as defined by valid_types.

category

A character string, custom category for this transaction.

name

A character string, custom name or ID for this transaction.

amount

Numeric, the amount of money loaned.

period

Integer, number of months to fully repay the loan.

interest

Numeric, the nominal interest rate per annum (a value between 0 and 1).

first_month

Character string in YYYY.MM format, defining the initial date of the loan.

schedule

One of the following, defining the repayment schedule:

  • "annuity": Equal rates of total repayment over period, thereby interest is relatively higher and principal payment relatively lower at the beginning.

  • "amortization": Repayment of equal rates of principal payment with decreasing interest and total payments over period.

  • "maturity": Repayment of the full loan amount at the end of period, until then only payment of interest.

due_month

Integer value defining the first month of principal repayment. The selected schedule will not begin before this month, until then only interest rates are due. Beware that this is a different behaviour of this argument compared to transaction.

valid_types

A character string, the model types defined by set_types to be used for validation. If "default", pre-defined example types are used.

value

A valid data frame to be used as the value slot directly, omitting calculation via amount, period, interest, etc.

Details

In contrast to revenue or expense, the time range of this class of objects is defined by details of the loan as specified. Only when used as an aspect of an operations class object, this range is adjusted to fit that particular object.

Slots

type

A character string, for valid values see valid_types. You might use all valid types pre-defined for either revenue or expense, considering that you might be the loan giver or receiver.

category

A character string, custom category for this loan.

name

A character string, custom name or ID for this loan.

value

Data frame containing an amortization schedule for the loan, each month in a row named YYYY.MM. It has a row for each month and the columns balance_start, interest, principal, total, cumsum, and balance_remain.

valid_types

A character string, the model types defined by set_types to be used for validation.

Constructor function

Should you need to manually generate objects of this class, the constructor function loan(...) can be used instead of new("loan", ...).

NA

Should you need to manually generate objects of this class, the constructor function loan(...) can be used instead of new("loan", ...).

Examples

loan_2019 <- loan(
    type="Interest",
    category="Bank",
    name="New office",
    amount=10000,
    period=60,
    interest=0.075,
    first_month="2019.04",
    schedule=c("amortization")
)

# turn loan object into an expense
loan_as_expense_2019 <- as_transaction(
    loan_2019,
    to="expense",
    aspect="interest"
)

[Package businessPlanR version 0.1-0 Index]