Bug #682280 - bill/invoice importer fails to save imported bills/invoices

The first attempt to commit when creating the invoice failed because
the commodity had not yet been set. Wrapped the creation routine in
begin/commit to allow the invoice to be fully populated before trying
to write the DB.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23166 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2013-09-13 23:36:22 +00:00
parent c7f6d0e6e0
commit 818c00630d

View File

@ -562,6 +562,9 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
{
// new invoice
invoice = gncInvoiceCreate (book);
/* Protect against thrashing the DB and trying to write the invoice
* record prematurely */
gncInvoiceBeginEdit (invoice);
gncInvoiceSetID (invoice, id);
owner = gncOwnerNew ();
if (g_ascii_strcasecmp (type, "BILL") == 0)
@ -601,6 +604,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
iw = gnc_ui_invoice_edit (invoice);
gnc_plugin_page_invoice_new (iw);
}
gncInvoiceCommitEdit (invoice);
}
// I want to warn the user that an existing billvoice exists, but not every
// time.