mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-29 20:24:25 -06:00
Fix up state-changing business functions
To ensure that they all have a begin/commit and mark the instance dirty so that the change is immediately written to the DB. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23167 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
818c00630d
commit
38f1cc6479
@ -404,6 +404,7 @@ void gncBillTermSetParent (GncBillTerm *term, GncBillTerm *parent)
|
||||
{
|
||||
gncBillTermMakeInvisible (term);
|
||||
}
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
@ -412,6 +413,7 @@ void gncBillTermSetChild (GncBillTerm *term, GncBillTerm *child)
|
||||
if (!term) return;
|
||||
gncBillTermBeginEdit (term);
|
||||
term->child = child;
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
@ -421,6 +423,7 @@ void gncBillTermIncRef (GncBillTerm *term)
|
||||
if (term->parent || term->invisible) return; /* children dont need refcounts */
|
||||
gncBillTermBeginEdit (term);
|
||||
term->refcount++;
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
@ -428,16 +431,20 @@ void gncBillTermDecRef (GncBillTerm *term)
|
||||
{
|
||||
if (!term) return;
|
||||
if (term->parent || term->invisible) return; /* children dont need refcounts */
|
||||
g_return_if_fail (term->refcount >= 1);
|
||||
gncBillTermBeginEdit (term);
|
||||
term->refcount--;
|
||||
g_return_if_fail (term->refcount >= 0);
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
void gncBillTermSetRefcount (GncBillTerm *term, gint64 refcount)
|
||||
{
|
||||
if (!term) return;
|
||||
gncBillTermBeginEdit (term);
|
||||
term->refcount = refcount;
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
void gncBillTermMakeInvisible (GncBillTerm *term)
|
||||
@ -446,6 +453,7 @@ void gncBillTermMakeInvisible (GncBillTerm *term)
|
||||
gncBillTermBeginEdit (term);
|
||||
term->invisible = TRUE;
|
||||
remObj (term);
|
||||
mark_term (term);
|
||||
gncBillTermCommitEdit (term);
|
||||
}
|
||||
|
||||
@ -578,6 +586,7 @@ static GncBillTerm *gncBillTermCopy (const GncBillTerm *term)
|
||||
t->discount = term->discount;
|
||||
t->cutoff = term->cutoff;
|
||||
|
||||
mark_term (t);
|
||||
gncBillTermCommitEdit(t);
|
||||
|
||||
return t;
|
||||
|
@ -550,6 +550,7 @@ qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent)
|
||||
}
|
||||
gncEmployeeBeginEdit(employee);
|
||||
employee->addr = addr;
|
||||
mark_employee (employee);
|
||||
gncEmployeeCommitEdit(employee);
|
||||
}
|
||||
|
||||
|
@ -844,6 +844,7 @@ void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry)
|
||||
}
|
||||
|
||||
dest->values_dirty = TRUE;
|
||||
mark_entry (dest);
|
||||
gncEntryCommitEdit (dest);
|
||||
}
|
||||
|
||||
@ -1330,6 +1331,7 @@ gncEntryRecomputeValues (GncEntry *entry)
|
||||
/* Determine the commodity denominator */
|
||||
denom = get_entry_commodity_denom (entry);
|
||||
|
||||
gncEntryBeginEdit (entry);
|
||||
/* Compute the invoice values */
|
||||
gncEntryComputeValue (entry->quantity, entry->i_price,
|
||||
(entry->i_taxable ? entry->i_tax_table : NULL),
|
||||
@ -1362,6 +1364,8 @@ gncEntryRecomputeValues (GncEntry *entry)
|
||||
entry->b_tax_value_rounded = gnc_numeric_convert (entry->b_tax_value, denom,
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
entry->values_dirty = FALSE;
|
||||
mark_entry (entry);
|
||||
gncEntryCommitEdit (entry);
|
||||
}
|
||||
|
||||
/* The "Int" functions below are for internal use only.
|
||||
|
@ -380,7 +380,7 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *from)
|
||||
|
||||
// Posted-date and the posted Txn is intentionally not copied; the
|
||||
// copy isn't "posted" but needs to be posted by the user.
|
||||
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit(invoice);
|
||||
|
||||
return invoice;
|
||||
@ -621,27 +621,33 @@ void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry)
|
||||
if (old == invoice) return; /* I already own this one */
|
||||
if (old) gncInvoiceRemoveEntry (old, entry);
|
||||
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
gncEntrySetInvoice (entry, invoice);
|
||||
invoice->entries = g_list_insert_sorted (invoice->entries, entry,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
}
|
||||
|
||||
void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry)
|
||||
{
|
||||
if (!invoice || !entry) return;
|
||||
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
gncEntrySetInvoice (entry, NULL);
|
||||
invoice->entries = g_list_remove (invoice->entries, entry);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
}
|
||||
|
||||
void gncInvoiceAddPrice (GncInvoice *invoice, GNCPrice *price)
|
||||
{
|
||||
if (!invoice || !price) return;
|
||||
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
invoice->prices = g_list_prepend(invoice->prices, price);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
}
|
||||
|
||||
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry)
|
||||
@ -656,19 +662,23 @@ void gncBillAddEntry (GncInvoice *bill, GncEntry *entry)
|
||||
if (old == bill) return; /* I already own this one */
|
||||
if (old) gncBillRemoveEntry (old, entry);
|
||||
|
||||
gncInvoiceBeginEdit (bill);
|
||||
gncEntrySetBill (entry, bill);
|
||||
bill->entries = g_list_insert_sorted (bill->entries, entry,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
mark_invoice (bill);
|
||||
gncInvoiceCommitEdit (bill);
|
||||
}
|
||||
|
||||
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry)
|
||||
{
|
||||
if (!bill || !entry) return;
|
||||
|
||||
gncInvoiceBeginEdit (bill);
|
||||
gncEntrySetBill (entry, NULL);
|
||||
bill->entries = g_list_remove (bill->entries, entry);
|
||||
mark_invoice (bill);
|
||||
gncInvoiceCommitEdit (bill);
|
||||
}
|
||||
|
||||
void gncInvoiceSortEntries (GncInvoice *invoice)
|
||||
@ -676,7 +686,9 @@ void gncInvoiceSortEntries (GncInvoice *invoice)
|
||||
if (!invoice) return;
|
||||
invoice->entries = g_list_sort(invoice->entries,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
mark_invoice(invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
@ -1488,6 +1500,10 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
gncAccountValueDestroy (splitinfo);
|
||||
|
||||
gnc_lot_commit_edit (lot);
|
||||
/* Not strictly necessary, since it was done by the Set calls
|
||||
* above, but good insurance. */
|
||||
DEBUG("Committing Invoice %s", invoice->id);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
|
||||
/* If requested, attempt to automatically apply open payments
|
||||
|
@ -338,10 +338,11 @@ qofJobSetOwner (GncJob *job, QofInstance *ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
qof_begin_edit(&job->inst);
|
||||
|
||||
gncJobBeginEdit (job);
|
||||
qofOwnerSetEntity(&job->owner, ent);
|
||||
mark_job (job);
|
||||
qof_commit_edit(&job->inst);
|
||||
gncJobCommitEdit (job);
|
||||
}
|
||||
|
||||
void gncJobBeginEdit (GncJob *job)
|
||||
|
@ -399,21 +399,25 @@ void gncOrderAddEntry (GncOrder *order, GncEntry *entry)
|
||||
if (old == order) return; /* I already own it */
|
||||
if (old) gncOrderRemoveEntry (old, entry);
|
||||
|
||||
gncOrderBeginEdit (order);
|
||||
order->entries = g_list_insert_sorted (order->entries, entry,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
|
||||
/* This will send out an event -- make sure we're attached */
|
||||
gncEntrySetOrder (entry, order);
|
||||
mark_order (order);
|
||||
gncOrderCommitEdit (order);
|
||||
}
|
||||
|
||||
void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry)
|
||||
{
|
||||
if (!order || !entry) return;
|
||||
|
||||
gncOrderBeginEdit (order);
|
||||
gncEntrySetOrder (entry, NULL);
|
||||
order->entries = g_list_remove (order->entries, entry);
|
||||
mark_order (order);
|
||||
gncOrderCommitEdit (order);
|
||||
}
|
||||
|
||||
/* Get Functions */
|
||||
|
@ -499,6 +499,7 @@ void gncTaxTableSetParent (GncTaxTable *table, GncTaxTable *parent)
|
||||
gncTaxTableAddChild(parent, table);
|
||||
table->refcount = 0;
|
||||
gncTaxTableMakeInvisible (table);
|
||||
mark_table (table);
|
||||
gncTaxTableCommitEdit (table);
|
||||
}
|
||||
|
||||
@ -507,6 +508,7 @@ void gncTaxTableSetChild (GncTaxTable *table, GncTaxTable *child)
|
||||
if (!table) return;
|
||||
gncTaxTableBeginEdit (table);
|
||||
table->child = child;
|
||||
mark_table (table);
|
||||
gncTaxTableCommitEdit (table);
|
||||
}
|
||||
|
||||
@ -516,6 +518,7 @@ void gncTaxTableIncRef (GncTaxTable *table)
|
||||
if (table->parent || table->invisible) return; /* children dont need refcounts */
|
||||
gncTaxTableBeginEdit (table);
|
||||
table->refcount++;
|
||||
mark_table (table);
|
||||
gncTaxTableCommitEdit (table);
|
||||
}
|
||||
|
||||
@ -523,16 +526,21 @@ void gncTaxTableDecRef (GncTaxTable *table)
|
||||
{
|
||||
if (!table) return;
|
||||
if (table->parent || table->invisible) return; /* children dont need refcounts */
|
||||
g_return_if_fail (table->refcount > 0);
|
||||
gncTaxTableBeginEdit (table);
|
||||
table->refcount--;
|
||||
g_return_if_fail (table->refcount >= 0);
|
||||
mark_table (table);
|
||||
gncTaxTableCommitEdit (table);
|
||||
}
|
||||
|
||||
void gncTaxTableSetRefcount (GncTaxTable *table, gint64 refcount)
|
||||
{
|
||||
if (!table) return;
|
||||
g_return_if_fail (refcount >= 0);
|
||||
gncTaxTableBeginEdit (table);
|
||||
table->refcount = refcount;
|
||||
mark_table (table);
|
||||
gncTaxTableCommitEdit (table);
|
||||
}
|
||||
|
||||
void gncTaxTableMakeInvisible (GncTaxTable *table)
|
||||
|
Loading…
Reference in New Issue
Block a user