mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
From Budget editor, add toolbar and Edit menu to run budget report
This parallels the invoice editor "Print Invoice" functionality. Runs the budget report using current budget.
This commit is contained in:
@@ -42,7 +42,11 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include "gnc-date-edit.h"
|
||||
|
||||
#include "swig-runtime.h"
|
||||
#include "libguile.h"
|
||||
|
||||
#include "gnc-plugin-page-register.h"
|
||||
#include "gnc-plugin-page-report.h"
|
||||
#include "gnc-budget.h"
|
||||
#include "gnc-features.h"
|
||||
|
||||
@@ -127,6 +131,8 @@ static void gnc_plugin_page_budget_cmd_refresh (GtkAction *action,
|
||||
GncPluginPageBudget *page);
|
||||
static void gnc_plugin_page_budget_cmd_budget_note (GtkAction *action,
|
||||
GncPluginPageBudget *page);
|
||||
static void gnc_plugin_page_budget_cmd_budget_report (GtkAction *action,
|
||||
GncPluginPageBudget *page);
|
||||
static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data);
|
||||
|
||||
@@ -177,6 +183,12 @@ static GtkActionEntry gnc_plugin_page_budget_actions [] =
|
||||
N_("Edit note for the selected account and period"),
|
||||
G_CALLBACK (gnc_plugin_page_budget_cmd_budget_note)
|
||||
},
|
||||
{
|
||||
"BudgetReportAction", "system-run", N_("Budget Report"),
|
||||
NULL,
|
||||
N_("Run budget report"),
|
||||
G_CALLBACK (gnc_plugin_page_budget_cmd_budget_report)
|
||||
},
|
||||
/* View menu */
|
||||
{
|
||||
"ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
|
||||
@@ -211,6 +223,7 @@ static action_toolbar_labels toolbar_labels[] =
|
||||
{ "EstimateBudgetAction", N_("Estimate") },
|
||||
{ "AllPeriodsBudgetAction", N_("All Periods") },
|
||||
{ "BudgetNoteAction", N_("Note") },
|
||||
{ "BudgetReportAction", N_("Run Report") },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
@@ -250,6 +263,8 @@ typedef struct GncPluginPageBudgetPrivate
|
||||
gnc_numeric allValue;
|
||||
allperiods_action action;
|
||||
|
||||
/* the cached reportPage for this budget */
|
||||
GncPluginPage *reportPage;
|
||||
} GncPluginPageBudgetPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(GncPluginPageBudget, gnc_plugin_page_budget, GNC_TYPE_PLUGIN_PAGE)
|
||||
@@ -289,6 +304,7 @@ gnc_plugin_page_budget_new (GncBudget *budget)
|
||||
priv->budget = budget;
|
||||
priv->delete_budget = FALSE;
|
||||
priv->key = *gnc_budget_get_guid (budget);
|
||||
priv->reportPage = NULL;
|
||||
label = g_strdup_printf ("%s: %s", _("Budget"), gnc_budget_get_name (budget));
|
||||
g_object_set (G_OBJECT(plugin_page), "page-name", label, NULL);
|
||||
g_free (label);
|
||||
@@ -1268,6 +1284,38 @@ gnc_plugin_page_budget_cmd_budget_note(GtkAction *action,
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_budget_cmd_budget_report (GtkAction *action,
|
||||
GncPluginPageBudget *page)
|
||||
{
|
||||
GncPluginPageBudgetPrivate *priv;
|
||||
|
||||
g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET (page));
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE (page);
|
||||
|
||||
if (priv->reportPage && GNC_IS_PLUGIN_PAGE (priv->reportPage))
|
||||
gnc_plugin_page_report_reload (GNC_PLUGIN_PAGE_REPORT (priv->reportPage));
|
||||
else
|
||||
{
|
||||
SCM func = scm_c_eval_string ("gnc:budget-report-create");
|
||||
SCM arg = SWIG_NewPointerObj (priv->budget, SWIG_TypeQuery ("_p_budget_s"), 0);
|
||||
int report_id;
|
||||
|
||||
g_return_if_fail (scm_is_procedure (func));
|
||||
|
||||
arg = scm_apply_0 (func, scm_list_1 (arg));
|
||||
g_return_if_fail (scm_is_exact (arg));
|
||||
|
||||
report_id = scm_to_int (arg);
|
||||
g_return_if_fail (report_id >= 0);
|
||||
|
||||
priv->reportPage = gnc_plugin_page_report_new (report_id);
|
||||
}
|
||||
|
||||
gnc_main_window_open_page (GNC_MAIN_WINDOW (priv->dialog), priv->reportPage);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action,
|
||||
GncPluginPageBudget *page)
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
(use-modules (gnucash reports standard new-aging))
|
||||
(use-modules (gnucash reports standard new-owner-report))
|
||||
|
||||
(export gnc:budget-report-create)
|
||||
(export gnc:register-report-create)
|
||||
(export gnc:invoice-report-create)
|
||||
(export gnc:payables-report-create)
|
||||
@@ -78,6 +79,15 @@
|
||||
0
|
||||
))
|
||||
|
||||
(define budget-ID "810ed4b25ef0486ea43bbd3dddb32b11")
|
||||
(define (gnc:budget-report-create budget)
|
||||
(if (gnc:find-report-template budget-ID)
|
||||
(let* ((options (gnc:make-report-options budget-ID))
|
||||
(bgt-op (gnc:lookup-option options gnc:pagename-general "Budget")))
|
||||
(gnc:option-set-value bgt-op budget)
|
||||
(gnc:make-report budget-ID options))
|
||||
-1))
|
||||
|
||||
(define gnc:payables-report-create payables-report-create-internal)
|
||||
(define gnc:receivables-report-create receivables-report-create-internal)
|
||||
(define gnc:owner-report-create owner-report-create)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<menuitem name="AllPeriods" action="AllPeriodsBudgetAction"/>
|
||||
<menuitem name="Delete" action="DeleteBudgetAction"/>
|
||||
<menuitem name="Note" action="BudgetNoteAction"/>
|
||||
<menuitem name="Report" action="BudgetReportAction"/>
|
||||
</placeholder>
|
||||
<menuitem name="Options" action="OptionsBudgetAction"/>
|
||||
</menu>
|
||||
@@ -30,6 +31,7 @@
|
||||
<toolitem name="AllPeriods" action="AllPeriodsBudgetAction"/>
|
||||
<toolitem name="Delete" action="DeleteBudgetAction"/>
|
||||
<toolitem name="Note" action="BudgetNoteAction"/>
|
||||
<toolitem name="Report" action="BudgetReportAction"/>
|
||||
</placeholder>
|
||||
</toolbar>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user