mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Keep the lot list sorted during payment processing to ensure the oldest
open document is processed first. In the process, I renamed two helper functions (one of which I had to extend to work with payment lots). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22002 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6d76a40653
commit
b6135110ec
@ -531,7 +531,7 @@ get_selected_lots (GtkTreeModel *model,
|
||||
g_value_unset (&value);
|
||||
|
||||
if (lot)
|
||||
*return_list = g_list_append(*return_list, lot);
|
||||
*return_list = g_list_insert_sorted (*return_list, lot, (GCompareFunc)gncOwnerLotsSortFunc);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -656,8 +656,8 @@ KvpFrame* gncOwnerGetSlots(GncOwner* owner)
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_lot_match_invoice_owner (GNCLot *lot, gpointer user_data)
|
||||
gboolean
|
||||
gncOwnerLotMatchOwnerFunc (GNCLot *lot, gpointer user_data)
|
||||
{
|
||||
GncOwner owner_def;
|
||||
const GncOwner *owner;
|
||||
@ -681,17 +681,24 @@ gnc_lot_match_invoice_owner (GNCLot *lot, gpointer user_data)
|
||||
return gncOwnerEqual (owner, this_owner);
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_lot_sort_func (GNCLot *a, GNCLot *b)
|
||||
gint
|
||||
gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
|
||||
{
|
||||
GncInvoice *ia, *ib;
|
||||
Timespec da, db;
|
||||
|
||||
ia = gncInvoiceGetInvoiceFromLot (a);
|
||||
ib = gncInvoiceGetInvoiceFromLot (b);
|
||||
ia = gncInvoiceGetInvoiceFromLot (lotA);
|
||||
ib = gncInvoiceGetInvoiceFromLot (lotB);
|
||||
|
||||
da = gncInvoiceGetDateDue (ia);
|
||||
db = gncInvoiceGetDateDue (ib);
|
||||
if (ia)
|
||||
da = gncInvoiceGetDateDue (ia);
|
||||
else
|
||||
da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA)));
|
||||
|
||||
if (ib)
|
||||
db = gncInvoiceGetDateDue (ib);
|
||||
else
|
||||
db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB)));
|
||||
|
||||
return timespec_cmp (&da, &db);
|
||||
}
|
||||
@ -1086,7 +1093,7 @@ gncOwnerGetBalanceInCurrency (const GncOwner *owner,
|
||||
continue;
|
||||
|
||||
/* Get a list of open lots for this owner and account */
|
||||
lot_list = xaccAccountFindOpenLots (account, gnc_lot_match_invoice_owner,
|
||||
lot_list = xaccAccountFindOpenLots (account, gncOwnerLotMatchOwnerFunc,
|
||||
(gpointer)owner, NULL);
|
||||
/* For each lot */
|
||||
for (lot_node = lot_list; lot_node; lot_node = lot_node->next)
|
||||
|
@ -177,9 +177,19 @@ GncGUID gncOwnerRetGUID (GncOwner *owner);
|
||||
const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner);
|
||||
const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner);
|
||||
|
||||
/** attach an owner to a lot */
|
||||
/** Attach an owner to a lot */
|
||||
void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot);
|
||||
|
||||
/** Helper function used to filter a list of lots by owner.
|
||||
*/
|
||||
gboolean gncOwnerLotMatchOwnerFunc (GNCLot *lot, gpointer user_data);
|
||||
|
||||
/** Helper function used to sort lots by date. If the lot is
|
||||
* linked to an invoice, use the invoice posted date, otherwise
|
||||
* use the lot's opened date.
|
||||
*/
|
||||
gint gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB);
|
||||
|
||||
/** Get the owner from the lot. If an owner is found in the lot,
|
||||
* fill in "owner" and return TRUE. Otherwise return FALSE.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user