New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd behaviour when using prices #683

Closed
mheden opened this Issue Dec 29, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@mheden

mheden commented Dec 29, 2017

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

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Dec 29, 2017

Owner

Can someone help investigate this one ?

Owner

simonmichael commented Dec 29, 2017

Can someone help investigate this one ?

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Dec 29, 2017

Owner

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.

Owner

simonmichael commented Dec 29, 2017

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.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Dec 29, 2017

Owner

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.

Owner

simonmichael commented Dec 29, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment