Bug 789 - Various weirdness of "fixed CURRENCY VALUE ... end fixed"
Summary: Various weirdness of "fixed CURRENCY VALUE ... end fixed"
Status: UNCONFIRMED
Alias: None
Product: Ledger
Classification: Unclassified
Component: misc (show other bugs)
Version: 3.0.0
Hardware: All All
: P1 normal
Assignee: John Wiegley
URL:
Depends on:
Blocks:
 
Reported: 2012-09-14 14:35 UTC by Bradley M. Kuhn
Modified: 2016-11-10 20:52 UTC (History)
2 users (show)

See Also:


Attachments
Fixed block weirdness file. (815 bytes, application/octet-stream)
2012-09-14 14:35 UTC, Bradley M. Kuhn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bradley M. Kuhn 2012-09-14 14:35:32 UTC
Created attachment 56 [details]
Fixed block weirdness file.

I've found various oddities with using the

#+begin_src ledger
fixed CURRENCY VALUE
endfixed
#+end_src

blocks.

I asked johnw on IRC, and he said that these blocks are the equivalent to
putting Fixated Prices, ala:

#+begin_src ledger
    ACCOUNT  CURRENCY VALUE {= OTHER_CURRENCY OTHER_VALUE}
#+end_src

Yet, consider this file attached, called fixed-block-weirdness.ledger.
There are a few intersting problems.  I first discovered that the reg
report does the wrong thing (IMO) by revaluing, as if we had left out the
= again:

#+begin_src sh
$ledger -V -f ~/tmp/fixed-block-weirdness.ledger reg payee 'First'
12-Jul-01 First                 Accrued:ProjectB         €-1,000.00   €-1,000.00
                                Expenses:ProjectB         €1,000.00            0
                                (Funds:ProjectB)         €-1,000.00   €-1,000.00
12-Aug-22 Commodities revalued  <Revalued>                        0   $-1,666.67
12-Sep-01 Commodities revalued  <Revalued>                  $166.67   $-1,500.00
12-Sep-01 First                 Accrued:ProjectB          $1,500.00            0
                                Assets:All               $-1,500.00   $-1,500.00
#+end_src sh

I don't think the Commodities should be revalued.  Indeed, if I remove use
of the "fixed" block, and instead put {=PRICE} after the two euro-only transactions, ala:

#+begin_src ledger
2012/07/01 First
    Accrued:ProjectB          €-1,000.00  {=$1.50}
    Expenses:ProjectB          €1,000.00  {=$1.50}
...
2012/02/16 Second
    Accrued:ProjectA              €-200.00 {=$.3333}
    Expenses:ProjectA             €200.00  {=$.3333}
#+end_src ledger

The "Revalued" transactions in the 'reg' report go away:

#+begin_src sh
$ ledger -V -f ~/tmp/fixated-fully.ledger reg payee 'First'
12-Jul-01 First                 Accrued:ProjectB         $-1,500.00   $-1,500.00
                                Expenses:ProjectB         $1,500.00            0
                                (Funds:ProjectB)         $-1,500.00   $-1,500.00
12-Sep-01 First                 Accrued:ProjectB          $1,500.00            0
                                Assets:All               $-1,500.00   $-1,500.00
#+end_src

Meanwhile, using the original "fixed" block one, merely removing:

#+begin_src ledger
= /^(Income|Expenses|Unearned Income):ProjectA/
  (Funds:ProjectA)  -1

= /^(Income|Expenses|Unearned Income):ProjectB/
  (Funds:ProjectB)  -1
#+end_src

transactions makes some of the "revalued" lines disappear (although not
all of this).  This part may be a red herring, though, since the Funds
lines are generating new postings.

Next issue: The fixed block should really forbid changing the fixated
prices inside of it.  The following ledger snippet generates no errors,
but both these transactions below should each generate an inbalance error,
for different reasons:

#+begin_src ledger
fixed € 0.6000

2012/09/01 Bad Because it is not balanced in light of fixiated price from block
    Accrued:ProjectB          €1,000.00
    Assets:All                $-1,500.00

2012/07/01 Bad Because it sets fixiated price different from block one
    Accrued:ProjectB          €-1,000.00 {= $1.50}
    Expenses:ProjectB          €1,000.00 {= $1.50}

endfixed
#+end_src

Next issue (minor): Why does "fixed" end with "endfixed" when other things
end with "end <SPACE> something"?  I'm submitting a documentation pull
reuqest to document this for now, but you can just reject that if you want
to change it.
Comment 4 Martin Michlmayr 2016-11-10 20:52:40 UTC
Bradley, as John pointed out in Comment #3, I think this is because you didn't use the correct syntax.

With:

apply fixed € 0.9000

2012/07/01 First
    Accrued:ProjectB          €-1,000.00
    Expenses:ProjectB          €1,000.00

end

I get the expected result:

$ ledger -f c bal -V
                -900  Accrued:ProjectB
                 900  Expenses:ProjectB
--------------------
                   0
Comment 3 John Wiegley 2013-05-19 04:17:21 UTC
Bradley, the correct syntax is "apply fixed" and "end", not "fixed" and 
"endfixed" any longer.

I did fix another bug though.  Can you please try things out again and let me 
know?  Thanks!
Comment 2 John Wiegley 2012-10-06 03:53:45 UTC
Long title: Various weirdness of "fixed CURRENCY VALUE ... end fixed" blocks, when compared to VALUE {=CONVERTED_VAL} syntax.
Comment 1 Bradley M. Kuhn 2012-09-14 15:12:07 UTC
I chatted with johnw on IRC, and he indicates the intent is that:
fixed A B ... endfixed is equivalent to all transactions just having:
X A {=B} 

But, I get very different results on this, so it's tough for me to figure out what fixed is really doing.  Here's an example:

#+begin_src ledger
default $

fixed € 0.9000
2012/07/01 First
    Accrued:ProjectB          €-1,000.00
    Expenses:ProjectB          €1,000.00
endfixed
#+end_src
#+begin_src sh
$ ledger -V -f abovedata.ledger bal
          €-1,000.00  Accrued:ProjectB
           €1,000.00  Expenses:ProjectB
--------------------
                   0
#+end_src

yet:
#+begin_src ledger
default $

2012/07/01 First
    Accrued:ProjectB          €-1,000.00 {=$0.90}
    Expenses:ProjectB          €1,000.00 {=$0.90}
#+end_src
#+begin_src 
$ ledger -V -f abovedata.ledger bal
               $-900  Accrued:ProjectB
                $900  Expenses:ProjectB
--------------------
                   0
#+end_src

Weird, huh?