simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
2.87k stars 308 forks source link

convert-to-balanced command, for easy conversion to ledgers obeying --require-balanced=true #130

Closed tphyahoo closed 8 years ago

tphyahoo commented 11 years ago

Context:

https://github.com/simonmichael/hledger/issues/115

Create an upgrade path from ledgers incompatible with --require-balanced=true, to ledgers compatible, in particular for the multi-currency case.

Simplest thing that could possibly work for upgrade path is something like

$ ledger convert-to-balanced --balancing-account-name=FIXME -f myledger.ledger > myledger-balanced.ledger

User would then manually tweak transactions, changing FIXME to something more appropriate. Slicker upgrade paths could be provided as software matures.

Single currency case is simple. Just make final entries in transactions with inferrred final balances explicit in ledger file. So assets:cash:found_on_street USD1000 equity is transformed to assets:cash:found_on_street USD1000 equity -USD1000

multi currency case:

2013/01/01 exchange dollars for euros at 1.4USD/EUR assets:cash EUR100 ; assets:usd -USD140 is transformed to 2013/01/01 exchange dollars for euros at 1.4USD/EUR assets:cash EUR100 FIXME -EUR100 assets:cash -USD140 FIXME 140USD

Inferred account name ("FIXME" above) is up for debate / clarification when this feature is actually implemented. Various other possibilities come to mind: equity, equity:trading, suspense, equity:suspense, user specified, forex, or... other ideas?

similar shopping transaction (from selinger) 2013/01/01 Buy food (1 USD = 1.30 CAD) assets:cash -USD40 equity:expense:food CAD52

this converts to 2013/01/01 Buy food (1 USD = 1.30 CAD) assets:cash -USD40 FIXME USD40 equity:expense:food CAD52 FIXME -CAD52 which user can manually fix to 2013/01/01 Canadian in the USA Buys food with US dollars (1 USD = 1.30 CAD) assets:cash -USD40 equity:forex USD40 equity:expense:food CAD52 equity:forex -CAD52

simonmichael commented 8 years ago

Needs discussion/developers, closing.