* src/business/business-core/gncBillTerm.c: fix gncBillTermCopy()

so it PROPERLY copies the bill term.  Oops!
	* src/business/business-core/file/gnc-tax-table-xml-v2.c:
	  when rebuilding the refcount, make sure we fix the grandparent
	  problems first so we refcount the correct object.
	* src/business/business-core/file/gnc-bill-term-xml-v2.c:
	  when rebuilding the refcount, make sure we fix the grandparent
	  problems first so we refcount the correct object.  Also cope
	  with the broken gncBillTermCopy() and hope that the existing
	  parent is correct.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8638 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2003-06-17 21:38:41 +00:00
parent 426e3068fa
commit a436587841
4 changed files with 65 additions and 13 deletions

View File

@ -4,6 +4,17 @@
It does not need to be part of the enum (it's not even used anywhere) It does not need to be part of the enum (it's not even used anywhere)
* src/engine/QueryCore.h: gint32 prints as a "%d", not a "%ld". * src/engine/QueryCore.h: gint32 prints as a "%d", not a "%ld".
* src/business/business-core/gncBillTerm.c: fix gncBillTermCopy()
so it PROPERLY copies the bill term. Oops!
* src/business/business-core/file/gnc-tax-table-xml-v2.c:
when rebuilding the refcount, make sure we fix the grandparent
problems first so we refcount the correct object.
* src/business/business-core/file/gnc-bill-term-xml-v2.c:
when rebuilding the refcount, make sure we fix the grandparent
problems first so we refcount the correct object. Also cope
with the broken gncBillTermCopy() and hope that the existing
parent is correct.
2003-06-16 David Hampton <hampton@employees.org> 2003-06-16 David Hampton <hampton@employees.org>
* src/gnome/window-register.c: Register with the component manager * src/gnome/window-register.c: Register with the component manager

View File

