-
Notifications
You must be signed in to change notification settings - Fork 537
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
Bugfix 603: scheduled transactions with multiple splits end up going to imbalance #628
Conversation
…alues. The quantity's currency might be different than the value's currency.
@@ -268,7 +268,11 @@ public Money getBalance(String accountUID){ | |||
public Money getImbalance(){ | |||
Money imbalance = Money.createZeroInstance(mCurrencyCode); | |||
for (Split split : mSplitList) { | |||
if (!split.getQuantity().getCommodity().getCurrencyCode().equals(mCurrencyCode)) { | |||
Money quantity = split.getQuantity(); | |||
if (quantity.isAmountZero()) { |
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'd say quantity
should never be zero (see this comment). Am I missing something?
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.
missing the fact that template transactions have splits with zero quantity, but non-zero values.
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.
In which case would we have a valid template transaction with zero quantity and non-zero value? It doesn't seem possible from the Android application. How do you create such template transaction?
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.
it happens when importing from Desktop.
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.
Then it's an import problem that should be fixed instead of worked around.
Split imbSplit = mTransaction.createAutoBalanceSplit(); | ||
if (imbSplit != null) { | ||
mAutoBalanceSplits.add(imbSplit); | ||
} |
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.
If we get a transaction with unbalanced splits (scheduled or normal), I'd say it's either we've failed to import it correctly or there's something wrong in the file.
Sorry, I can merge these changes. They are working around the problem instead of fixing it. |
Template transactions have splits with zero quantities but non-zero values.
The quantity's currency might be different than the value's currency.