Fix rounding problem with investments

Authored by wojnilowicz on Mar 26 2017, 4:37 PM.

Description

Fix rounding problem with investments

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

Differential Revision: https://phabricator.kde.org/D5187

Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>

Details

Committed
wojnilowiczApr 1 2017, 6:16 AM
Differential Revision
D5187: Fix rounding problem with investments
Parents
R261:c8b12d8426d7: Resolved compiler warnings
Branches
Unknown
Tags
Unknown