transactions {debkeepr} | R Documentation |
Analysis of double-entry bookkeeping
Description
Family of seven related functions to analyze transactions data frames that have credit, debit, and tetrapartite (lsd) or tetrapartite (lsdf) columns, mimicking an account book.
-
deb_account()
credit, debit, and current value of a single account. -
deb_account_summary()
credit, debit, and current value of all accounts. -
deb_credit()
total credit of each account. -
deb_debit()
total debit of each account. -
deb_current()
current value of each account (credit - debit). -
deb_open()
current value of each account that has a positive or negative value. -
deb_balance()
positive and negative value remaining in a transactions data frame.
Usage
deb_account(
df,
account_id,
credit = credit,
debit = debit,
lsd = lsd,
na.rm = FALSE
)
deb_account_summary(
df,
credit = credit,
debit = debit,
lsd = lsd,
na.rm = FALSE
)
deb_credit(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)
deb_debit(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)
deb_current(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)
deb_open(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)
deb_balance(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)
Arguments
df |
A data frame or tibble with at least credit, debit, and lsd columns. |
account_id |
The id of the account to be used to calculate the credit, debit, and current values. |
credit |
Credit column: Unquoted name of the credit column,
representing the accounts that discharge the transactional values or
from which the values derive. Default is |
debit |
Debit column: Unquoted name of the debit column,
representing the accounts that receive the transactional values.
Default is |
lsd |
Value column: Unquoted name of a column of class |
na.rm |
Logical. Should missing values (including |
Value
Transaction functions return a data frame or tibble with columns for the
accounts in df
and credit, debit, and/or current values in the same type
and bases
as lsd
:
-
deb_account()
: a data frame with three rows showing the credit, debit, and current value of the given account. -
deb_account_summary()
a data frame with one row for each account indf
and credit, debit, and current value columns. -
deb_credit()
: a data frame with one row for each account with the total credit of the accounts. -
deb_debit()
: a data frame with one row for each account with the total debit of the accounts. -
deb_current()
: a data frame with one row for each account with the current value of the accounts. -
deb_open()
: a data frame with one row for each account whose current value is not0
. If all accounts are equal to zero, a data frame with zero rows will be returned. -
deb_balance()
: a data frame with two rows showing the credit and debit remaining indf
.
Transactions data frames:
Transactions data frames have the structure of an account book. They
should have a similar arrangement to dafforne_transactions
. Each row is
a transaction in the book. credit
and debit
columns contain the
account ids associated with discharging account (credit) and the receiving
account (debit). The lsd
column represents the tripartite or
tetrapartite value of each transaction. Like dafforne_transactions
,
transactions data frames can have additional columns with attributes for
each transaction such as id or date among others.
Examples
# Examples use dafforne_transactions data,
# which have default column names.
# See dafforne_accounts for account names.
# Credit, debit, and current value of cash account
deb_account(dafforne_transactions, account_id = 1,
credit = credit, debit = debit,
lsd = lsd)
# Credit, debit, and current value of profit and loss account
deb_account(dafforne_transactions, account_id = 23)
# Summary of all accounts in Dafforne's ledger
deb_account_summary(dafforne_transactions)
# Credit of accounts in Dafforne's ledger
deb_credit(dafforne_transactions)
# Debit of accounts in Dafforne's ledger
deb_debit(dafforne_transactions)
# Current value of accounts in Dafforne's ledger
current <- deb_current(dafforne_transactions)
current
# Current value of open account in Dafforne's ledger
open <- deb_open(dafforne_transactions)
open
# Compare the amount of rows in returned values of
# deb_current() vs deb_open()
nrow(current)
nrow(open)
# Credit and debit remaining on Dafforne's ledger
deb_balance(dafforne_transactions)