mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Assign as payment - Differentiate between new and existing payments for 'Assign as payment'
When the selected transaction is already involved in a business payment, propose to Edit the payment instead of Assigning it as a payment. This is more informative and will help prevent users from accidentally replacing existing payments.
This commit is contained in:
parent
18dcbeef8a
commit
d66469fef8
@ -319,6 +319,11 @@ static GtkActionEntry gnc_plugin_actions [] =
|
||||
N_("Assign the selected transaction as payment"),
|
||||
G_CALLBACK (gnc_plugin_business_cmd_assign_payment)
|
||||
},
|
||||
{
|
||||
"RegisterEditPayment", NULL, N_("Edit payment..."), NULL,
|
||||
N_("Edit the payment this transaction is a part of"),
|
||||
G_CALLBACK (gnc_plugin_business_cmd_assign_payment)
|
||||
},
|
||||
};
|
||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||
|
||||
@ -888,12 +893,18 @@ static const gchar *register_txn_actions[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
static const gchar *register_bus_txn_actions[] =
|
||||
{
|
||||
"RegisterEditPayment",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
gnc_plugin_business_update_menus (GncPluginPage *plugin_page)
|
||||
{
|
||||
GncMainWindow *window;
|
||||
GtkActionGroup *action_group;
|
||||
gboolean is_txn_register;
|
||||
gboolean is_txn_register, is_bus_txn = FALSE;
|
||||
|
||||
// We continue only if the current page is a plugin page
|
||||
if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
|
||||
@ -905,11 +916,21 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page)
|
||||
action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
|
||||
g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
|
||||
|
||||
if (is_txn_register)
|
||||
{
|
||||
Transaction *trans = gnc_plugin_page_register_get_current_txn (GNC_PLUGIN_PAGE_REGISTER(plugin_page));
|
||||
if (xaccTransCountSplits(trans) > 0)
|
||||
is_bus_txn = (xaccTransGetFirstAPARAcctSplit(trans, TRUE) != NULL);
|
||||
}
|
||||
// Change visibility and also sensitivity according to whether we are in a txn register
|
||||
gnc_plugin_update_actions (action_group, register_txn_actions,
|
||||
"sensitive", is_txn_register);
|
||||
"sensitive", is_txn_register && !is_bus_txn);
|
||||
gnc_plugin_update_actions (action_group, register_txn_actions,
|
||||
"visible", is_txn_register);
|
||||
"visible", is_txn_register && !is_bus_txn);
|
||||
gnc_plugin_update_actions (action_group, register_bus_txn_actions,
|
||||
"sensitive", is_txn_register && is_bus_txn);
|
||||
gnc_plugin_update_actions (action_group, register_bus_txn_actions,
|
||||
"visible", is_txn_register && is_bus_txn);
|
||||
}
|
||||
|
||||
|
||||
@ -921,6 +942,12 @@ static void gnc_plugin_business_main_window_page_changed(GncMainWindow *window,
|
||||
update_inactive_actions(page);
|
||||
}
|
||||
|
||||
|
||||
void gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page)
|
||||
{
|
||||
gnc_plugin_business_main_window_page_changed(NULL, plugin_page, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_business_cmd_test_init_data (GtkAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
@ -1011,6 +1038,7 @@ static const gchar* readonly_inactive_actions[] =
|
||||
"EmployeeProcessPaymentAction",
|
||||
"ToolbarNewInvoiceAction",
|
||||
"RegisterAssignPayment",
|
||||
"RegisterEditPayment",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -66,4 +66,8 @@ void gnc_invoice_remind_bills_due_cb (void);
|
||||
void gnc_invoice_remind_invoices_due_cb (void);
|
||||
const char *gnc_plugin_business_get_invoice_printreport(void);
|
||||
|
||||
|
||||
void gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page);
|
||||
|
||||
|
||||
#endif /* __GNC_PLUGIN_BUSINESS_H */
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "gnc-plugin-register.h"
|
||||
#include "gnc-plugin-menu-additions.h"
|
||||
#include "gnc-plugin-page-report.h"
|
||||
#include "gnc-plugin-business.h"
|
||||
|
||||
#include "dialog-account.h"
|
||||
#include "dialog-find-account.h"
|
||||
@ -823,6 +824,17 @@ gnc_plugin_page_register_get_account (GncPluginPageRegister *page)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Transaction *
|
||||
gnc_plugin_page_register_get_current_txn (GncPluginPageRegister *page)
|
||||
{
|
||||
GncPluginPageRegisterPrivate *priv;
|
||||
SplitRegister *reg;
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
|
||||
reg = gnc_ledger_display_get_split_register(priv->ledger);
|
||||
return gnc_split_register_get_current_trans(reg);
|
||||
}
|
||||
|
||||
/* This is the list of actions which are switched inactive in a read-only book. */
|
||||
static const char* readonly_inactive_actions[] =
|
||||
{
|
||||
@ -949,10 +961,9 @@ gnc_plugin_page_register_ui_update (gpointer various, GncPluginPageRegister *pag
|
||||
uri = xaccTransGetAssociation(trans);
|
||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
|
||||
"ExecAssociatedTransactionAction");
|
||||
if (g_strcmp0 (uri, "") != 0 && g_strcmp0 (uri, NULL) != 0)
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), TRUE);
|
||||
else
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), FALSE);
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), (uri && *uri));
|
||||
|
||||
gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page));
|
||||
|
||||
/* If we are in a readonly book, make any modifying action inactive */
|
||||
if (qof_book_is_readonly(gnc_get_current_book()))
|
||||
|
@ -153,6 +153,16 @@ gnc_plugin_page_register_get_query (GncPluginPage *plugin_page);
|
||||
Account *
|
||||
gnc_plugin_page_register_get_account (GncPluginPageRegister *page);
|
||||
|
||||
/** Get the currently selected transaction in this register page.
|
||||
*
|
||||
* @param page A "register" page.
|
||||
*
|
||||
* @return The currently active transaction or NULL if there currently
|
||||
* is no currently selected.
|
||||
*/
|
||||
Transaction *
|
||||
gnc_plugin_page_register_get_current_txn (GncPluginPageRegister *page);
|
||||
|
||||
G_END_DECLS
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -2,7 +2,8 @@
|
||||
<menubar>
|
||||
<menu name="Edit" action="EditAction">
|
||||
<placeholder name="EditSelectedPlaceholder">
|
||||
<menuitem name="RegisterAssignPayment" action="RegisterAssignPayment"/>
|
||||
<menuitem name="RegisterAssignPayment" action="RegisterAssignPayment"/>
|
||||
<menuitem name="RegisterEditPayment" action="RegisterEditPayment"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
|
||||
@ -73,7 +74,8 @@
|
||||
<popup name="MainPopup" action="FakeToplevel">
|
||||
<!--separator name="PopupSep3"/-->
|
||||
<placeholder name="PopupPlaceholder3">
|
||||
<menuitem name="RegisterAssignPayment" action="RegisterAssignPayment"/>
|
||||
<menuitem name="RegisterAssignPayment" action="RegisterAssignPayment"/>
|
||||
<menuitem name="RegisterEditPayment" action="RegisterEditPayment"/>
|
||||
</placeholder>
|
||||
</popup>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user