simonmichael / hledger

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

generate commodity revaluation transactions ? #82

Open simonmichael opened 11 years ago

simonmichael commented 11 years ago

Original author: simon@joyful.com (January 18, 2012 17:20:43)

As reported by betabug, hledger doesn't auto-generate the commodity revaluation transactions described at http://ledger-cli.org/3.0/doc/ledger3.html#Commodity-Pricing-Problem , so hledger's and ledger's reports can differ eg when exchange rates are changing.

$ cat t.j
P 2011/11/18 EUR CHF 1.234

2011/11/18 Invoice
    Debitor                             EUR 1000.00
    Sales                               EUR -1000.00

P 2011/12/02 EUR CHF 1.2261

2011/12/07 Payment
    Debitor                             EUR -1000.00
    Currency:EUR                        EUR 1000.00
$ hledger -f t.j bal
         EUR 1000.00  Currency:EUR
        EUR -1000.00  Sales
--------------------
                   0

$ hledger -f t.j bal --cost
       CHF 1226.1000  Currency:EUR
          CHF 7.9000  Debitor
       CHF -1234.000  Sales
--------------------
                   0

$ ledger -f t.j bal
         EUR 1000.00  Currency:EUR
        EUR -1000.00  Sales
--------------------
                   0

$ ledger -f t.j bal --cost
         EUR 1000.00  Currency:EUR
        EUR -1000.00  Sales
--------------------
                   0

$ ledger -f t.j bal --market
             CHF1226  Currency:EUR
            CHF-1226  Sales
--------------------
                   0

Some corresponding register reports for reference:

$ hledger -f t.j reg
2011/11/18 Invoice              Debitor                 EUR 1000.00  EUR 1000.00
                                Sales                  EUR -1000.00            0
2011/12/07 Payment              Debitor                EUR -1000.00 EUR -1000.00
                                Currency:EUR            EUR 1000.00            0

$ hledger -f t.j reg --cost
2011/11/18 Invoice              Debitor                CHF 1234.000 CHF 1234.000
                                Sales                  CHF -1234.000            0
2011/12/07 Payment              Debitor                CHF -1226.1000 CHF -1226.1000
                                Currency:EUR           CHF 1226.1000            0

$ hledger -f t.j reg Debitor
2011/11/18 Invoice              Debitor                 EUR 1000.00  EUR 1000.00
2011/12/07 Payment              Debitor                EUR -1000.00            0

$ hledger -f t.j reg Debitor --cost
2011/11/18 Invoice              Debitor                CHF 1234.000 CHF 1234.000
2011/12/07 Payment              Debitor                CHF -1226.1000   CHF 7.9000

$ ledger -f t.j reg                                                                                                                                                                                                                         
11-Nov-18 Invoice                                         Debitor                                                                 EUR 1000.00                  EUR 1000.00                                                                  
                                                          Sales                                                                  EUR -1000.00                            0                                                                  
11-Dec-07 Payment                                         Debitor                                                                EUR -1000.00                 EUR -1000.00                                                                  
                                                          Currency:EUR                                                            EUR 1000.00                            0                                                                  

$ ledger -f t.j reg Debitor                                                                                                                                                                                                                 
11-Nov-18 Invoice                                         Debitor                                                                 EUR 1000.00                  EUR 1000.00                                                                  
11-Dec-07 Payment                                         Debitor                                                                EUR -1000.00                            0                                                                  

$ ledger -f t.j reg --market                                                                                                                                                                                                                
11-Nov-18 Invoice                                         Debitor                                                                     CHF1234                      CHF1234                                                                  
                                                          Sales                                                                      CHF-1234                            0                                                                  
11-Dec-07 Payment                                         Debitor                                                                    CHF-1226                     CHF-1226                                                                  
                                                          Currency:EUR                                                                CHF1226                            0                                                                  

$ ledger -f t.j reg Debitor --market                                                                                                                                                                                                        
11-Nov-18 Invoice                                         Debitor                                                                     CHF1234                      CHF1234                                                                  
11-Dec-02 Commodities revalued                            <Revalued>                                                                    CHF-8                      CHF1226                                                                  
11-Dec-07 Payment                                         Debitor                                                                    CHF-1226                            0                                                                  

Original issue: http://code.google.com/p/hledger/issues/detail?id=82

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/5973291-generate-commodity-revaluation-transactions?utm_campaign=plugin&utm_content=tracker%2F536505&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F536505&utm_medium=issues&utm_source=github).
simonmichael commented 11 years ago

From simon@joyful.com on January 18, 2012 18:26:05 Actually it's not described at that link, but at places like https://groups.google.com/forum/#!searchin/ledger-cli/revalued/ledger-cli/9oa47zA-qqM/Gkpg0VoVkHkJ

tphyahoo commented 11 years ago

I propose to close current bug and open one or more bugs nudging hledger towards following the advice in

http://www.mscs.dal.ca/~selinger/accounting/tutorial.html#4.2

for multicurrency acounting. The selinger link is also referenced in the googlegroups thread above.

I don't understand the desired behavior for currency revaluations, and I'm not convinced it adds value to the accounting tool.

I think what might be nice is a feature that lets you add a history of date,(curr1/curr2),conversionFactor like

2013-01-01, dollar/euro, 0.8 2013-01-02, dollar/euro,0.81 .....

and then have an hledger view that converts everything to the desired reference currency using these conversion factors. But this is purely a "view" and not how the data is actually stored.

so you might do

hledger balance --numeraire-currency=USD

and then hledger would report everything in dollars somehow, using the conversion factors specified.

But that would be something to implement way down the line. For now, the important thing is to follow the rules of accounting, and debits always equal credits in multicurrency, and disallow voodoo inferred currency conversions like in https://github.com/simonmichael/hledger/issues/115