gnucash maint: Bug 476114 - Goto register by date feature req
Christopher Lam
clam at code.gnucash.org
Wed Sep 2 23:28:03 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/c1424164 (commit)
from https://github.com/Gnucash/gnucash/commit/befc4056 (commit)
commit c142416445d01e8a3a0389118ebfd0c21d3bccfe
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Sep 2 15:20:24 2020 +0800
Bug 476114 - Goto register by date feature req
Adds ability to jump to arbitrary date.
Finds first split whose posted date >= specified date, and jump to it.
diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index f8d4034b1..b75bf72af 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -232,6 +232,8 @@ static void gnc_plugin_page_register_cmd_delete_transaction (GtkAction* action,
GncPluginPageRegister* plugin_page);
static void gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action,
GncPluginPageRegister* plugin_page);
+static void gnc_plugin_page_register_cmd_goto_date (GtkAction* action,
+ GncPluginPageRegister* page);
static void gnc_plugin_page_register_cmd_duplicate_transaction (
GtkAction* action, GncPluginPageRegister* plugin_page);
static void gnc_plugin_page_register_cmd_reinitialize_transaction (
@@ -479,6 +481,11 @@ static GtkActionEntry gnc_plugin_page_register_actions [] =
N_ ("Move to the blank transaction at the bottom of the register"),
G_CALLBACK (gnc_plugin_page_register_cmd_blank_transaction)
},
+ {
+ "GotoDateAction", "x-office-calendar", N_ ("_Go to Date"), "<primary>G",
+ N_ ("Move to the the split at specified date"),
+ G_CALLBACK (gnc_plugin_page_register_cmd_goto_date)
+ },
{
"EditExchangeRateAction", NULL, N_ ("Edit E_xchange Rate"), NULL,
N_ ("Edit the exchange rate for the current transaction"),
@@ -4688,6 +4695,47 @@ gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action,
LEAVE (" ");
}
+static void
+gnc_plugin_page_register_cmd_goto_date (GtkAction* action,
+ GncPluginPageRegister* page)
+{
+ GNCSplitReg* gsr;
+ Query* query;
+ time64 date = gnc_time (NULL);
+ Split *split = NULL;
+
+ ENTER ("(action %p, plugin_page %p)", action, page);
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
+
+ if (!gnc_dup_time64_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)),
+ _("Go to Date"), _("Go to Date"), &date))
+ {
+ LEAVE ("goto_date cancelled");
+ return;
+ }
+
+ gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE (page));
+ query = gnc_plugin_page_register_get_query (GNC_PLUGIN_PAGE (page));
+
+ for (GList *lp = qof_query_run (query); lp; lp = lp->next)
+ {
+ if (xaccTransGetDate (xaccSplitGetParent (lp->data)) >= date)
+ {
+ split = lp->data;
+ break;
+ }
+ }
+
+ /* Test for visibility of split */
+ /* if (gnc_split_reg_clear_filter_for_split (gsr, split)) */
+ /* gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(page)); */
+
+ if (split)
+ gnc_split_reg_jump_to_split (gsr, split);
+
+ LEAVE (" ");
+}
+
static void
gnc_plugin_page_register_cmd_duplicate_transaction (GtkAction* action,
GncPluginPageRegister* plugin_page)
diff --git a/gnucash/ui/gnc-plugin-page-register-ui.xml b/gnucash/ui/gnc-plugin-page-register-ui.xml
index 50d111b46..500406c32 100644
--- a/gnucash/ui/gnc-plugin-page-register-ui.xml
+++ b/gnucash/ui/gnc-plugin-page-register-ui.xml
@@ -48,6 +48,7 @@
<menuitem name="ActionLots" action="ActionsLotsAction"/>
<separator name="ActionsSep4"/>
<menuitem name="BlankTransaction" action="BlankTransactionAction"/>
+ <menuitem name="GotoDate" action="GotoDateAction"/>
<menuitem name="SplitTransaction" action="SplitTransactionAction"/>
<menuitem name="EditExchangeRate" action="EditExchangeRateAction"/>
<menuitem name="ScheduleTransaction" action="ScheduleTransactionAction"/>
@@ -106,6 +107,7 @@
<menuitem name="JumpAssociateInvoice" action="JumpAssociatedInvoiceAction"/>
<separator name="PopupSep5"/>
<menuitem name="BlankTransaction" action="BlankTransactionAction"/>
+ <menuitem name="GotoDate" action="GotoDateAction"/>
<menuitem name="SplitTransaction" action="SplitTransactionAction"/>
<menuitem name="EditExchangeRate" action="EditExchangeRateAction"/>
<menuitem name="ScheduleTransaction" action="ScheduleTransactionAction"/>
Summary of changes:
gnucash/gnome/gnc-plugin-page-register.c | 48 ++++++++++++++++++++++++++++++
gnucash/ui/gnc-plugin-page-register-ui.xml | 2 ++
2 files changed, 50 insertions(+)
More information about the gnucash-changes
mailing list