Skip to content
  • Łukasz Wojniłowicz's avatar
    Fix rounding problem with investments · c6e31c96
    Łukasz Wojniłowicz authored
    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: default avatarŁukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
    c6e31c96