Fix rounding problem with investments
ClosedPublic

Authored by wojnilowicz on Mar 26 2017, 6:43 PM.

Details

Summary

Patch introduces rounding rules per security for fixing bug #372163. It
seems that this broker always rounds amounts down while my broker rounds
amounts depending on the outlying digit, so it couldn't work for both of
us without rules.

Rounding is done in InvestTransactionEditor because it has all needed
informations at hand.

No rounding of shares is done in InvestTransactionEditor::setupPrice.
Transaction from bug #372163 looks as follows:
brokerage:
shares = 1,009 ; value = 1,009
investment:
shares = -1 ; value = 1,009

InvestTransactionEditor::setupPrice causes brokerage to look as follows:
shares = 1,01 ; value = 1,009
As we can see shares and value diverge, which is unacceptable here.

Patch makes assumption that transaction has only single split of
stock/mutual fund/bond.

BUG:345655
BUG:357784
BUG:365177
BUG:372163
FIXED-IN:5.0

Diff Detail

Repository
R261 KMyMoney
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
wojnilowicz created this revision.Mar 26 2017, 6:43 PM
tbaumgart added inline comments.
kmymoney/mymoney/storage/mymoneystoragesql.cpp
2249

Where is roundingMethodString stored in the DB and why?

wojnilowicz marked an inline comment as done.Mar 27 2017, 12:48 PM
wojnilowicz added inline comments.
kmymoney/mymoney/storage/mymoneystoragesql.cpp
2249

Actually, I don't need it. I'll remove it. Pretend as there is no roundingMethodString.

wojnilowicz marked an inline comment as done.
wojnilowicz edited the summary of this revision. (Show Details)

Changes:

  1. Another bug fixed,
  2. Removed roundingMethodString.
This revision was automatically updated to reflect the committed changes.