@ -429,9 +429,9 @@ dom_tree_to_billterm (xmlNodePtr node, GNCBook *book)
successful = dom_tree_generic_parse (node, billterm_handlers_v2, successful = dom_tree_generic_parse (node, billterm_handlers_v2,
&billterm_pdata); &billterm_pdata);
if (successful) if (successful) {
gncBillTermCommitEdit (billterm_pdata.term); gncBillTermCommitEdit (billterm_pdata.term);
else { } else {
PERR ("failed to parse billing term tree"); PERR ("failed to parse billing term tree");
gncBillTermDestroy (billterm_pdata.term); gncBillTermDestroy (billterm_pdata.term);
billterm_pdata.term = NULL; billterm_pdata.term = NULL;
@ -565,8 +565,29 @@ billterm_scrub_cb (gpointer term_p, gpointer list_p)
GncBillTerm *term = term_p; GncBillTerm *term = term_p;
GList **list = list_p; GList **list = list_p;
if (billterm_is_grandchild(term) || gncBillTermGetType(term) == 0) if (billterm_is_grandchild(term)) {
*list = g_list_prepend(*list, term); *list = g_list_prepend(*list, term);
} else if (!gncBillTermGetType(term)) {
GncBillTerm *t = gncBillTermGetParent(term);
if (t) {
/* Fix up the broken "copy" function */
PWARN("Fixing broken child billterm: %s",
guid_to_string(gncBillTermGetGUID(term)));
gncBillTermBeginEdit(term);
gncBillTermSetType(term, gncBillTermGetType(t));
gncBillTermSetDueDays (term, gncBillTermGetDueDays(t));
gncBillTermSetDiscountDays (term, gncBillTermGetDiscountDays(t));
gncBillTermSetDiscount (term, gncBillTermGetDiscount(t));
gncBillTermSetCutoff (term, gncBillTermGetCutoff(t));
gncBillTermCommitEdit(term);
} else {
/* No parent? Must be a standalone */
*list = g_list_prepend(*list, term);
}
}
} }
/* for each invoice, check the bill terms. If the bill terms are /* for each invoice, check the bill terms. If the bill terms are
@ -582,16 +603,19 @@ billterm_scrub_invoices (gpointer invoice_p, gpointer ht_p)
term = gncInvoiceGetTerms(invoice); term = gncInvoiceGetTerms(invoice);
if (term) { if (term) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
count++;
g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
if (billterm_is_grandchild(term)) { if (billterm_is_grandchild(term)) {
PINFO("Fixing i-billterm on invoice %s\n", PWARN("Fixing i-billterm on invoice %s\n",
guid_to_string(gncInvoiceGetGUID(invoice))); guid_to_string(gncInvoiceGetGUID(invoice)));
new_bt = billterm_find_senior(term); new_bt = billterm_find_senior(term);
gncInvoiceBeginEdit(invoice); gncInvoiceBeginEdit(invoice);
gncInvoiceSetTerms(invoice, new_bt); gncInvoiceSetTerms(invoice, new_bt);
gncInvoiceCommitEdit(invoice); gncInvoiceCommitEdit(invoice);
term = new_bt;
}
if (term) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
count++;
g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
} }
} }
} }

View File

@ -536,9 +536,6 @@ taxtable_scrub_entries (gpointer entry_p, gpointer ht_p)
table = gncEntryGetInvTaxTable(entry); table = gncEntryGetInvTaxTable(entry);
if (table) { if (table) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
count++;
g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
if (taxtable_is_grandchild(table)) { if (taxtable_is_grandchild(table)) {
PINFO("Fixing i-taxtable on entry %s\n", PINFO("Fixing i-taxtable on entry %s\n",
guid_to_string(gncEntryGetGUID(entry))); guid_to_string(gncEntryGetGUID(entry)));
@ -546,14 +543,17 @@ taxtable_scrub_entries (gpointer entry_p, gpointer ht_p)
gncEntryBeginEdit(entry); gncEntryBeginEdit(entry);
gncEntrySetInvTaxTable(entry, new_tt); gncEntrySetInvTaxTable(entry, new_tt);
gncEntryCommitEdit(entry); gncEntryCommitEdit(entry);
table = new_tt;
}
if (table) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
count++;
g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
} }
} }
table = gncEntryGetBillTaxTable(entry); table = gncEntryGetBillTaxTable(entry);
if (table) { if (table) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
count++;
g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
if (taxtable_is_grandchild(table)) { if (taxtable_is_grandchild(table)) {
PINFO("Fixing b-taxtable on entry %s\n", PINFO("Fixing b-taxtable on entry %s\n",
guid_to_string(gncEntryGetGUID(entry))); guid_to_string(gncEntryGetGUID(entry)));
@ -561,6 +561,12 @@ taxtable_scrub_entries (gpointer entry_p, gpointer ht_p)
gncEntryBeginEdit(entry); gncEntryBeginEdit(entry);
gncEntrySetBillTaxTable(entry, new_tt); gncEntrySetBillTaxTable(entry, new_tt);
gncEntryCommitEdit(entry); gncEntryCommitEdit(entry);
table = new_tt;
}
if (table) {
count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
count++;
g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
} }
} }
} }

View File

@ -409,9 +409,20 @@ static GncBillTerm *gncBillTermCopy (GncBillTerm *term)
if (!term) return NULL; if (!term) return NULL;
t = gncBillTermCreate (term->book); t = gncBillTermCreate (term->book);
gncBillTermBeginEdit(t);
gncBillTermSetName (t, term->name); gncBillTermSetName (t, term->name);
gncBillTermSetDescription (t, term->desc); gncBillTermSetDescription (t, term->desc);
t->type = term->type;
t->due_days = term->due_days;
t->disc_days = term->disc_days;
t->discount = term->discount;
t->cutoff = term->cutoff;
gncBillTermCommitEdit(t);
return t; return t;
} }