r20766 - gnucash/trunk/src - Owner Tree: add vendor/customer listing buttons/menu items
Geert Janssens
gjanssens at code.gnucash.org
Sat Jun 18 08:59:37 EDT 2011
Author: gjanssens
Date: 2011-06-18 08:59:36 -0400 (Sat, 18 Jun 2011)
New Revision: 20766
Trac: http://svn.gnucash.org/trac/changeset/20766
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
gnucash/trunk/src/report/business-reports/aging.scm
gnucash/trunk/src/report/business-reports/business-reports.scm
gnucash/trunk/src/report/business-reports/payables.scm
gnucash/trunk/src/report/business-reports/receivables.scm
Log:
Owner Tree: add vendor/customer listing buttons/menu items
These are shortcuts to the payable/receivable aging reports with
slightly different default presets.
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-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c 2011-06-18 12:59:36 UTC (rev 20766)
@@ -35,8 +35,11 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include "swig-runtime.h"
+
#include "gnc-plugin.h"
#include "gnc-plugin-page-owner-tree.h"
+#include "gnc-plugin-page-report.h"
#include "dialog-vendor.h"
#include "dialog-customer.h"
@@ -120,6 +123,7 @@
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 guint plugin_page_signals[LAST_SIGNAL] = { 0 };
@@ -171,6 +175,16 @@
N_("Create a new voucher"),
G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice)
},
+ {
+ "VendorListingReportAction", GTK_STOCK_PRINT_PREVIEW, N_("Vendor Listing"), NULL,
+ N_("Show vendor aging overview"),
+ G_CALLBACK (gnc_plugin_page_owner_tree_cmd_listing_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)
+ },
};
/** 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);
@@ -189,11 +203,13 @@
/** Short labels for use on the toolbar buttons. */
static action_toolbar_labels toolbar_labels[] =
{
- { "EditEditOwnerAction", N_("Edit") },
- { "BusinessNewOwnerAction", N_("New") },
- { "BusinessNewBillAction", N_("New Bill") },
- { "BusinessNewInvoiceAction", N_("New Invoice") },
- { "BusinessNewVoucherAction", N_("New Voucher") },
+ { "EditEditOwnerAction", N_("Edit") },
+ { "BusinessNewOwnerAction", N_("New") },
+ { "BusinessNewBillAction", N_("New Bill") },
+ { "BusinessNewInvoiceAction", N_("New Invoice") },
+ { "BusinessNewVoucherAction", N_("New Voucher") },
+ { "VendorListingReportAction", N_("Vendor Listing") },
+ { "CustomerListingReportAction", N_("Customer Listing") },
/* FIXME disable due to crash { "EditDeleteOwnerAction", N_("Delete") },*/
{ NULL, NULL },
};
@@ -211,9 +227,11 @@
static action_owners_struct action_owners[] =
{
- { "BusinessNewBillAction", GNC_OWNER_VENDOR },
- { "BusinessNewInvoiceAction", GNC_OWNER_CUSTOMER },
- { "BusinessNewVoucherAction", GNC_OWNER_EMPLOYEE },
+ { "BusinessNewBillAction", GNC_OWNER_VENDOR },
+ { "BusinessNewInvoiceAction", GNC_OWNER_CUSTOMER },
+ { "BusinessNewVoucherAction", GNC_OWNER_EMPLOYEE },
+ { "VendorListingReportAction", GNC_OWNER_VENDOR },
+ { "CustomerListingReportAction", GNC_OWNER_CUSTOMER },
{ NULL, GNC_OWNER_NONE },
};
@@ -754,7 +772,75 @@
g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
}
+/******************************************************************/
+/* Report helper functions */
+/******************************************************************/
+static int
+build_aging_report (GncOwnerType owner_type)
+{
+ Account *account;
+ gchar *report_name = NULL;
+ gchar *report_title = NULL;
+ swig_type_info * qtype;
+ SCM args;
+ SCM func;
+ SCM arg;
+
+ args = SCM_EOL;
+
+ switch(owner_type)
+ {
+ case GNC_OWNER_NONE :
+ case GNC_OWNER_UNDEFINED :
+ case GNC_OWNER_EMPLOYEE :
+ case GNC_OWNER_JOB :
+ {
+ return -1;
+ }
+ case GNC_OWNER_VENDOR :
+ {
+ report_name = "gnc:payables-report-create";
+ report_title = _("Vendor Listing");
+ break;
+ }
+ case GNC_OWNER_CUSTOMER :
+ {
+ report_name = "gnc:receivables-report-create";
+ report_title = _("Customer Listing");
+ break;
+ }
+ }
+
+ /* Find report generator function in guile */
+ func = scm_c_eval_string (report_name);
+ g_return_val_if_fail (scm_is_procedure (func), -1);
+
+ /* Option Show zero's ? - Yes for the listing report */
+ arg = SCM_BOOL_T;
+ args = scm_cons (arg, args);
+ g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
+
+ /* Option Report title */
+ arg = scm_makfrom0str (report_title);
+ args = scm_cons (arg, args);
+
+ /* Option Account - Using False to select default account
+ *
+ * XXX I'm not sure if it would make sense to use another
+ * account than default */
+ arg = SCM_BOOL_F;
+ args = scm_cons (arg, args);
+ g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
+
+
+ /* 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 */
/************************************************************/
@@ -942,5 +1028,26 @@
LEAVE(" ");
}
+
+static void
+gnc_plugin_page_owner_tree_cmd_listing_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)
+ 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-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/business/business-gnome/ui/gnc-plugin-page-owner-tree-ui.xml 2011-06-18 12:59:36 UTC (rev 20766)
@@ -2,33 +2,42 @@
<menubar>
<menu name="Edit" action="EditAction">
<placeholder name="EditSelectedPlaceholder">
- <menuitem name="EditEditOwner" action="EditEditOwnerAction"/>
+ <menuitem name="EditEditOwner" action="EditEditOwnerAction"/>
<!-- <menuitem name="EditDeleteOwner" action="EditDeleteOwnerAction"/> -->
- <menuitem name="EditNewOwner" action="BusinessNewOwnerAction"/>
+ <menuitem name="EditNewOwner" action="BusinessNewOwnerAction"/>
</placeholder>
</menu>
+
+ <menu name="Reports" action="ReportsAction">
+ <placeholder name="OtherReports">
+ <menuitem name="VendorListingReport" action="VendorListingReportAction"/>
+ <menuitem name="CustomerListingReport" action="CustomerListingReportAction"/>
+ </placeholder>
+ </menu>
</menubar>
<toolbar name="DefaultToolbar">
<placeholder name="DefaultToolbarPlaceholder">
- <toolitem name="ToolbarNewOwner" action="BusinessNewOwnerAction"/>
- <toolitem name="ToolbarEditOwner" action="EditEditOwnerAction"/>
+ <toolitem name="ToolbarNewOwner" action="BusinessNewOwnerAction"/>
+ <toolitem name="ToolbarEditOwner" action="EditEditOwnerAction"/>
<!-- <toolitem name="ToolbarDeleteOwner" action="EditDeleteOwnerAction"/> -->
<separator name="ToolbarSep168"/>
- <toolitem name="ToolbarNewBill" action="BusinessNewBillAction"/>
- <toolitem name="ToolbarNewInvoice" action="BusinessNewInvoiceAction"/>
- <toolitem name="ToolbarNewVoucher" action="BusinessNewVoucherAction"/>
+ <toolitem name="ToolbarNewBill" action="BusinessNewBillAction"/>
+ <toolitem name="ToolbarNewInvoice" action="BusinessNewInvoiceAction"/>
+ <toolitem name="ToolbarNewVoucher" action="BusinessNewVoucherAction"/>
+ <toolitem name="ToolbarVendorListing" action="VendorListingReportAction"/>
+ <toolitem name="ToolbarCustomerListing" action="CustomerListingReportAction"/>
</placeholder>
</toolbar>
- <popup name="MainPopup" action="FakeToplevel">
+ <popup name="MainPopup" action="FakeToplevel">
<placeholder name="PopupPlaceholder2">
- <menuitem name="EditOwner" action="EditEditOwnerAction"/>
-<!-- <menuitem name="DeleteOwner" action="EditDeleteOwnerAction"/> -->
+ <menuitem name="EditOwner" action="EditEditOwnerAction"/>
+<!-- <menuitem name="DeleteOwner" action="EditDeleteOwnerAction"/> -->
<separator name="ToolbarSep169"/>
- <menuitem name="NewBill" action="BusinessNewBillAction"/>
- <menuitem name="NewInvoice" action="BusinessNewInvoiceAction"/>
- <menuitem name="NewVoucher" action="BusinessNewVoucherAction"/>
+ <menuitem name="NewBill" action="BusinessNewBillAction"/>
+ <menuitem name="NewInvoice" action="BusinessNewInvoiceAction"/>
+ <menuitem name="NewVoucher" action="BusinessNewVoucherAction"/>
</placeholder>
</popup>
</ui>
Modified: gnucash/trunk/src/report/business-reports/aging.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/aging.scm 2011-06-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/report/business-reports/aging.scm 2011-06-18 12:59:36 UTC (rev 20766)
@@ -45,6 +45,8 @@
(define optname-show-zeros (N_ "Show zero balance items"))
(define optname-date-driver (N_ "Due or Post Date"))
+(export optname-show-zeros)
+
;; The idea is: have a hash with the key being the contact name
;; (In future this might be GUID'ed, but for now it's a string
;; from the description or the split memo.
Modified: gnucash/trunk/src/report/business-reports/business-reports.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/business-reports.scm 2011-06-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/report/business-reports/business-reports.scm 2011-06-18 12:59:36 UTC (rev 20766)
@@ -111,7 +111,14 @@
(define gnc:invoice-report-create gnc:invoice-report-create-internal)
+(define (gnc:payables-report-create account title show-zeros?)
+ (payables-report-create-internal account title show-zeros?))
+
+(define (gnc:receivables-report-create account title show-zeros?)
+ (receivables-report-create-internal account title show-zeros?))
+
(export gnc:invoice-report-create
gnc:customer-anchor-text gnc:job-anchor-text gnc:vendor-anchor-text
- gnc:invoice-anchor-text gnc:owner-anchor-text gnc:owner-report-text)
+ gnc:invoice-anchor-text gnc:owner-anchor-text gnc:owner-report-text
+ gnc:payables-report-create gnc:receivables-report-create)
(re-export gnc:owner-report-create)
Modified: gnucash/trunk/src/report/business-reports/payables.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/payables.scm 2011-06-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/report/business-reports/payables.scm 2011-06-18 12:59:36 UTC (rev 20766)
@@ -73,17 +73,23 @@
'renderer payables-renderer
'in-menu? #t)
-(define (payables-report-create-internal acct)
+(define (payables-report-create-internal acct title show-zeros?)
(let* ((options (gnc:make-report-options payables-aging-guid))
- (acct-op (gnc:lookup-option options acc-page this-acc)))
+ (acct-op (gnc:lookup-option options acc-page this-acc))
+ (zero-op (gnc:lookup-option options acc-page optname-show-zeros))
+ (title-op (gnc:lookup-option options acc-page gnc:optname-reportname)))
(gnc:option-set-value acct-op acct)
+ (gnc:option-set-value title-op title)
+ (gnc:option-set-value zero-op show-zeros?)
(gnc:make-report payables-aging-guid options)))
(define (gnc:payables-report-create-internal
account split query journal? double? title
debit-string credit-string)
- (payables-report-create-internal account))
+ (payables-report-create-internal account #f #f))
(gnc:register-report-hook ACCT-TYPE-PAYABLE #f
gnc:payables-report-create-internal)
+
+(export payables-report-create-internal)
\ No newline at end of file
Modified: gnucash/trunk/src/report/business-reports/receivables.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/receivables.scm 2011-06-18 12:59:27 UTC (rev 20765)
+++ gnucash/trunk/src/report/business-reports/receivables.scm 2011-06-18 12:59:36 UTC (rev 20766)
@@ -74,17 +74,23 @@
'renderer receivables-renderer
'in-menu? #t)
-(define (receivables-report-create-internal acct)
+(define (receivables-report-create-internal acct title show-zeros?)
(let* ((options (gnc:make-report-options receivables-aging-guid))
- (acct-op (gnc:lookup-option options acc-page this-acc)))
+ (acct-op (gnc:lookup-option options acc-page this-acc))
+ (zero-op (gnc:lookup-option options acc-page optname-show-zeros))
+ (title-op (gnc:lookup-option options acc-page gnc:optname-reportname)))
(gnc:option-set-value acct-op acct)
+ (gnc:option-set-value title-op title)
+ (gnc:option-set-value zero-op show-zeros?)
(gnc:make-report receivables-aging-guid options)))
(define (gnc:receivables-report-create-internal
account split query journal? double? title
debit-string credit-string)
- (receivables-report-create-internal account))
+ (receivables-report-create-internal account #f #f))
(gnc:register-report-hook ACCT-TYPE-RECEIVABLE #f
gnc:receivables-report-create-internal)
+
+(export receivables-report-create-internal)
More information about the gnucash-changes
mailing list