-
-
Notifications
You must be signed in to change notification settings - Fork 524
WIP: Make virtual-balanced transactions balance separately. #2376
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
base: master
Are you sure you want to change the base?
WIP: Make virtual-balanced transactions balance separately. #2376
Conversation
if (journal && journal->bucket && posts.size() == 1) { | ||
if (! balance_real.is_null()) { | ||
null_post_real = new post_t(journal->bucket, ITEM_INFERRED); | ||
null_post_real->_state = (*posts.begin())->_state; | ||
add_post(null_post_real); | ||
} | ||
// TODO: does this need to set POST_VIRTUAL | POST_MUST_BALANCE ? | ||
else if (! balance_virtual.is_null()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently there's some way to say "if an xact has only one posting, here's a default account to balance against".
If an xact has exactly one real and one balanced-virtual posting, right now I'm taking that to be an error. We could instead choose to balance both against the default account. But currently,
2024/08/27 Example
Income $1.00
(Expenses) $-1.00
doesn't balance against the default, so I wouldn't expect it to with []
either.
|
||
if (! null_post && balance.is_balance() && | ||
// TODO: How do we want handle virtual postings here? | ||
if (! null_post_real && ! null_post_virtual && balance.is_balance() && | ||
balance.as_balance().amounts.size() == 2) { | ||
// When an xact involves two different commodities (regardless of how | ||
// many posts there are) determine the conversion ratio by dividing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are two commodities, we calculate the conversion rate between them.
If there are two real and two virtual, should we do the same? Regardless of whether that's two, three, or four in total?
// TODO: fix for virtual post balancing. | ||
bool xact_base_t::verify() | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can fix this (with yet more code duplication). But when I do, how should I test it? My current guess is this code path gets called when there are auto xacts?
This is intended to close #2105: in a given transaction, virtual postings (with
[]
) should balance to 0 and real postings should balance to 0, but until now it's just been required that the complete set "virtual postings (with[]
) and real postings" should balance to 0. Minimally:ought to error but until now has been accepted.
It's not complete yet. There are some design decisions and I'd appreciate some opinions on them. Also, I don't really know C++. Right now a lot of the code here is just "copy the existing code and do it again with some variables and some flags changed", and if there's some way to avoid that it would be nice to know.