mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
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:
@@ -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 ();
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user