Corrections for XIRR implementation to achieve more accurate values
ClosedPublic

Authored by habacker on Nov 8 2018, 9:13 PM.

Details

Summary

In the Investment Report, the XIRR() function is used to calculate
the annual return. The previous implementation contains some errors
that have been corrected with this commit. In addition, if XIRR
cannot calculate the annual return to notify the user of this case,
an empty column is displayed in the investment report.

The basis for this fix is an update of the XIRR implementation from
the KOffice project [1], which brings the calculation up to date and
a further improvement from the libreoffice XIRR implementation [2] to
get more solutions using a two-pass approach. The class CashFlowList
has been moved to separate files to have a cleaner separation.

The obsolete and unused NPV function has been removed.

Tests for XIRR have been extended to check for recognized issues.

[1] https://github.com/KDE/koffice/blob/master/kcells/functions/financial.cpp
[2] https://raw.githubusercontent.com/LibreOffice/core/master/scaddins/source/analysis/financial.cxx

BUG:385993
FIXED-IN:4.8.3, 5.0.3

Test Plan

compiled and tested on linux

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.
habacker requested review of this revision.Nov 8 2018, 9:13 PM
habacker created this revision.
habacker updated this revision to Diff 45138.Nov 8 2018, 9:48 PM
  • added really libreoffice additions
habacker updated this revision to Diff 45322.Nov 11 2018, 7:38 PM
  • add missing include for std::isinf detected by obs build

@wojnilowicz: You do not want this in 5.0 branch ?

This revision was not accepted when it landed; it landed in state Needs Review.Nov 16 2018, 11:07 AM
This revision was automatically updated to reflect the committed changes.
habacker reopened this revision.Nov 16 2018, 11:17 AM
habacker updated this revision to Diff 45579.Nov 16 2018, 11:18 AM
  • rebased

This patch is mostly the same as the patch from D16700 except refactoring of QString QueryTable::helperIRR(const CashFlowList &all) const to be able to show empty values.

tbaumgart accepted this revision.Nov 24 2018, 10:11 AM

Looks OK to me

This revision is now accepted and ready to land.Nov 24 2018, 10:11 AM
This revision was automatically updated to reflect the committed changes.