Visitar URL original
Odd behaviour when using prices · Issue #683 · hledgerorg/hledger · GitHub
Skip to content

Odd behaviour when using prices #683

Closed

Description

@mheden

Hi,

Case 1
If I'm using the following file:

2009/01/01
  assets:a:sek     SEK 100.00000 @ 1.35
  assets:a:cash

2014/01/01
  assets:b:stock:Foo Bar          "Foo Bar" 27.0000000 @ 179.400000
  assets:b:cash

P 2010/01/01 SEK 1.40
P 2015/01/01 "Foo Bar" 200.0000000

and run the following command, it looks like the behavior is different between the two transactions:

C:\tmp>hledger -f test.journal bal -B -V
          54.0000000  assets
          54.0000000    a
        -135.0000000      cash
         189.0000000      sek                      <---- changed with updated price
                   0    b
       -4843.8000000      cash
        4843.8000000      stock:Foo Bar            <--- why is this not changed?

Case 2
If I then change the date of the second transaction to the same as the first one:

2009/01/01
  assets:a:sek     SEK 100.00000 @ 1.35
  assets:a:cash

2009/01/01
  assets:b:stock:Foo Bar          "Foo Bar" 27.0000000 @ 179.400000
  assets:b:cash

P 2010/01/01 SEK 1.40
P 2015/01/01 "Foo Bar" 200.0000000

I get another output:

C:\tmp>hledger -f test.journal bal -B -V
                   0  assets
                   0    a
        -135.0000000      cash
         135.0000000      sek                      <---- this is no longer updated
                   0    b
       -4843.8000000      cash
        4843.8000000      stock:Foo Bar

I feel I'm missing something very basic here, could you please explain the behavior?

  1. What is the difference between transaction 1 and 2 in Case 1?
  2. Why did the balance change for transaction 1 in Case 2 when I changed the date for transaction 2?

hledger 1.4 / Windows 10

Activity

  1. added
    docsDocumentation-related.
    journalThe journal file format, and its features.
    needs-reviewTo unblock: needs more code/docs/design review by someone
    on Dec 29, 2017
  2. simonmichael commented on Dec 29, 2017

    @simonmichael
    Member

    Can someone help investigate this one ?

  3. simonmichael commented on Dec 29, 2017

    @simonmichael
    Member

    Related docs, and at least part of the answer:
    http://hledger.org/manual.html#market-prices
    http://hledger.org/manual.html#market-value: when there is a market price (P directive) for the amount's commodity, dated on or before the report end date (see hledger -> Report start & end date), the amount will be converted
    http://hledger.org/hledger.html#report-start-end-date: the [default] effective report start and end dates will be the earliest and latest transaction or posting dates found in the journal

    With no explicit report end date specified, it was converting using prices effective on the date of the latest transaction. In this situation I guess it should use today's date instead.

  4. simonmichael commented on Dec 29, 2017

    @simonmichael
    Member

    Secondly, the different result you get from combining -B and -V here seems like a bug. http://hledger.org/manual.html#market-value says Using -B and -V together is allowed. but I don't know if that ever does anything meaningful. Perhaps we should make this an error.

  5. added this to the 1.5 milestone on Dec 29, 2017
  6. removed
    good-first-issueIf you're a new contributor, this might be a good one for you.
    needs-reviewTo unblock: needs more code/docs/design review by someone
    on Dec 30, 2017
  7. added a commit that references this issue on Dec 30, 2017
    8f55b61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation-related.journalThe journal file format, and its features.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions