mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Re-sort an invoice entry list when an entry date changes (#320566)
* src/business/business-core/gncInvoice.[ch]: Add new API: gncInvoiceSortEntries() * src/business/business-core/gncEntry.c: re-sort the parent when the entry date changes. Only re-sort when the existing date is non-zero (i.e. don't re-sort on the initial setting of the date). Fixes #320566. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13069 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -4,6 +4,14 @@
|
||||
Need to put the new split into the txn as well as the acct
|
||||
before we call xaccSplitSetBaseValue(). Fixes #325890.
|
||||
|
||||
* src/business/business-core/gncInvoice.[ch]:
|
||||
Add new API: gncInvoiceSortEntries()
|
||||
* src/business/business-core/gncEntry.c:
|
||||
re-sort the parent when the entry date changes.
|
||||
Only re-sort when the existing date is non-zero (i.e.
|
||||
don't re-sort on the initial setting of the date).
|
||||
Fixes #320566.
|
||||
|
||||
2006-01-31 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* configure.in: include gmodule in GLIB_LIBS
|
||||
|
||||
@@ -266,12 +266,25 @@ gncEntryObtainTwin (GncEntry *from, QofBook *book)
|
||||
|
||||
void gncEntrySetDate (GncEntry *entry, Timespec date)
|
||||
{
|
||||
gboolean first_date = FALSE;
|
||||
Timespec zero_time = { 0, 0 };
|
||||
|
||||
if (!entry) return;
|
||||
if (timespec_equal (&entry->date, &date)) return;
|
||||
if (timespec_equal (&entry->date, &zero_time))
|
||||
first_date = TRUE;
|
||||
gncEntryBeginEdit (entry);
|
||||
entry->date = date;
|
||||
mark_entry (entry);
|
||||
gncEntryCommitEdit (entry);
|
||||
|
||||
/* Don't re-sort the first time we set the date on this entry */
|
||||
if (!first_date) {
|
||||
if (entry->invoice)
|
||||
gncInvoiceSortEntries(entry->invoice);
|
||||
if (entry->bill)
|
||||
gncInvoiceSortEntries(entry->bill);
|
||||
}
|
||||
}
|
||||
|
||||
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
|
||||
|
||||
@@ -432,6 +432,14 @@ void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry)
|
||||
mark_invoice (bill);
|
||||
}
|
||||
|
||||
void gncInvoiceSortEntries (GncInvoice *invoice)
|
||||
{
|
||||
if (!invoice) return;
|
||||
invoice->entries = g_list_sort(invoice->entries,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
mark_invoice(invoice);
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
/* Get Functions */
|
||||
|
||||
|
||||
@@ -76,6 +76,11 @@ void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry);
|
||||
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry);
|
||||
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry);
|
||||
|
||||
/** Call this function when an Entry is changed and you want to
|
||||
re-sort the list of entries
|
||||
*/
|
||||
void gncInvoiceSortEntries (GncInvoice *invoice);
|
||||
|
||||
/** @name Get Functions
|
||||
@{ */
|
||||
const char * gncInvoiceGetID (GncInvoice *invoice);
|
||||
|
||||
Reference in New Issue
Block a user