mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[Split] xaccSplitGetOtherSplit don't test book trading-accts
don't test trading-acct property when finding other split.
This commit is contained in:
@@ -2077,45 +2077,27 @@ xaccSplitMergePeerSplits (Split *split, const Split *other_split)
|
|||||||
Split *
|
Split *
|
||||||
xaccSplitGetOtherSplit (const Split *split)
|
xaccSplitGetOtherSplit (const Split *split)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
int count, num_splits;
|
|
||||||
Split *other = NULL;
|
Split *other = NULL;
|
||||||
gboolean lot_split;
|
|
||||||
gboolean trading_accts;
|
|
||||||
|
|
||||||
if (!split) return NULL;
|
if (!split) return NULL;
|
||||||
trans = split->parent;
|
trans = split->parent;
|
||||||
if (!trans) return NULL;
|
if (!trans) return NULL;
|
||||||
|
|
||||||
trading_accts = xaccTransUseTradingAccounts (trans);
|
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
|
||||||
num_splits = xaccTransCountSplits(trans);
|
|
||||||
count = num_splits;
|
|
||||||
lot_split = qof_instance_has_slot(QOF_INSTANCE (split), "lot-split");
|
|
||||||
if (!lot_split && !trading_accts && (2 != count)) return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < num_splits; i++)
|
|
||||||
{
|
{
|
||||||
Split *s = xaccTransGetSplit(trans, i);
|
Split *s = n->data;
|
||||||
if (s == split)
|
if ((s == split) ||
|
||||||
{
|
(xaccAccountGetType (xaccSplitGetAccount (s)) == ACCT_TYPE_TRADING) ||
|
||||||
--count;
|
(qof_instance_has_slot (QOF_INSTANCE (s), "lot-split")))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (qof_instance_has_slot (QOF_INSTANCE (s), "lot-split"))
|
if (other)
|
||||||
{
|
return NULL;
|
||||||
--count;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (trading_accts &&
|
|
||||||
xaccAccountGetType(xaccSplitGetAccount(s)) == ACCT_TYPE_TRADING)
|
|
||||||
{
|
|
||||||
--count;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
other = s;
|
other = s;
|
||||||
}
|
}
|
||||||
return (1 == count) ? other : NULL;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
|
|||||||
Reference in New Issue
Block a user