Giter Site home page Giter Site logo

r-ledger's People

Contributors

esovetkin avatar trevorld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

r-ledger's Issues

Read beancount files in directly with an appropriate bean-query statement

Currently use either bean-report (h)ledger and then either ledger csv or hledger register -o csv. Right now bean-query "SELECT *" doesn't give me what I want/need (in particular missing the crucial account field plus parsing historical cost and/or market values look like could be a bit of a pain as well):

$ bean-example > example.bean
$ bean-query -f csv example.bean "SELECT *" | csvlook | head
|-------------+------+---------------------------+--------------------------------------------------+---------------------------------|
|  date       | flag | payee                     | narration                                        | position                        |
|-------------+------+---------------------------+--------------------------------------------------+---------------------------------|
|  2016-01-01 | *    |                           | Opening Balance for checking account             |   3762.36  USD                  |
|  2016-01-01 | *    |                           | Opening Balance for checking account             |  -3762.36  USD                  |
|  2016-01-01 | *    |                           | Allowed contributions for one year               | -18000     IRAUSD               |
|  2016-01-01 | *    |                           | Allowed contributions for one year               |  18000     IRAUSD               |
|  2016-01-03 | *    | RiverBank Properties      | Paying the rent                                  |  -2400.00  USD                  |
|  2016-01-03 | *    | RiverBank Properties      | Paying the rent                                  |   2400.00  USD                  |
|  2016-01-04 | *    | BANK FEES                 | Monthly bank fee                                 |     -4.00  USD                  |

Enhance register output and simplify register arguments

Add mark, cost, cost_commodity, value, value_commodity columns to imported data frame. Do this by importing in the register several times with a helper function and then merge/join them. Also add an end date option to the helper function to aid with net worth at various times calculations.

"register_hledge()" fails with comma as currency separator and/or if the commodity is prefixed

Hi

As the title states, register_hledge fails if the currency is formatted with a comma as the decimal separator and/or the commodity is prefixed. It will import the transactions, but all amounts will be NA. All of these formats are the official format somewhere.

I found possible solutions (see below) such that the user doesn't need to change his original hledger files and where the internals of register_hledge stays roughly the same, with a few additions.

I have not yet implemented the solutions, but if you agree with them i can make a pull request.

Either way, it took me some time to find error so i believe a more descriptive error message would be good.

Reproducible code

Note that this will create a file called "temp.journal" in the current directory)

> writeLines(c("2016/01/01 Rent", "    assets    100.00 EUR","    expenses"), "temp.journal")
> register_hledger("temp.journal") # works
# A tibble: 2 x 11
  date       mark  payee description account amount commodity historical_cost
  <date>     <chr> <lgl> <chr>       <chr>    <dbl> <chr>               <dbl>
1 2016-01-01 ""    NA    Rent        assets     100 EUR                   100
2 2016-01-01 ""    NA    Rent        expens…   -100 EUR                  -100
...
> writeLines(c("2016/01/01 Rent", "    assets    100,00 EUR","    expenses"), "temp.journal")
> register_hledger("temp.journal") # will import NAs
# A tibble: 2 x 11
  date       mark  payee description account amount commodity historical_cost
  <date>     <chr> <lgl> <chr>       <chr>    <dbl> <chr>               <dbl>
1 2016-01-01 ""    NA    Rent        assets      NA EUR                    NA
2 2016-01-01 ""    NA    Rent        expens…     NA EUR                    NA
# … with 3 more variables: hc_commodity <chr>, market_value <dbl>,
#   mv_commodity <chr>
Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion 
3: NAs introduced by coercion 
> writeLines(c("2016/01/01 Rent", "    assets    EUR 100.00","    expenses"), "temp.journal")
> register_hledger("temp.journal") # Will import NAs
# A tibble: 2 x 11
  date       mark  payee description account amount commodity historical_cost
  <date>     <chr> <lgl> <chr>       <chr>    <dbl> <chr>               <dbl>
1 2016-01-01 ""    NA    Rent        assets      NA 100.00                 NA
2 2016-01-01 ""    NA    Rent        expens…     NA -100.00                NA
# … with 3 more variables: hc_commodity <chr>, market_value <dbl>,
#   mv_commodity <chr>
Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion 
3: NAs introduced by coercion 
> writeLines(c("2016/01/01 Rent", "    assets    EUR 100,00","    expenses"), "temp.journal")
> register_hledger("temp.journal") "will imports NAs"
# A tibble: 2 x 11
  date       mark  payee description account amount commodity historical_cost
  <date>     <chr> <lgl> <chr>       <chr>    <dbl> <chr>               <dbl>
1 2016-01-01 ""    NA    Rent        assets      NA 100,00                 NA
2 2016-01-01 ""    NA    Rent        expens…     NA -100,00                NA
# … with 3 more variables: hc_commodity <chr>, market_value <dbl>,
#   mv_commodity <chr>
Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion 
3: NAs introduced by coercion 

Solutions

Commodity placement

Using hledge print -o file.csv instead of hledge register -o file.csv yields a file with all the information from using register but where the amount is split into an "amount" and "commodity" field. Hence the commodity could be extracted from that column.

For example: (using the same temp.journal from above)

$ hledger register -f temp.journal -o tempReg.csv
$ hledger print -f temp.journal -o tempPrint.csv
$ cat tempReg.csv
"txnidx","date","code","description","account","amount","total"
"1","2016/01/01","","Rent","assets","EUR 100,00","EUR 100,00"
"1","2016/01/01","","Rent","expenses","EUR -100,00","0"
$ cat tempPrint.csv
"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment"
"1","2016/01/01","","","","Rent","","assets","100,00","EUR","","100,00","",""
"1","2016/01/01","","","","Rent","","expenses","-100,00","EUR","100,00","","",""

The columns are named in the same way, so it wouldn't change much.

Decimal separator

This solution is a bit more "hacky" but I believe it's pretty robust.

hledger allows one to specify commodity directives with commodity 100.00 USD - but it has to be a part of the journal file. So a possible solution could work like

  • Use hledger print -o file.csv to find all commodities in use, like above
  • create a copy of the journal file
  • for each commodity, insert the line "commodity 100.00 <commodity>" at the end of the file
  • use hledger register exactly as in the original implementation.
    I have tried it with a single commodity and it worked.

Add engine argument

Refine unit tests for beancount to check for both bean-report and other engines

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.