r20775 - gnucash/trunk/src/business/business-gnome - Owner Tree: add menu to open owner report (Vendor/Customer/Employee)
Geert Janssens
gjanssens at code.gnucash.org
Sun Jun 19 17:31:58 EDT 2011
Author: gjanssens
Date: 2011-06-19 17:31:57 -0400 (Sun, 19 Jun 2011)
New Revision: 20775
Trac: http://svn.gnucash.org/trac/changeset/20775
Modified:
gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
gnucash/trunk/src/business/business-gnome/ui/gnc-plugin-page-owner-tree-ui.xml
Log:
Owner Tree: add menu to open owner report (Vendor/Customer/Employee)
And some small tweaks to the owner listing report
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c 2011-06-19 21:31:48 UTC (rev 20774)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c 2011-06-19 21:31:57 UTC (rev 20775)
@@ -123,7 +123,8 @@
static void gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwnerTree *page);
static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageOwnerTree *page);
static void gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, GncPluginPageOwnerTree *page);
-static void gnc_plugin_page_owner_tree_cmd_listing_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page);
+static void gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page);
+static void gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page);
static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
@@ -177,14 +178,29 @@
},
{
"VendorListingReportAction", GTK_STOCK_PRINT_PREVIEW, N_("Vendor Listing"), NULL,
- N_("Show vendor aging overview"),
- G_CALLBACK (gnc_plugin_page_owner_tree_cmd_listing_report)
+ N_("Show vendor aging overview for all vendors"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report)
},
{
"CustomerListingReportAction", GTK_STOCK_PRINT_PREVIEW, N_("Customer Listing"), NULL,
- N_("Show customer aging overview"),
- G_CALLBACK (gnc_plugin_page_owner_tree_cmd_listing_report)
+ N_("Show customer aging overview for all customers"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report)
},
+ {
+ "OTVendorReportAction", NULL, N_("Vendor Report"), NULL,
+ N_("Show vendor report"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
+ },
+ {
+ "OTCustomerReportAction", NULL, N_("Customer Report"), NULL,
+ N_("Show customer report"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
+ },
+ {
+ "OTEmployeeReportAction", NULL, N_("Employee Report"), NULL,
+ N_("Show employee report"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
+ },
};
/** The number of actions provided by this plugin. */
static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_owner_tree_actions);
@@ -195,6 +211,9 @@
static const gchar *actions_requiring_owner[] =
{
"EditEditOwnerAction",
+ "OTVendorReportAction",
+ "OTCustomerReportAction",
+ "OTEmployeeReportAction",
/* FIXME disabled due to crash "EditDeleteOwnerAction", */
NULL
};
@@ -232,6 +251,9 @@
{ "BusinessNewVoucherAction", GNC_OWNER_EMPLOYEE },
{ "VendorListingReportAction", GNC_OWNER_VENDOR },
{ "CustomerListingReportAction", GNC_OWNER_CUSTOMER },
+ { "OTVendorReportAction", GNC_OWNER_VENDOR },
+ { "OTCustomerReportAction", GNC_OWNER_CUSTOMER },
+ { "OTEmployeeReportAction", GNC_OWNER_EMPLOYEE },
{ NULL, GNC_OWNER_NONE },
};
@@ -841,6 +863,45 @@
return scm_num2int (arg, SCM_ARG1, G_STRFUNC);
}
+static int build_owner_report (GncOwner *owner, Account *acc)
+{
+ int id;
+ SCM args;
+ SCM func;
+ SCM arg;
+
+ g_return_val_if_fail (owner, -1);
+
+ args = SCM_EOL;
+
+ func = scm_c_eval_string ("gnc:owner-report-create");
+ g_return_val_if_fail (scm_is_procedure (func), -1);
+
+ if (acc)
+ {
+ swig_type_info * qtype = SWIG_TypeQuery("_p_Account");
+ g_return_val_if_fail (qtype, -1);
+
+ arg = SWIG_NewPointerObj(acc, qtype, 0);
+ g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
+ args = scm_cons (arg, args);
+ }
+ else
+ {
+ args = scm_cons (SCM_BOOL_F, args);
+ }
+
+ arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery("_p__gncOwner"), 0);
+ g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
+ args = scm_cons (arg, args);
+
+ /* Apply the function to the args */
+ arg = scm_apply (func, args, SCM_EOL);
+ g_return_val_if_fail (scm_is_exact (arg), -1);
+ return scm_num2int (arg, SCM_ARG1, G_STRFUNC);
+}
+
+
/************************************************************/
/* Command callbacks */
/************************************************************/
@@ -1030,24 +1091,50 @@
}
static void
-gnc_plugin_page_owner_tree_cmd_listing_report (GtkAction *action,
+gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action,
GncPluginPageOwnerTree *plugin_page)
{
GncPluginPageOwnerTreePrivate *priv;
- GncMainWindow *window;
int id;
ENTER("(action %p, plugin_page %p)", action, plugin_page);
g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
- window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
id = build_aging_report (priv->owner_type);
if (id >= 0)
+ {
+ GncMainWindow *window;
+ window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
gnc_main_window_open_report(id, window);
+ }
+
LEAVE(" ");
}
+static void
+gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action,
+ GncPluginPageOwnerTree *plugin_page)
+{
+ GncOwner *current_owner;
+ int id;
+
+ ENTER("(action %p, plugin_page %p)", action, plugin_page);
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
+
+ current_owner = gnc_plugin_page_owner_tree_get_current_owner (plugin_page);
+ id = build_owner_report (current_owner, NULL);
+ if (id >= 0)
+ {
+ GncMainWindow *window;
+ window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
+ gnc_main_window_open_report(id, window);
+ }
+
+ LEAVE(" ");
+}
+
/** @} */
/** @} */
Modified: gnucash/trunk/src/business/business-gnome/ui/gnc-plugin-page-owner-tree-ui.xml
===================================================================
--- gnucash/trunk/src/business/business-gnome/ui/gnc-plugin-page-owner-tree-ui.xml 2011-06-19 21:31:48 UTC (rev 20774)
+++ gnucash/trunk/src/business/business-gnome/ui/gnc-plugin-page-owner-tree-ui.xml 2011-06-19 21:31:57 UTC (rev 20775)
@@ -10,8 +10,11 @@
<menu name="Reports" action="ReportsAction">
<placeholder name="OtherReports">
- <menuitem name="VendorListingReport" action="VendorListingReportAction"/>
- <menuitem name="CustomerListingReport" action="CustomerListingReportAction"/>
+ <menuitem name="ReportVendorListingReport" action="VendorListingReportAction"/>
+ <menuitem name="ReportCustomerListingReport" action="CustomerListingReportAction"/>
+ <menuitem name="ReportOTVendorReport" action="OTVendorReportAction"/>
+ <menuitem name="ReportOTCustomerReport" action="OTCustomerReportAction"/>
+ <menuitem name="ReportOTEmployeeReport" action="OTEmployeeReportAction"/>
</placeholder>
</menu>
</menubar>
@@ -38,6 +41,9 @@
<menuitem name="NewBill" action="BusinessNewBillAction"/>
<menuitem name="NewInvoice" action="BusinessNewInvoiceAction"/>
<menuitem name="NewVoucher" action="BusinessNewVoucherAction"/>
+ <menuitem name="OTVendorReport" action="OTVendorReportAction"/>
+ <menuitem name="OTCustomerReport" action="OTCustomerReportAction"/>
+ <menuitem name="OTEmployeeReport" action="OTEmployeeReportAction"/>
</placeholder>
</popup>
</ui>
More information about the gnucash-changes
mailing list