Giter Site home page Giter Site logo

ledger-to-beancount's People

Stargazers

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

Watchers

 avatar  avatar  avatar

ledger-to-beancount's Issues

What line in journal causes an exception?

Hi

Testing with two journals, one is converted while the other one causes an exception. However, reading the trace below I'm not able to understand, which line in journal is the cause?

$ ledger-to-beancount ~/journal.txt

Traceback (most recent call last):
  File "/home/ra/.local/share/virtualenvs/ledger-to-beancount-524C-Oyj/bin/ledger-to-beancount", line 11, in <module>
    sys.exit(main())
  File "/home/ra/.local/share/virtualenvs/ledger-to-beancount-524C-Oyj/lib/python3.6/site-packages/ledger_to_beancount/__main__.py", line 7, in main
    output = translate_file(open(filename).readlines())
  File "/home/ra/.local/share/virtualenvs/ledger-to-beancount-524C-Oyj/lib/python3.6/site-packages/ledger_to_beancount/__init__.py", line 223, in translate_file
    posting = '  {}        {}'.format(account, translate_amount(rest))
  File "/home/ra/.local/share/virtualenvs/ledger-to-beancount-524C-Oyj/lib/python3.6/site-packages/ledger_to_beancount/__init__.py", line 126, in translate_amount
    (amount, units) = parse_amount_and_units(amount)
TypeError: 'NoneType' object is not iterable

Currency Formatting

The currency formatting could be improved if it could parse and edit the currency in Beancount format.
Just as an example :


2017-07-13 * "Drinks with Friends"
  Expenses:Personal:Dave:Beverage:Beer     EUR 13.00
  Assets:Cash

To as follows:-

2017-07-13 * "Drinks with Friends"
  Expenses:Personal:Dave:Beverage:Beer    13.00 EUR 
  Assets:Cash

Transactions don't need flags

You wrote in commit 596e5bf:

Flags are preserved, but since every transaction has to have a flag,
we default to the "*" flag for any unflagged transactions

Actually, that's not true. But if you don't have a flag, you have to write "txn" in beancount. This is documented in the beancount syntax guide.

Doesn't know about aux dates

ledger allows aux dates (date1=date2). The script doesn't know about them:

2018-01-01=2018-01-02 * Opening balance: test
    Assets:Test               20.00 EUR
    Equity:Opening balance

Parser breaks if there's space(s) between '$' sign and number

Noticed that if there's space(s) between the $ sign and the number for an entry, the parser crashes.

Example:

2010-02-04 Purchasing new shoes
    Expenses:Clothing       $ 100
    Liabilities:Credit Card

results in the trace:

Traceback (most recent call last):
  File "/Users/hello/.pyenv/versions/3.5.0/bin/ledger-to-beancount", line 9, in <module>
    load_entry_point('ledger-to-beancount==0.0.1', 'console_scripts', 'ledger-to-beancount')()
  File "/Users/hello/.pyenv/versions/3.5.0/lib/python3.5/site-packages/ledger_to_beancount/__main__.py", line 7, in main
    output = translate_file(open(filename).readlines())
  File "/Users/hello/.pyenv/versions/3.5.0/lib/python3.5/site-packages/ledger_to_beancount/__init__.py", line 183, in translate_file
    posting = '  {}        {}'.format(account, translate_amount(rest))
  File "/Users/hello/.pyenv/versions/3.5.0/lib/python3.5/site-packages/ledger_to_beancount/__init__.py", line 89, in translate_amount
    amount = re.sub(r'\$' + amount_re, partial(replace_number, 'USD'), amount)
  File "/Users/hello/.pyenv/versions/3.5.0/lib/python3.5/re.py", line 182, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/Users/hello/.pyenv/versions/3.5.0/lib/python3.5/site-packages/ledger_to_beancount/__init__.py", line 87, in replace_number
    amount = Decimal(match.group(1))
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

Doesn't parse @@

ledger allows you to specify the total with @@ (rather than the unit price with @). The script
doesn't like this:

2018-01-01 * Opening balance: property
    ; :opening-balance:
    Assets:Property          2 FOO {{ 20.00 EUR}} @@ 20.00 EUR
    Equity:Opening balance
  File "/home/tbm/.local/lib/python3.5/site-packages/ledger_to_beancount/__init__.py", line 160, in translate_file
    (amount, price) = rest.split('@')

Quoted commodity names should be stripped

ledger requires some commodity names (e.g. those containing numbers) to be quoted but beancount doesn't allow this.

2018-01-01 * Opening balance: test
    Assets:Property          2 "FOO" @ 20.00 EUR
    Equity:Opening balance

Doesn't parse lot dates

ledger allows lot dates and beancount does as well.

ledger: 2.00 FOO { 4.00 BAR} [2018-03-05}
beancount: 2.00 FOO { 4.00 BAR, 2018-03-05}

But the script gets confused:

2018-01-01 * Opening balance: property
    Assets:Property          2 FOO { 20.00 EUR} [2011-12-18] @ 20.00 EUR
    Equity:Opening balance

leads to:

  File "/home/tbm/.local/lib/python3.5/site-packages/ledger_to_beancount/__init__.py", line 164, in translate_file
    number, units = translated_amount.strip().split(' ')
ValueError: too many values to unpack (expected 2)

Should parse flags

ledger and beancount allow flags to indicate the status of a transaction. It seems this script ignores
them and puts them in the narration (and puts in a * everywhere as the flag).

2017-12-15 * Gift
    Expenses:Gifts                                           80.00 GBP
    Assets:Cash                                             -80.00 GBP

gives:

2017-12-15 * "* Gift"

Note how my flag is in the narration.

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.