[kmymoney] [Bug 498033] Unclear definition for investment transaction ‘addition of shares’
Ralf Habacker
bugzilla_noreply at kde.org
Wed Jan 1 08:54:10 GMT 2025
https://bugs.kde.org/show_bug.cgi?id=498033
--- Comment #12 from Ralf Habacker <ralf.habacker at freenet.de> ---
(In reply to Ralf Habacker from comment #11)
> (In reply to Thomas Baumgart from comment #4)
> > Therefore, the value has to be zero and that is achieved by a price of zero (shares * price = value).
>
> I traced into the generating of this report and found
> https://invent.kde.org/office/kmymoney/-/blob/master/kmymoney/plugins/views/
> reports/core/querytable.cpp#L991
>
> qS[ctValue] = ((*it_split).shares() * xr).convert(fraction).toString();
>
> At this point, xr is equal to 1.0, which is used as the price and generates
> a value != 0.0
Saving an “Add shares” transaction in a kmymoney file results in this xml
fragment:
<TRANSACTION id=“T000000000000000008” postdate=“2022-08-01” memo=“”
entrydate=“2024-12-27” commodity=“AUD”>
<SPLITS>
<SPLIT id=“S0001” payee=“” reconciledate=“” action=“Add”
reconcileflag=“0” value=“0/1” shares=“5/1” price=“1/1” memo=“”
account=“A000003” number=“” bankid=“”/>
</SPLITS>
</TRANSACTION>
with a price set to 1.0, which is not correct. After looking into the
implementation of the editor for investment transactions, it turned out that
regardless of the call to d->currentActivity->adjustStockSplit(d->stockSplit);
from the instance of the Invest::Add class, which clears the price and value,
retrieving the price from the split always returns 1.0. The cause of this
problem lies in
MyMoneyMoney MyMoneySplit::price() const
{
Q_D(const MyMoneySplit);
if (!d->m_Price.isZero())
returns d->m_Price;
if (!d->m_value.isZero() && !d->m_shares.isZero())
return d->m_value / d->m_shares;
return MyMoneyMoney::ONE;
}
where the corresponding branch in this case is
return MyMoneyMoney:::ONE;
and does not support the case that d->m_value.isZero() can be zero.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the KMyMoney-devel
mailing list