mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
src/engine/Account.[ch]: add convenience function to find open lots
that meet caller's criteria, and create a sorted list (maybe) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7023 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1835,6 +1835,39 @@ xaccAccountGetLotList (Account *acc)
|
|||||||
return (acc->lots);
|
return (acc->lots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LotList *
|
||||||
|
xaccAccountFindOpenLots (Account *acc,
|
||||||
|
gboolean (*match_func)(GNCLot *lot,
|
||||||
|
gpointer user_data),
|
||||||
|
gpointer user_data, GCompareFunc sort_func)
|
||||||
|
{
|
||||||
|
GList *lot_list;
|
||||||
|
GList *retval = NULL;
|
||||||
|
|
||||||
|
if (!acc)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
lot_list = xaccAccountGetLotList (acc);
|
||||||
|
for ( ; lot_list ; lot_list = lot_list->next ) {
|
||||||
|
GNCLot *lot = lot_list->data;
|
||||||
|
|
||||||
|
/* If this lot is closed, then ignore it */
|
||||||
|
if (gnc_lot_is_closed (lot))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (match_func && !(match_func)(lot, user_data))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Ok, this is a valid lot. Add it to our list of lots */
|
||||||
|
if (sort_func)
|
||||||
|
retval = g_list_insert_sorted (retval, lot, sort_func);
|
||||||
|
else
|
||||||
|
retval = g_list_prepend (retval, lot);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -312,6 +312,16 @@ gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account, time_t date);
|
|||||||
SplitList* xaccAccountGetSplitList (Account *account);
|
SplitList* xaccAccountGetSplitList (Account *account);
|
||||||
LotList* xaccAccountGetLotList (Account *account);
|
LotList* xaccAccountGetLotList (Account *account);
|
||||||
|
|
||||||
|
/* Find a list of open lots that match the match_func. Sort according
|
||||||
|
* to sort_func. If match_func is NULL, then all open lots are returned.
|
||||||
|
* If sort_func is NULL, then the returned list has no particular order.
|
||||||
|
* The caller must free to returned list.
|
||||||
|
*/
|
||||||
|
LotList * xaccAccountFindOpenLots (Account *acc,
|
||||||
|
gboolean (*match_func)(GNCLot *lot,
|
||||||
|
gpointer user_data),
|
||||||
|
gpointer user_data, GCompareFunc sort_func);
|
||||||
|
|
||||||
gboolean xaccAccountGetTaxRelated (Account *account);
|
gboolean xaccAccountGetTaxRelated (Account *account);
|
||||||
void xaccAccountSetTaxRelated (Account *account,
|
void xaccAccountSetTaxRelated (Account *account,
|
||||||
gboolean tax_related);
|
gboolean tax_related);
|
||||||
|
|||||||
Reference in New Issue
Block a user