mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[Transaction|Split.cpp] Remove Reg2 unused functions
This commit is contained in:
parent
963117624a
commit
119e257146
@ -926,39 +926,6 @@ xaccSplitEqual(const Split *sa, const Split *sb,
|
||||
}
|
||||
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
/********************************************************************
|
||||
* xaccSplitListGetUniqueTransactions
|
||||
********************************************************************/
|
||||
GList *
|
||||
xaccSplitListGetUniqueTransactionsReversed (const GList *splits)
|
||||
{
|
||||
GHashTable *txn_hash = g_hash_table_new (nullptr, nullptr);
|
||||
GList *transList = nullptr;
|
||||
const GList *snode;
|
||||
|
||||
for (snode = splits; snode; snode = snode->next)
|
||||
{
|
||||
Transaction *trans = xaccSplitGetParent((Split *)(snode->data));
|
||||
|
||||
if (g_hash_table_contains (txn_hash, trans))
|
||||
continue;
|
||||
|
||||
g_hash_table_insert (txn_hash, trans, nullptr);
|
||||
transList = g_list_prepend (transList, trans);
|
||||
}
|
||||
g_hash_table_destroy (txn_hash);
|
||||
return transList;
|
||||
}
|
||||
|
||||
GList *
|
||||
xaccSplitListGetUniqueTransactions(const GList *splits)
|
||||
{
|
||||
return g_list_reverse (xaccSplitListGetUniqueTransactionsReversed (splits));
|
||||
}
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* Account funcs
|
||||
|
@ -360,11 +360,6 @@ gboolean xaccSplitEqual(const Split *sa, const Split *sb,
|
||||
Split * xaccSplitLookup (const GncGUID *guid, QofBook *book);
|
||||
#define xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b)
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
/* Get a GList of unique transactions containing the given list of Splits. */
|
||||
GList *xaccSplitListGetUniqueTransactionsReversed (const GList *splits);
|
||||
GList *xaccSplitListGetUniqueTransactions(const GList *splits);
|
||||
/*################## Added for Reg2 #################*/
|
||||
/** Add a peer split to this split's lot-split list.
|
||||
* @param other_split: The split whose guid to add
|
||||
* @param timestamp: The time to be recorded for the split.
|
||||
|
@ -1190,56 +1190,6 @@ xaccTransGetAccountAmount (const Transaction *trans, const Account *acc)
|
||||
return total;
|
||||
}
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
gboolean
|
||||
xaccTransGetRateForCommodity(const Transaction *trans,
|
||||
const gnc_commodity *split_com,
|
||||
const Split *split, gnc_numeric *rate)
|
||||
{
|
||||
GList *splits;
|
||||
gnc_commodity *trans_curr;
|
||||
|
||||
if (trans == nullptr || split_com == nullptr || split == nullptr)
|
||||
return FALSE;
|
||||
|
||||
trans_curr = xaccTransGetCurrency (trans);
|
||||
if (gnc_commodity_equal (trans_curr, split_com))
|
||||
{
|
||||
if (rate)
|
||||
*rate = gnc_numeric_create (1, 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (splits = trans->splits; splits; splits = splits->next)
|
||||
{
|
||||
Split *s = GNC_SPLIT(splits->data);
|
||||
gnc_commodity *comm;
|
||||
|
||||
if (!xaccTransStillHasSplit (trans, s)) continue;
|
||||
|
||||
if (s == split)
|
||||
{
|
||||
comm = xaccAccountGetCommodity (xaccSplitGetAccount(s));
|
||||
if (gnc_commodity_equal (split_com, comm))
|
||||
{
|
||||
gnc_numeric amt = xaccSplitGetAmount (s);
|
||||
gnc_numeric val = xaccSplitGetValue (s);
|
||||
|
||||
if (!gnc_numeric_zero_p (xaccSplitGetAmount (s)) &&
|
||||
!gnc_numeric_zero_p (xaccSplitGetValue (s)))
|
||||
{
|
||||
if (rate)
|
||||
*rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_REDUCE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
gnc_numeric
|
||||
xaccTransGetAccountConvRate(const Transaction *txn, const Account *acc)
|
||||
{
|
||||
@ -2597,26 +2547,6 @@ gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
gboolean xaccTransInFutureByPostedDate (const Transaction *trans)
|
||||
{
|
||||
time64 present;
|
||||
gboolean result;
|
||||
g_assert(trans);
|
||||
|
||||
present = gnc_time64_get_today_end ();
|
||||
|
||||
if (trans->date_posted > present)
|
||||
result = TRUE;
|
||||
else
|
||||
result = FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
gboolean
|
||||
xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
|
||||
const Account *account)
|
||||
|
@ -452,13 +452,6 @@ const char * xaccTransGetReadOnly (Transaction *trans);
|
||||
* qof_book_uses_autofreeze() and qof_book_get_autofreeze_gdate(). */
|
||||
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans);
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
/** Returns TRUE if this Transaction's posted-date is in the future */
|
||||
gboolean xaccTransInFutureByPostedDate (const Transaction *trans);
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
/** Returns the number of splits in this transaction. */
|
||||
int xaccTransCountSplits (const Transaction *trans);
|
||||
|
||||
@ -531,15 +524,6 @@ gnc_numeric xaccTransGetAccountValue (const Transaction *trans,
|
||||
gnc_numeric xaccTransGetAccountAmount (const Transaction *trans,
|
||||
const Account *account);
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
/* Gets the amt/val rate, i.e. rate from the transaction currency to
|
||||
the 'split_com' */
|
||||
gboolean
|
||||
xaccTransGetRateForCommodity(const Transaction *trans,
|
||||
const gnc_commodity *split_com,
|
||||
const Split *split_to_exclude, gnc_numeric *rate);
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
/* Compute the conversion rate for the transaction to this account.
|
||||
* Any "split value" (which is in the transaction currency),
|
||||
* multiplied by this conversion rate, will give you the value you
|
||||
|
@ -1171,38 +1171,7 @@ test_xaccTransGetAccountAmount (Fixture *fixture, gconstpointer pData)
|
||||
g_assert_true (gnc_numeric_eq (xaccTransGetAccountAmount (fixture->txn, fixture->acc2), amt2));
|
||||
|
||||
}
|
||||
/* xaccTransGetRateForCommodity
|
||||
gboolean
|
||||
xaccTransGetRateForCommodity(const Transaction *trans,
|
||||
const gnc_commodity *split_com,
|
||||
const Split *split, gnc_numeric *rate)
|
||||
*/
|
||||
static void
|
||||
test_xaccTransGetRateForCommodity (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
gnc_numeric rate = gnc_numeric_zero ();
|
||||
QofBook *book = qof_instance_get_book (QOF_INSTANCE (fixture->txn));
|
||||
auto split0 = xaccMallocSplit (book);
|
||||
auto split1 = xaccTransFindSplitByAccount(fixture->txn, fixture->acc1);
|
||||
g_assert_true (!xaccTransGetRateForCommodity (NULL, fixture->comm,
|
||||
split0, &rate));
|
||||
g_assert_true (!xaccTransGetRateForCommodity (fixture->txn, NULL,
|
||||
split0, &rate));
|
||||
g_assert_true (!xaccTransGetRateForCommodity (fixture->txn, fixture->comm,
|
||||
NULL, &rate));
|
||||
g_assert_true (xaccTransGetRateForCommodity (fixture->txn, fixture->curr,
|
||||
split0, &rate));
|
||||
g_assert_true (gnc_numeric_equal (rate, gnc_numeric_create (1, 1)));
|
||||
rate = gnc_numeric_zero ();
|
||||
g_assert_true (!xaccTransGetRateForCommodity (fixture->txn, fixture->comm,
|
||||
split0, &rate));
|
||||
g_assert_true (gnc_numeric_zero_p (rate));
|
||||
|
||||
g_assert_true (xaccTransGetRateForCommodity (fixture->txn, fixture->comm,
|
||||
split1, &rate));
|
||||
g_assert_true (gnc_numeric_equal (rate, gnc_numeric_create (1800, 240)));
|
||||
|
||||
}
|
||||
/* xaccTransGetAccountConvRate
|
||||
gnc_numeric
|
||||
xaccTransGetAccountConvRate(const Transaction *txn, const Account *acc)// C: 5 in 4 Local: 0:0:0
|
||||
@ -2063,7 +2032,6 @@ test_suite_transaction (void)
|
||||
GNC_TEST_ADD (suitename, "xaccTransIsBalanced", Fixture, NULL, setup, test_xaccTransIsBalanced, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransIsBalanced Trading Accounts", Fixture, NULL, setup, test_xaccTransIsBalanced_trading, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransGetAccountValue", Fixture, NULL, setup, test_xaccTransGetAccountValue, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransGetRateForCommodity", Fixture, NULL, setup, test_xaccTransGetRateForCommodity, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransGetAccountAmount", Fixture, NULL, setup, test_xaccTransGetAccountAmount, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransGetAccountConvRate", Fixture, NULL, setup, test_xaccTransGetAccountConvRate, teardown);
|
||||
GNC_TEST_ADD (suitename, "xaccTransGetAccountBalance", Fixture, NULL, setup, test_xaccTransGetAccountBalance, teardown);
|
||||
|
Loading…
Reference in New Issue
Block a user