mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 787295 - Allow UI jump from Business accounts to their relevant invoice/bill/voucher
Combine the best of both approaches and allow jumping to invoice if either - the current txn is an invoice transaction - the current split has an invoice associated with it Those are the only two conditions that allow us to uniquely identify an invoice from a register. A future extension could be to allow a jump if any split of the current txn has an invoice associated with it. This would need user interaction if more than one split is linked to an invoice. A payment transaction for example can pay more than one invoice and hence can have more than one invoice related split.
This commit is contained in:
parent
a019bb2f2d
commit
3446a66a33
@ -1142,11 +1142,23 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
||||
"AssociateTransactionRemoveAction");
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE));
|
||||
|
||||
/* Set 'ExecAssociatedInvoice' */
|
||||
/* Set 'ExecAssociatedInvoice'
|
||||
We can determine an invoice from a txn if either
|
||||
- it is an invoice transaction
|
||||
- it has splits with an invoice associated with it
|
||||
As payment txns can have more than one split associated
|
||||
with an invoice, we can't tell which invoice to open based on
|
||||
the transaction type alone (like in a bank account). However we can
|
||||
uniquely determine an invoice from a split starting from an APAR account
|
||||
as only those splits will have invoice information. For a more universal
|
||||
mechanism (like to be able to display invoices from a bank account) we would
|
||||
need user interaction which is not implemented so far. */
|
||||
inv = invoice_from_split (gnc_split_register_get_current_split (reg));
|
||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||
"JumpAssociatedInvoiceAction");
|
||||
|
||||
gtk_action_set_sensitive (GTK_ACTION (action),
|
||||
inv ||
|
||||
(xaccTransGetTxnType (trans) == TXN_TYPE_INVOICE));
|
||||
|
||||
gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page));
|
||||
@ -4590,11 +4602,14 @@ gnc_plugin_page_register_cmd_jump_associated_invoice (GtkAction* action,
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
|
||||
reg = gnc_ledger_display_get_split_register (priv->gsr->ledger);
|
||||
txn = gnc_split_register_get_current_trans (reg);
|
||||
invoice = invoice_from_split (gnc_split_register_get_current_split (reg));
|
||||
if (xaccTransGetTxnType (txn) == TXN_TYPE_INVOICE)
|
||||
{
|
||||
invoice = invoice_from_split (xaccTransGetFirstAPARAcctSplit (txn, TRUE));
|
||||
else
|
||||
invoice = invoice_from_split (gnc_split_register_get_current_split (reg));
|
||||
|
||||
if (invoice)
|
||||
gnc_ui_invoice_edit (NULL, invoice);
|
||||
}
|
||||
|
||||
LEAVE (" ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user