Hello,
is there anything (plugin, importer, converter) that can read a ledger file containing user-defined expressions, and convert into values to be ingested in beancount?
Reason/background: I am a long time beancount user and I have about 10 years of data in double-entry text format. In December, I migrated the beancount format to ledger format to leverage the emacs-mode integration and the plain-text reporting capabilities.
While I achieved some goals (e.g. better integration with my workflows in ingesting and processing documents), I struggle to conduct exploratory analysis on my data. As example, I harmonized my chart of accounts to a structure that allows a comparison with official data from the national statistics, but I need some charting capabilities to view trends and relative shares. I tried running reports in ledger and piping to gnuplot: results are OK-ish but I lack interactivity. Tools like Fava, Fava dashboard and Beangrow gave me immediate answers to my needs.
My latest rabbit hole was trying to integrate depreciation of my car: in ledger I am forced to write a transaction for each period, as the automatic transactions does not work for this case. However, a transaction per year is not enough: I have an outlier month, and 11 months not including the depreciation, screwing up the stats by month and the integration with seasonality of other expenses. In Beancount, I had my python custom script that ran at runtime (and there are plugins out there too) and where I can change parameters like depreciation methods very quickly.
On the other side, the ability of user-defined in ledger is very helpful in some cases: as example, I have a defined function that calculates the different taxes (capital gains, other taxes) automatically for dividends, verifying expected figures with bank statements.
Example (note that I use aliases, so expenses/income prefixes are missing from the screenshot):
define round_cents(val) = (floor((val * 100) + €0.5) / 100)
;; taxable_quote_of_equity
define tqeq(gross) = (round_cents(gross * 0.70))
;; taxable_quote_of_fixed_income
define tqfi(gross) = (round_cents(gross * 1.00))
;; equity_capital_gain_tax
define eqcgtax(taxable) = (round_cents(taxable) * 0.25)
;; fixed_income_capital_gain_tax
define ficgtax(taxable) = (round_cents(taxable) * 0.25)
;; equity_solid_tax
define eqstax(taxable) = (round_cents(eqcgtax(taxable) * 0.055))
;; fixed_income_solid_tax
define fistax(taxable) = (round_cents(ficgtax(taxable) * 0.055))
2021-02-05 XEIN Advanced lump sum tax on capital gain
; isin: LU0290358224
; type: yield
; commodity: XEIN
(assets:taxes:accumulated-advance-tax-gross:XEIN) €64.86
used-tax-free-allowance €27.34
assets-annual-tax-free-allowance €-27.34 = €0
taxes:capitalgain:XEIN (ficgtax(tqfi(€64.86) - €27.34))
taxes:solidtax:XEIN (fistax(tqfi(€64.86) - €27.34) - €0.01)
* bank €-9.89
My plan is to try to stay in ledger format, for the integration in my workflows, but have the possibility to convert it on the spot to beancount and launch fava if needed. I tried ledger2beancount but it does not support inline math.
Any help, comment, critic, suggestion would be appreciated.
--Stefano