gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat Mar 20 10:23:17 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/31a36b2b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d6082e1a (commit)
	from  https://github.com/Gnucash/gnucash/commit/e3254b93 (commit)



commit 31a36b2ba138cfec7ebd9cbcd5f17b4a047ecc3d
Merge: e3254b93b d6082e1a6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Mar 20 22:21:38 2021 +0800

    Merge branch 'maint-invoice-link-report' into maint #939


commit d6082e1a60da5179a9309ccccb96f5c26014d895
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Mar 14 21:45:15 2021 +0800

    [dialog-invoice] invoice editor reuses invoice report tab
    
    Similar to 9f4ba17d8 -- from invoice editor, click Print Invoice to
    create invoice report. This saves link to invoice, and reuses the
    report tab if Print Invoice is clicked again.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 5b329c95e..c443b9535 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -70,6 +70,7 @@
 
 #include "gnc-plugin-business.h"
 #include "gnc-plugin-page-invoice.h"
+#include "gnc-plugin-page-report.h"
 #include "gnc-main-window.h"
 #include "gnc-state.h"
 
@@ -211,6 +212,11 @@ struct _invoice_window
     GncOwner     proj_cust;
     GncOwner     proj_job;
 
+    /* the cached reportPage for this invoice. note this is not saved
+       into .gcm file therefore the invoice editor->report link is lost
+       upon restart. */
+    GncPluginPage *reportPage;
+
     /* for Unposting */
     gboolean     reset_tax_tables;
 };
@@ -781,13 +787,14 @@ gnc_invoice_window_blankCB (GtkWidget *widget, gpointer data)
     }
 }
 
-static void
+static GncPluginPage *
 gnc_invoice_window_print_invoice(GtkWindow *parent, GncInvoice *invoice)
 {
     SCM func, arg, arg2;
     SCM args = SCM_EOL;
     int report_id;
     const char *reportname = gnc_plugin_business_get_invoice_printreport();
+    GncPluginPage *reportPage = NULL;
 
     g_return_if_fail (invoice);
     if (!reportname)
@@ -808,13 +815,32 @@ gnc_invoice_window_print_invoice(GtkWindow *parent, GncInvoice *invoice)
 
     /* scm_gc_unprotect_object(func); */
     if (report_id >= 0)
-        reportWindow (report_id, parent);
+    {
+        reportPage = gnc_plugin_page_report_new (report_id);
+        gnc_main_window_open_page (GNC_MAIN_WINDOW (parent), reportPage);
+    }
+
+    return reportPage;
 }
+
+/* From the invoice editor, open the invoice report. This will reuse the
+   invoice report if generated from the current invoice editor. Note the
+   link is lost when GnuCash is restarted. This link may be restored
+   by: scan the current session tabs, identify reports, checking
+   whereby report's report-type matches an invoice report, and the
+   report's invoice option value matches the current invoice. */
 void
 gnc_invoice_window_printCB (GtkWindow* parent, gpointer data)
 {
     InvoiceWindow *iw = data;
-    gnc_invoice_window_print_invoice (parent, iw_get_invoice (iw));
+
+    if (iw->reportPage && GNC_IS_PLUGIN_PAGE (iw->reportPage))
+        gnc_plugin_page_report_reload (GNC_PLUGIN_PAGE_REPORT (iw->reportPage));
+    else
+        iw->reportPage = gnc_invoice_window_print_invoice
+            (parent, iw_get_invoice (iw));
+
+    gnc_main_window_open_page (GNC_MAIN_WINDOW (iw->dialog), iw->reportPage);
 }
 
 static gboolean
@@ -2895,6 +2921,7 @@ gnc_invoice_window_new_invoice (GtkWindow *parent, InvoiceDialogType dialog_type
                                       iw);
 
     /* Setup initial values */
+    iw->reportPage = NULL;
     iw->invoice_guid = *gncInvoiceGetGUID (invoice);
     iw->is_credit_note = gncInvoiceGetIsCreditNote (invoice);
 



Summary of changes:
 gnucash/gnome/dialog-invoice.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list