From 818c00630d1547b77c51ecba37e7141745cb0e2d Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 13 Sep 2013 23:36:22 +0000 Subject: [PATCH] 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 --- src/plugins/bi_import/dialog-bi-import.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c index e3aa74e03d..af36c4a398 100644 --- a/src/plugins/bi_import/dialog-bi-import.c +++ b/src/plugins/bi_import/dialog-bi-import.c @@ -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.