On Sat, Mar 31, 2018 at 9:38 AM, Martin Michlmayr <[email protected]> wrote:

> * Martin Blais <[email protected]> [2018-03-30 23:56]:
> > - Found a bug in the example file:
> >
> >   bergamot [hg|]:~/src/ledger2beancount$     ./bin/ledger2beancount
> > examples/illustrated.ledger
> >   Can't parse date 03/28 at ./bin/ledger2beancount line 161.
>
> You have to use --config examples/illustrated.yml because of the
> non-standard date foramt used.  I used that because of of a bug in
> ledger but I'll see if I can remove it.
>

Ah! Cool, thx.
Perhaps adding that command as an example (with the --config option) helps
too.


> (This is out of the box, probably an easy fix.)
> > Idea: You may want to add a unit test on the running of the conversion on
> > each of the examples provided.
>
> I thought about doing that but illustrated.ledger won't pass
> bean-check after conversion because of the lot reduction (i.e. showing
> an example of something that's allowed n ledger but not in beancount).
> But I think that's ok since it's explained in the file.
>

I think you can adapt your converter to handle all these conversions
completely automatically.
The context is that you have postings with essentially just one type of
conversion (@ and {} and used interchangeably in Ledger AFAIK).
For every usage of @, classify whether it's a currency conversion or an
investment.
You can do this by looking at the pairs of commodities.

For example, first preprocess the entire ledger and to fetch the whole list
of commodities and separate them into two groups:
- commodities which occur by themselves
- commodities which have a @ conversion
Now define the subset of investment commodities as: the set of commodities
which (a) never occur by themselves, and (b) which are never seen as the
price or cost of another.
For instance, you would never see units of MSFT moved around without a
price (a), and you would never see MSFT used to price another commodity.
Another view: You have three possible cases:

1. just using a currency
  <account>     <units> <ccy>

2. currency conversion
  <account>     <units> <ccy1> @ <ccy2>

3. investment
  <account>     <units> <comm> @ <ccy>

The way you classify the third one is that <comm> never shows up on the
right of @ (e.g., 100 USD @ 2 MSFT) and is never used by itself (2 MSFT).
(1) translates trivially.
(2) becomes a Beancount currency conversion (@)
(3) becomes a Beancount posting held at cost ({})

(And since you're doing a text-to-text translation, you can take advantage
of the automated lot booking when Beancount will parse your file.)



> - About the payee_match feature: Just wanted to point out the fix_payees
> > plugin:
> > https://bitbucket.org/blais/beancount/src/4c0eeea4c6c4f406c5400d3fb24508
> 7042293844/beancount/plugins/fix_payees.py?at=default&
> fileviewer=file-view-default
> > I'm not sure if it can do what Ledger does; but if you think it can be
> > modified to match your needs, let me know.
>
> Ah, this is very cool.  I wasn't aware of that.  I'll add it to the
> documentation.
>

To be fair it's a bit of a prototype.
It could be greatly expanded.



>
> > - About "tag foo"; you can use
> > pushtag #foo
> > ...
> > poptag #foo
> > to achieve something similar (I think it's similar?)
>
> I completely forgot about pushtag.  Thanks, I'll use that instead.
>
> Thanks for the feedback.
> --
> Martin Michlmayr
> http://www.cyrius.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/beancount/20180331133819.pvnnkwxsdgyb663v%40jirafa.cyrius.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhOBQBaH%3D0SVrjd3tXPdNmPihc-gAzRae%3DD3OfgSL2vO_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to