Skip to contents

register imports the register from a ledger, hledger, or beancount file as a tibble.

Usage

register(file, ..., toolchain = default_toolchain(file), date = NULL)

register_beancount(file, date = NULL)

register_bean_query(file, date = NULL)

register_rledger(file, date = NULL)

register_hledger(
  file,
  flags = "",
  date = NULL,
  add_mark = TRUE,
  add_cost = TRUE,
  add_value = TRUE
)

register_ledger(file, flags = "", date = NULL)

Arguments

file

Filename for a ledger, hledger, or beancount file.

...

Arguments passed on to either register_ledger, register_hledger, or register_beancount

toolchain

Toolchain used to read in register. Either "ledger" (uses ledger), "hledger" (uses hledger), "beancount" (uses bean-query if available, else rledger), "bean-query" (uses bean-query from beanquery), or "rledger" (uses rledger from rustledger).

date

End date. Only transactions (and implicitly price statements) strictly before this date are used.

flags

Character vector of additional command line flags to pass to either ledger csv or hledger register.

add_mark

Whether to add a column with the mark information. Only relevant for hledger files.

add_cost

Whether to add historical cost columns. Only relevant for hledger files.

add_value

Whether to add market value columns. Only relevant for hledger files.

Value

register returns a tibble.

Examples

 if (Sys.which("ledger") != "") {
     example_ledger_file <- system.file("extdata", "example.ledger", package = "ledger")
     dfl <- register(example_ledger_file)
     head(dfl)
 }
#> # A tibble: 6 × 9
#>   date       mark  payee     description  code  account amount commodity comment
#>   <date>     <chr> <chr>     <chr>        <chr> <chr>    <dbl> <chr>     <chr>  
#> 1 2015-12-31 *     NA        Opening Bal… NA    Assets…   5000 USD       ""     
#> 2 2015-12-31 *     NA        Opening Bal… NA    Equity…  -5000 USD       ""     
#> 3 2016-01-01 *     Landlord  Rent         NA    Assets…  -1500 USD       ""     
#> 4 2016-01-01 *     Landlord  Rent         NA    Expens…   1500 USD       ""     
#> 5 2016-01-01 *     Brokerage Buy Stock    NA    Assets…  -1000 USD       ""     
#> 6 2016-01-01 *     Brokerage Buy Stock    NA    Equity…   1000 USD       ""     
 if (Sys.which("hledger") != "") {
     example_hledger_file <- system.file("extdata", "example.hledger", package = "ledger")
     dfh <- register(example_hledger_file)
     head(dfh)
 }
#> # A tibble: 6 × 12
#>   date       mark  payee    description account amount commodity historical_cost
#>   <date>     <chr> <chr>    <chr>       <chr>    <dbl> <chr>               <dbl>
#> 1 2015-12-31 *     NA       Opening Ba… Assets…   5000 USD                  5000
#> 2 2015-12-31 *     NA       Opening Ba… Equity…  -5000 USD                 -5000
#> 3 2016-01-01 *     Landlord Rent        Assets…  -1500 USD                 -1500
#> 4 2016-01-01 *     Landlord Rent        Expens…   1500 USD                  1500
#> 5 2016-01-01 *     Brokera… Buy Stock   Assets…  -1000 USD                 -1000
#> 6 2016-01-01 *     Brokera… Buy Stock   Equity…   1000 USD                  1000
#> # ℹ 4 more variables: hc_commodity <chr>, market_value <dbl>,
#> #   mv_commodity <chr>, id <chr>
 if (Sys.which("bean-query") != "" || Sys.which("rledger") != "") {
     example_beancount_file <- system.file("extdata", "example.beancount", package = "ledger")
     dfb <- register(example_beancount_file)
     head(dfb)
 }
#> # A tibble: 6 × 13
#>   date       mark  payee    description account amount commodity historical_cost
#>   <date>     <chr> <chr>    <chr>       <chr>    <dbl> <chr>               <dbl>
#> 1 2015-12-31 *     ""       Opening Ba… Assets…   5000 USD                  5000
#> 2 2015-12-31 *     ""       Opening Ba… Equity…  -5000 USD                 -5000
#> 3 2016-01-01 *     "Landlo… Rent        Assets…  -1500 USD                 -1500
#> 4 2016-01-01 *     "Landlo… Rent        Expens…   1500 USD                  1500
#> 5 2016-01-01 *     "Broker… Buy Stock   Assets…  -1000 USD                 -1000
#> 6 2016-01-01 *     "Broker… Buy Stock   Equity…   1000 USD                  1000
#> # ℹ 5 more variables: hc_commodity <chr>, market_value <dbl>,
#> #   mv_commodity <chr>, tags <chr>, id <chr>