-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
New "-V" flag behavour not reverse compatible when combined with "--end" flag #1083
Comments
That's interesting, thanks. Reviewing what you've found, old behaviour first:
-V shows the SP amount in USD, using the market price on today's date by default. (Ignore the fact that print with -V looks unbalanced, that's expected.):
With a report end date specified, -V uses the market price on that date:
Now the new behaviour - print -V still uses today's market price by default:
It no longer pays attention to the report end date:
Unless you set the valuation date explicitly, to "end":
Is this a bug ? Well, report end date and valuation date are independent concepts; you should be able to see any period's data, valued using the prices on any date. So should a report end date also set the valuation date ? I don't think so. https://hledger.org/hledger.html#effect-of-value-on-reports is supposed to document how print is affected, and seems a bit unclear. https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Reports/EntriesReport.hs#L47 helps determine the default valuation date used by print. In this case I can see it's being used only with --value=end (evaluating to 2016-01-02); it's not used with -V. https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Posting.hs#L337 shows why: --value=end executes the AtEnd case. -V executes the second AtDefault case, which uses today's date (same as --value=now). Is this a bug ? Is there a better default valuation date for -V when valuing postings, affecting print and register ? Still not sure, I'll need a fresh mind. |
https://hledger.org/hledger.html#valuation docs updated a bit. |
Well I reported it as a bug since the release notes claim "There is a new valuation option --value=TYPE[,COMM], with backwards-compatible -B/--cost, -V/--market, -X/--exchange=COMM variants" but there is actually new non-backwards-compatible behaviour that breaks how r-ledger calculates historical net worth in hledger files. If you want to keep the new behaviour I can first figure out which version of hledger the user has and then use different flags based on whether it is hledger (>= 1.15) or hledger (< 1.15) (which does not have the new I suspect that using the reporting end date as the default valuation date for "--market" is the most useful default market valuation date (which it seems you continue to use as the default for multiperiod reports) instead of |
I had a weaker notion of backwards-compatible in mind there, but you're right. And as you say, "-V == --value=end, always" would seem both more compatible and simpler, and at least as useful, I think. And I think we could do this in a bugfix release quite soon. |
"-V == --value=end" isn't fully compatible either:
Old -V uses prices on -e date, otherwise today's date:
1.15 single-period -V uses prices on today's date, ignoring -e date:
-V equivalent to --value=end uses prices on -e date, otherwise journal end date:
|
I think that last behaviour might be ok from a usability perspective, even though it's a change. How would it affect your usage ? |
Whether -V (with no report end date specified) should be changed to use the journal end date instead of today as default valuation date. Pro:
Con:
|
When importing in an
Neither the One use case would be someone keeping track of an inventory or investments in a separate ledger that they are holding long-term and while they are keeping the price directives up to date they don't have any new transactions to record but they are still interested in knowing what their current market values are in that separate ledger. Not sure how many such users with that use case exist, if you keep everything (including checking account and credit card) in one ledger and don't have future price directives then you aren't likely to be impacted either way. |
For the record, price directive dates is something we don't currently consider at all when choosing valuation date. I don't know if Ledger does. There are are a lot of dates and cases to keep track of. Tricky! And this is reflected a bit in the code right now. So this might take a little longer to bake. Currently I lean towards just fixing the issue you reported (make -V use -e) and maximising compatibility. |
-V (and -X) now respects a report end date set with -e/-p/date: when choosing the valuation date, similar to hledger 1.14 and Ledger. This means that -V/-X aren't exactly like either --value=end or --value=now. The "Effect of --value on reports" doc has been extended accordingly, and much of it has been reworded and made more accurate.
This is now fixed in master, and these docs should be accurate (for master): https://hledger.org/hledger.html#effect-of-value-on-reports |
Thanks! |
And, released as hledger-1.15.2. |
FYI: Just downloaded 1.15.2 and noticed there is a small discrepancy from the old HLedger behaviour (and what Ledger does) but I think the new HLedger behaviour is a more intuitive default than the old behaviour.
|
Thanks for the testing. Good catch!
As you say, in hledger 1.15.2 the report end date is exclusive with respect to price directives. Which is consistent with how it works when filtering transactions.. but different from previous hledger versions and Ledger. Which was not intended. |
In particular in hledger the "-V" when combined with the "--end" flag used to only use price directives up to the end date to determine market value but now it also uses price directives after the end flag.
Example:
The old behaviour used to be equivalent to the new "--value=END-DATE" behaviour:
Is this new "-V" combined with "--end=YYYY-MM-DD" behaviour considered a bug that will be fixed? Or do I need to update r-ledger to detect which version of hledger is being used and if the version is new enough use the
-value=END-DATE
and if older instead use-V --end=END-DATE
?The text was updated successfully, but these errors were encountered: