r23398 - gnucash/trunk/src - Don't create invoice when Duplicate invoice dialog is cancelled
Geert Janssens
gjanssens at code.gnucash.org
Sat Nov 16 07:51:55 EST 2013
Author: gjanssens
Date: 2013-11-16 07:51:54 -0500 (Sat, 16 Nov 2013)
New Revision: 23398
Trac: http://svn.gnucash.org/trac/changeset/23398
Modified:
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/engine/gncInvoice.c
gnucash/trunk/src/engine/gncInvoice.h
Log:
Don't create invoice when Duplicate invoice dialog is cancelled
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2013-11-15 22:02:34 UTC (rev 23397)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2013-11-16 12:51:54 UTC (rev 23398)
@@ -463,8 +463,10 @@
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 ();
Modified: gnucash/trunk/src/engine/gncInvoice.c
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.c 2013-11-15 22:02:34 UTC (rev 23397)
+++ gnucash/trunk/src/engine/gncInvoice.c 2013-11-16 12:51:54 UTC (rev 23398)
@@ -691,6 +691,43 @@
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 */
Modified: gnucash/trunk/src/engine/gncInvoice.h
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.h 2013-11-15 22:02:34 UTC (rev 23397)
+++ gnucash/trunk/src/engine/gncInvoice.h 2013-11-16 12:51:54 UTC (rev 23398)
@@ -127,6 +127,11 @@
*/
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);
More information about the gnucash-changes
mailing list