Repository navigation
Closed
Labels
A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.Something wrong, confusing or sub-standard in the software, docs, or user experience.bountyThar's some kind o' loot on offer..Thar's some kind o' loot on offer..journalThe journal file format, and its features.The journal file format, and its features.regressionA backwards step, indicating a weakness in our QA. We don't like these.A backwards step, indicating a weakness in our QA. We don't like these.
Description
Hi,
hledger-1.22.1 introduces a regression preventing auto-deduced amounts of forecasted balance assertions of being calculated.
How To Reproduce
Take this log.hledger file:
2021-09-01 Normal Balance Assertion Works
Checking = -60
Costs
~ 2021-10-01 explicit forecasted assertion
Checking = -100
Costs 40
~ 2021-10-02 auto-deduced forecasted assertion
Checking = -100
Costs
# Works with v1.22
➤ hledger-1.22 reg -f log.hledger --forecast
2021-09-01 Normal Balance Assertion Works Checking -60 -60
Costs 60 0
2021-10-01 explicit forecasted assertion Checking -40 -40
Costs 40 0
2021-10-02 auto-deduced forecasted assertion Checking 0 0
Costs 0 0
# Doesn't work with v1.22.1
➤ hledger-1.22.1 reg -f log.hledger --forecast
hledger-1.22.1: "" (lines 1-1)
could not balance this transaction:
can't have more than one real posting with no amount
(remember to put two or more spaces between account and amount)
2021-10-02 auto-deduced forecasted assertion
; generated-transaction: ~ 2021-10-02
Checking = -100
Costs
CallStack (from HasCallStack):
error, called at ./Hledger/Cli/Utils.hs:125:27 in hledger-1.22.1-inplace:Hledger.Cli.UtilsIs this intended? Auto-deduced amounts for forecasted balance assertions are really handy to say e.g. ”I'll move all of the money from that account to another one at that time”.
Platform: up-to-date Manjaro x86_64 with hledger 1.22 and 1.22.1
Reacted by Jeric de Leon
Metadata
Metadata
Assignees
Labels
A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.Something wrong, confusing or sub-standard in the software, docs, or user experience.bountyThar's some kind o' loot on offer..Thar's some kind o' loot on offer..journalThe journal file format, and its features.The journal file format, and its features.regressionA backwards step, indicating a weakness in our QA. We don't like these.A backwards step, indicating a weakness in our QA. We don't like these.
Activity
simonmichael commentedon Aug 3, 2021
Ack. It seems we broke this use case with
(Auto-Postings don't work on auto-deduced remaining amounts of periodic transactions #1412)
Thanks for the report! You have earned the https://hledger.org/regressionbounty.
Xitian9 commentedon Aug 3, 2021
sigh I'll look into it. I seem to be doing great damage to hledger project finances.
simonmichael commentedon Aug 4, 2021
LOL, it's money well spent! :-) Thanks for looking into it.
FWIW I'm feeling cautiously optimistic on quality:
simonmichael commentedon Aug 4, 2021
PS and thinking aloud, if it becomes the norm to see frequent bounty money flowing to bug reporters and none to the hard-working bug fixers, that might become a problem. There could be a fixed bounty budget, lasting one release cycle, and any unclaimed is distributed to release contributors at the end of the cycle..
Xitian9 commentedon Aug 4, 2021
Okay, the problem is specifically with balance assignments in forecast transactions. While this seems like a weird feature to me (making statements about what balances should be in the future seems likely to break), I can understand that in some restricted cases this may be useful. In @nobodyinperson's example above, forecast transactions are basically being used as a normal transaction which is only included in the journal when given the
--forecastoption.Here's a summary:
So a proper solution using the most obvious method seems to require four different balancing passes over the whole journal:
This is not only inefficient, but also error-prone. We need to make sure the proper balancing procedure is followed in all places where it has to happen (at least two, currently), and any bugs in one will not necessarily be fixed in the other (which is basically what we're seeing here).
My proposed fix is to change the structure so that forecast transactions are added during the journal finalisation pass. This will require moving
forecast_toInputOpts, as it will now be needed during journal parsing. The overall flow would then be unified, and only require two balancing passes:Any objections?
simonmichael commentedon Aug 4, 2021
Four passes sounds like too many. Yes adding forecast transactions earlier so they can be checked within journalFinalise's usual two passes sounds good. I don't remember why they are not there, I think it was just implementation convenience as they were added later.
Xitian9 commentedon Aug 4, 2021
I'm sure you'll love to hear this. There is precisely one place where
forecast_is used that does not have access toInputOpts: inaccountTransactionsReport, where it needs to check whether we've called--forecastto determine whether to exclude future transactions. Since we were just discussing this the other day, here's another data point to decide whether to keep this feature.simonmichael commentedon Aug 4, 2021
Aha.. I'm fine with dropping
aregister's hiding of future txns, let it work like other commands for now.Xitian9 commentedon Aug 4, 2021
Second issue: hledger-ui allows you to toggle viewing forecast transactions. Previously this just required running the appropriate report with an updated
ReportOpts. If we make this change, it will require re-reading and re-parsing the entire journal.I guess this doesn't actually differ too much from the status quo, since we have to rebalance the entire journal (twice) anyway. But it is something to note.
Xitian9 commentedon Aug 4, 2021
Update: Generating the default half-a-year's worth of forecast transactions and toggling visibility based on the flag seems like a reasonable option, and actually what is currently done. I'll just put a note here for myself, as I'm likely to mess up to logic here if I'm not careful.
3 remaining items
fix: forecast: Generate forecast transactions at journal finalisation,
nobodyinperson commentedon Aug 4, 2021
Wow, I didn't know this existed. What a great way to motivate the development and testing! The regression bounty amount is really generous. I think I'll use it as a budget for posting future issue bounties 🙂 . Invoiced ✅
I consider forecasting a really important part of accounting. And this case (auto-deducing the remaining amount of a forecasted transaction) is especially useful for future
=0balance assertions - e.g. for loans. Consider you lend somebody a specific sum and you aggree on a latest payback time but that at any time there can be paybacks:For rent deposits it's useful as well (deposited safety amount for the landlord which gets refunded on departure - which at least in Germany is a thing): You move the rent deposit amount to a separate account in
hledger(because it's still yours) and you know that you move out of the appartment at date X. In the forecast, you say that all of the amount will get payed back at that date X (RentDeposit = 0) without the need to hard-code the amount in the periodic transation (as the refundable amount might also be reduced later due to other reasons).I think this feature is important and should stay consistent with
hledger's normal non-forecasted balancing behaviour.Thank you very much for your work on
hledger, it's a really good and dependable tool!fix: forecast: Generate forecast transactions at journal finalisation,
fix: forecast: Generate forecast transactions at journal finalisation,
jericdeleon commentedon Aug 4, 2021
I also got tripped by this and rely on it so much that I am willing to assist financially if needed.
PS: regressions are fine as long as there are logs like these to keep everyone posted, please keep doing great work! 👍 😄
simonmichael commentedon Aug 4, 2021
Let's just hope
aregisterusers don't show up with pitchforks...fix: forecast: Generate forecast transactions at journal finalisation,
fix: forecast: Generate forecast transactions at journal finalisation,
fix: forecast: Generate forecast transactions at journal finalisation,
[-]v1.22.1 breaks auto-deduced amounts of forecasted balance assertions[/-][+]1.22.1 breaks auto-deduced amounts of forecasted balance assertions[/+]fix: forecast: Generate forecast transactions at journal finalisation,
[-]1.22.1 breaks auto-deduced amounts of forecasted balance assertions[/-][+]1.22.1: breaks auto-deduced amounts of forecasted balance assertions[/+]