mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
bugfix xaccTransGetTxnType: avoid returning TXN_TYPE_LINK incorrectly
A TXN_TYPE_PAYMENT will have non-APAR splits; a TXN_TYPE_LINK will not have non-APAR splits. This bug manifests as a regular TXN_TYPE_PAYMENT transaction being later voided being incorrectly changed to TXN_TYPE_LINK.
This commit is contained in:
parent
853791cbf7
commit
4a60e01fcd
@ -2484,7 +2484,7 @@ xaccTransRetDateDue(const Transaction *trans)
|
||||
char
|
||||
xaccTransGetTxnType (Transaction *trans)
|
||||
{
|
||||
gboolean has_nonAPAR_amount = FALSE;
|
||||
gboolean has_nonAPAR_split = FALSE;
|
||||
|
||||
if (!trans) return TXN_TYPE_NONE;
|
||||
|
||||
@ -2499,9 +2499,8 @@ xaccTransGetTxnType (Transaction *trans)
|
||||
if (!acc)
|
||||
continue;
|
||||
|
||||
if (!xaccAccountIsAPARType (xaccAccountGetType (acc)) &&
|
||||
!gnc_numeric_zero_p (xaccSplitGetValue (n->data)))
|
||||
has_nonAPAR_amount = TRUE;
|
||||
if (!xaccAccountIsAPARType (xaccAccountGetType (acc)))
|
||||
has_nonAPAR_split = TRUE;
|
||||
else if (trans->txn_type == TXN_TYPE_NONE)
|
||||
{
|
||||
GNCLot *lot = xaccSplitGetLot (n->data);
|
||||
@ -2515,7 +2514,7 @@ xaccTransGetTxnType (Transaction *trans)
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_nonAPAR_amount && (trans->txn_type == TXN_TYPE_PAYMENT))
|
||||
if (!has_nonAPAR_split && (trans->txn_type == TXN_TYPE_PAYMENT))
|
||||
trans->txn_type = TXN_TYPE_LINK;
|
||||
|
||||
return trans->txn_type;
|
||||
|
@ -369,6 +369,12 @@ test_xaccTransGetTxnTypeInvoice (Fixture *fixture, gconstpointer pData)
|
||||
g_assert_cmpint (TXN_TYPE_INVOICE, ==, xaccTransGetTxnType (fixture->trans));
|
||||
|
||||
g_assert_cmpint (TXN_TYPE_PAYMENT, ==, xaccTransGetTxnType (fixture->trans2));
|
||||
|
||||
xaccTransVoid (fixture->trans2, "Cancel payment");
|
||||
|
||||
g_assert_cmpint (TXN_TYPE_PAYMENT, ==, xaccTransGetTxnType (fixture->trans2));
|
||||
|
||||
xaccTransUnvoid (fixture->trans2);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user