Skip to content

Commit

Permalink
Merge Jean Laroche's '797006_subaccounts' into maint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Apr 5, 2020
2 parents 3b381f2 + f19b707 commit 2bdc936
Show file tree
Hide file tree
Showing 13 changed files with 3,655 additions and 3,381 deletions.
3 changes: 2 additions & 1 deletion gnucash/gnome-utils/gnc-tree-model-split-reg.c
Expand Up @@ -451,7 +451,7 @@ gnc_tree_model_split_reg_dispose (GObject *object)
/* Create a new tree model */
GncTreeModelSplitReg *
gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 style,
gboolean use_double_line, gboolean is_template)
gboolean use_double_line, gboolean is_template, gboolean mismatched_commodities)
{
GncTreeModelSplitReg *model;
GncTreeModelSplitRegPrivate *priv;
Expand All @@ -469,6 +469,7 @@ gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 s
model->style = style;
model->use_double_line = use_double_line;
model->is_template = is_template;
model->mismatched_commodities = mismatched_commodities;

model->sort_col = 1;
model->sort_depth = 1;
Expand Down
3 changes: 2 additions & 1 deletion gnucash/gnome-utils/gnc-tree-model-split-reg.h
Expand Up @@ -144,6 +144,7 @@ typedef struct
gboolean use_double_line; /**<FIXME ? As above, whether to use two lines per transaction */

gboolean is_template; /**< Are we using a template */
gboolean mismatched_commodities; /**< Are there different commodities */

gint sort_depth; /**< This is the row the sort direction is based on. */
gint sort_col; /**< This is the column the sort direction is based on. */
Expand Down Expand Up @@ -201,7 +202,7 @@ GType gnc_tree_model_split_reg_get_type (void);
/** Create new model and set options for register. */
GncTreeModelSplitReg *
gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 style,
gboolean use_double_line, gboolean is_template);
gboolean use_double_line, gboolean is_template, gboolean mismatched_commodities);

/** Load the model from a slist and set default account for register. */
void gnc_tree_model_split_reg_load (GncTreeModelSplitReg *model, GList * slist, Account *default_account);
Expand Down
3,547 changes: 1,865 additions & 1,682 deletions gnucash/gnome/gnc-plugin-page-register.c

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions gnucash/gnome/gnc-plugin-page-register2.c
Expand Up @@ -559,6 +559,15 @@ typedef struct GncPluginPageRegister2Private

static GObjectClass *parent_class = NULL;

static gpointer
gnc_plug_page_register_check_commodity(Account *account, void* usr_data)
{
// Check that account's commodity matches the commodity in usr_data
gnc_commodity* com0 = (gnc_commodity*) usr_data;
gnc_commodity* com1 = xaccAccountGetCommodity(account);
return gnc_commodity_equal(com1, com0) ? NULL : com1;
}

/************************************************************/
/* Implementation */
/************************************************************/
Expand Down Expand Up @@ -630,6 +639,8 @@ gnc_plugin_page_register2_new (Account *account, gboolean subaccounts)
GNCLedgerDisplay2 *ledger;
GncPluginPage *page;
GncPluginPageRegister2Private *priv;
gnc_commodity* com0;
gnc_commodity* com1;

/*################## Added for Reg2 #################*/
const GList *item;
Expand Down Expand Up @@ -657,9 +668,10 @@ gnc_plugin_page_register2_new (Account *account, gboolean subaccounts)
}
}
/*################## Added for Reg2 #################*/

com0 = gnc_account_get_currency_or_parent(account);
com1 = gnc_account_foreach_descendant_until(account,gnc_plug_page_register_check_commodity,com0);
if (subaccounts)
ledger = gnc_ledger_display2_subaccounts (account);
ledger = gnc_ledger_display2_subaccounts (account,com1!=NULL);
else
ledger = gnc_ledger_display2_simple (account);

Expand Down
49 changes: 30 additions & 19 deletions gnucash/gnome/gnc-split-reg.c
Expand Up @@ -2619,27 +2619,38 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
{
dialog_args *args;
char *string = NULL;
switch (gnc_split_reg_get_placeholder(gsr))
reg = gnc_ledger_display_get_split_register( gsr->ledger );
if(reg->mismatched_commodities)
{
case PLACEHOLDER_NONE:
/* stay as false. */
return;

case PLACEHOLDER_THIS:
string = _("This account may not be edited. If you want "
"to edit transactions in this register, please "
"open the account options and turn off the "
"placeholder checkbox.");
break;
string = _("This account may not be edited because its"
" subaccounts have mismatched commodities or currencies."
"You need to open each account individually to "
"edit transactions.");
}
else
{
switch (gnc_split_reg_get_placeholder(gsr))
{
case PLACEHOLDER_NONE:
/* stay as false. */
return;

default:
string = _("One of the sub-accounts selected may not be "
"edited. If you want to edit transactions in "
"this register, please open the sub-account "
"options and turn off the placeholder checkbox. "
"You may also open an individual account instead "
"of a set of accounts.");
break;
case PLACEHOLDER_THIS:
string = _("This account may not be edited. If you want "
"to edit transactions in this register, please "
"open the account options and turn off the "
"placeholder checkbox.");
break;

default:
string = _("One of the sub-accounts selected may not be "
"edited. If you want to edit transactions in "
"this register, please open the sub-account "
"options and turn off the placeholder checkbox. "
"You may also open an individual account instead "
"of a set of accounts.");
break;
}
}
gsr->read_only = TRUE;
/* Put up a warning dialog */
Expand Down

1 comment on commit 2bdc936

@christopherlam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref #674

Please sign in to comment.