Don't create invoice when Duplicate invoice dialog is cancelled

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23398 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2013-11-16 12:51:54 +00:00
parent f205698311
commit 6692d4bb1b
3 changed files with 45 additions and 1 deletions
+3 -1
View File
@@ -463,8 +463,10 @@ gnc_invoice_window_destroy_cb (GtkWidget *widget, gpointer data)
gnc_suspend_gui_refresh ();
if (iw->dialog_type == NEW_INVOICE && invoice != NULL)
if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
&& invoice != NULL)
{
gncInvoiceRemoveEntries (invoice);
gncInvoiceBeginEdit (invoice);
gncInvoiceDestroy (invoice);
iw->invoice_guid = *guid_null ();
+37
View File
@@ -691,6 +691,43 @@ void gncInvoiceSortEntries (GncInvoice *invoice)
gncInvoiceCommitEdit (invoice);
}
void gncInvoiceRemoveEntries (GncInvoice *invoice)
{
GList *node;
if (!invoice) return;
for (node = invoice->entries; node; node = node->next)
{
GncEntry *entry = node->data;
switch (gncInvoiceGetOwnerType (invoice))
{
case GNC_OWNER_VENDOR:
case GNC_OWNER_EMPLOYEE:
// this is a vendor bill, or an expense voucher
gncBillRemoveEntry (invoice, entry);
break;
case GNC_OWNER_CUSTOMER:
default:
// this is an invoice
gncInvoiceRemoveEntry (invoice, entry);
break;
}
/* If the entry is no longer referenced by any document,
* remove it.
*/
if (!(gncEntryGetInvoice (entry) ||
gncEntryGetBill (entry) ||
gncEntryGetOrder (entry)))
{
gncEntryBeginEdit (entry);
gncEntryDestroy (entry);
}
}
}
/* ================================================================== */
/* Get Functions */
+5
View File
@@ -127,6 +127,11 @@ void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry);
*/
void gncInvoiceSortEntries (GncInvoice *invoice);
/** Remove all entries from an invoice. To be called before
* destroying an invoice.
*/
void gncInvoiceRemoveEntries (GncInvoice *invoice);
/** @name Get Functions
@{ */
const char * gncInvoiceGetID (const GncInvoice *invoice);