mafm / ledger.fs

Simple command-line, double-entry accounting in F#. Excel and text output.
MIT License
6 stars 2 forks source link

Multi-Currency Support #4

Open ChernayaKoshka opened 6 years ago

ChernayaKoshka commented 6 years ago

Hello @mafm ,

My idea for multi-currency support is being able to define a currency within the input file. Like so:

DEFINE-CURRENCY [comma-delimited-symbols/text] [exchange rate to $]

Which would allow defined to be converted into USD. What do you think?

ChernayaKoshka commented 6 years ago

Added support in the format of CURRENCY-DEFINITION [single-char] [exchange-rate-to-$] in commits

https://github.com/FatherFoxxy/ledger.fs/commit/790803717e60827865b8714a83329a637757602e https://github.com/FatherFoxxy/ledger.fs/commit/3879704d57f5e1cbf4f68376b2e703cbc8f83880 https://github.com/FatherFoxxy/ledger.fs/commit/f1153072320aa8be33273cb5e1669b972984cba5 https://github.com/FatherFoxxy/ledger.fs/commit/bd04c31547dc1dac81ccc5bfa66db0063d266385 https://github.com/FatherFoxxy/ledger.fs/commit/a7cded54e5e32fb7179590eb9311b3342ea898b2

@mafm Let me know what you think.

mafm commented 6 years ago

Sorry, don't have time to look at this properly at the moment.

That said, my goal was actually to keep different currencies/units entirely separate and maintain separate balances for each currency/account because in general, there's no fixed relationship between two currencies/units.

Within each transaction, the accounting equation should hold for each currency - ie each transaction should balance for each currency independently.

For example a transaction like this should fail to validate:

2017-09-09 Convert $1K AUD to $785 USD Assets:Cash:Aud -1000 AUD Asets:Cash:Usd +785 USD

While this should validate:

2017-09-09 Convert $1K AUD to $785 USD Assets:Cash:Aud -1000 AUD Expenses:FxConversion -1000 AUD Asetts:Cash:Usd +785 USD Income:FxConversion 785 USD

The original implementaton of this that I did (not on github anywhere) kept track of the currencies used throughout the transaction file and in reports showing balances or changes in balances showed each currency's balance/change in a separate column.

I think this probably needs an example to make this clearer.