mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Bug 736765 - Assign as payment... should re-populate the payment represented by the selected transaction if any
The main topic of this bug was already fixed in earlier commits. This commit handles the minor improvements also mentioned here: - don't show the menu option for invoice/bill transactions as that doesn't make sense - don't show the pre-payment line if the selected transaction was one, in this case only set the amount - allow users to edit lot link transactions via this mechanism as well (which essentially are payments without an explicit payment split)
This commit is contained in:
parent
949f2db473
commit
75fb4e7a0c
@ -541,7 +541,10 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (gnc_numeric_positive_p (value))
|
||||
if (gnc_numeric_zero_p (value))
|
||||
/* If the lot's balance is 0 after the above compensation, skip this lot */
|
||||
continue;
|
||||
else if (gnc_numeric_positive_p (value))
|
||||
debit = value;
|
||||
else
|
||||
credit = gnc_numeric_neg (value);
|
||||
@ -1473,16 +1476,23 @@ static char *gen_split_desc (Transaction *txn, Split *split)
|
||||
|
||||
static Split *select_payment_split (GtkWidget *parent, Transaction *txn)
|
||||
{
|
||||
/* We require the txn to have one split in an Asset account.
|
||||
* The only exception would be a lot link transaction
|
||||
*/
|
||||
GList *payment_splits = xaccTransGetPaymentAcctSplitList (txn);
|
||||
if (!payment_splits)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(parent),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s",
|
||||
_("The selected transaction doesn't have splits that can be assigned as a payment"));
|
||||
if (xaccTransGetTxnType(txn) == TXN_TYPE_LINK)
|
||||
return NULL;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW(parent),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s",
|
||||
_("The selected transaction doesn't have splits that can be assigned as a payment"));
|
||||
gtk_dialog_run (GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.",
|
||||
@ -1647,12 +1657,14 @@ PaymentWindow * gnc_ui_payment_new_with_txn (GtkWidget* parent, GncOwner *owner,
|
||||
if (!txn)
|
||||
return NULL;
|
||||
|
||||
// We require the txn to have one split in an Asset account.
|
||||
if (!xaccTransGetSplitList(txn))
|
||||
return NULL;
|
||||
|
||||
/* We require the txn to have one split in an Asset account.
|
||||
* The only exception would be a lot link transaction
|
||||
*/
|
||||
payment_split = select_payment_split (parent, txn);
|
||||
if (!payment_split)
|
||||
if (!payment_split && (xaccTransGetTxnType(txn) != TXN_TYPE_LINK))
|
||||
return NULL;
|
||||
|
||||
/* Get all APAR related lots. Watch out: there might be none */
|
||||
@ -1678,6 +1690,7 @@ PaymentWindow * gnc_ui_payment_new_with_txn (GtkWidget* parent, GncOwner *owner,
|
||||
gnc_ui_payment_window_set_date(pw, &txn_date);
|
||||
}
|
||||
gnc_ui_payment_window_set_amount(pw, xaccSplitGetValue(payment_split));
|
||||
gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(payment_split));
|
||||
if (payment_split)
|
||||
gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(payment_split));
|
||||
return pw;
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page)
|
||||
{
|
||||
GncMainWindow *window;
|
||||
GtkActionGroup *action_group;
|
||||
gboolean is_txn_register, is_bus_txn = FALSE;
|
||||
gboolean is_txn_register, is_bus_txn = FALSE, is_bus_doc = FALSE;
|
||||
|
||||
// We continue only if the current page is a plugin page
|
||||
if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
|
||||
@ -921,16 +921,17 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page)
|
||||
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);
|
||||
is_bus_doc = (xaccTransGetTxnType (trans) == TXN_TYPE_INVOICE);
|
||||
}
|
||||
// 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 && !is_bus_txn);
|
||||
"sensitive", is_txn_register && !is_bus_txn && !is_bus_doc);
|
||||
gnc_plugin_update_actions (action_group, register_txn_actions,
|
||||
"visible", is_txn_register && !is_bus_txn);
|
||||
"visible", is_txn_register && !is_bus_txn && !is_bus_doc);
|
||||
gnc_plugin_update_actions (action_group, register_bus_txn_actions,
|
||||
"sensitive", is_txn_register && is_bus_txn);
|
||||
"sensitive", is_txn_register && is_bus_txn && !is_bus_doc);
|
||||
gnc_plugin_update_actions (action_group, register_bus_txn_actions,
|
||||
"visible", is_txn_register && is_bus_txn);
|
||||
"visible", is_txn_register && is_bus_txn && !is_bus_doc);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user