| 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 |
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 |
schedule |
One of the following, defining the repayment schedule:
|
due_month |
Integer value defining the first month of principal repayment. The selected |
valid_types |
A character string,
the model types defined by |
value |
A valid data frame to be used as the value slot directly,
omitting calculation via |
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
typeA character string, for valid values see
valid_types. You might use all valid types pre-defined for eitherrevenueorexpense, considering that you might be the loan giver or receiver.categoryA character string, custom category for this loan.
nameA character string, custom name or ID for this loan.
valueData 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 columnsbalance_start,interest,principal,total,cumsum, andbalance_remain.valid_typesA character string, the model types defined by
set_typesto 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"
)