mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change the balance limit icon if both limits are zero
When higher and lower limits are zero, when used for a a suspense account, change the icon to 'dialog-warning'. This type of use is to indicate that a non zero balance exists.
This commit is contained in:
parent
3be25ff0a9
commit
7536fcaf2f
@ -833,12 +833,7 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
if (gnc_ui_account_is_higher_balance_limit_reached (account))
|
||||
string = "go-top";
|
||||
else if (gnc_ui_account_is_lower_balance_limit_reached (account))
|
||||
string = "go-bottom";
|
||||
else
|
||||
string = "";
|
||||
string = gnc_ui_account_get_balance_limit_icon_name (account);
|
||||
g_value_set_string (value, string);
|
||||
break;
|
||||
|
||||
|
@ -272,7 +272,8 @@ account_balance_limit_reached (const Account *account, gnc_numeric balance_limit
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_ui_account_is_higher_balance_limit_reached (const Account *account)
|
||||
gnc_ui_account_is_higher_balance_limit_reached (const Account *account,
|
||||
gboolean *is_zero)
|
||||
{
|
||||
gnc_numeric balance_limit;
|
||||
gboolean limit_valid = FALSE;
|
||||
@ -289,6 +290,9 @@ gnc_ui_account_is_higher_balance_limit_reached (const Account *account)
|
||||
if (!limit_valid)
|
||||
return retval;
|
||||
|
||||
if (gnc_numeric_zero_p (balance_limit))
|
||||
*is_zero = TRUE;
|
||||
|
||||
if (account_balance_limit_reached (account, balance_limit) == 1)
|
||||
retval = TRUE;
|
||||
|
||||
@ -296,7 +300,8 @@ gnc_ui_account_is_higher_balance_limit_reached (const Account *account)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_ui_account_is_lower_balance_limit_reached (const Account *account)
|
||||
gnc_ui_account_is_lower_balance_limit_reached (const Account *account,
|
||||
gboolean *is_zero)
|
||||
{
|
||||
gnc_numeric balance_limit;
|
||||
gboolean limit_valid = FALSE;
|
||||
@ -313,12 +318,44 @@ gnc_ui_account_is_lower_balance_limit_reached (const Account *account)
|
||||
if (!limit_valid)
|
||||
return retval;
|
||||
|
||||
if (gnc_numeric_zero_p (balance_limit))
|
||||
*is_zero = TRUE;
|
||||
|
||||
if (account_balance_limit_reached (account, balance_limit) == -1)
|
||||
retval = TRUE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gnc_ui_account_get_balance_limit_icon_name (const Account *account)
|
||||
{
|
||||
gboolean lower_limit_reached, higher_limit_reached;
|
||||
gboolean lower_is_zero = FALSE;
|
||||
gboolean higher_is_zero = FALSE;
|
||||
|
||||
g_return_val_if_fail (GNC_IS_ACCOUNT(account), g_strdup (""));
|
||||
|
||||
higher_limit_reached = gnc_ui_account_is_higher_balance_limit_reached (account, &higher_is_zero);
|
||||
|
||||
// assume the higher value will be set mostly so test that first
|
||||
if (higher_limit_reached && !higher_is_zero)
|
||||
return g_strdup ("go-top");
|
||||
|
||||
lower_limit_reached = gnc_ui_account_is_lower_balance_limit_reached (account, &lower_is_zero);
|
||||
|
||||
if (lower_limit_reached && (!lower_is_zero || !higher_is_zero))
|
||||
return g_strdup ("go-bottom");
|
||||
|
||||
if (higher_limit_reached && !lower_is_zero)
|
||||
return g_strdup ("go-top");
|
||||
|
||||
if ((lower_limit_reached || higher_limit_reached ) && lower_is_zero && higher_is_zero)
|
||||
return g_strdup ("dialog-warning");
|
||||
|
||||
return g_strdup ("");
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* Balance calculations related to owners
|
||||
********************************************************************/
|
||||
|
@ -160,18 +160,30 @@ GList * gnc_account_get_autoclear_splits (Account *account, gnc_numeric toclear_
|
||||
*
|
||||
* @param account A pointer to the account.
|
||||
*
|
||||
* @param is_zero A return value, set to TRUE if limit is zero
|
||||
*
|
||||
* @return TRUE if account balance has passed limit.
|
||||
*/
|
||||
gboolean gnc_ui_account_is_higher_balance_limit_reached (const Account *account);
|
||||
gboolean gnc_ui_account_is_higher_balance_limit_reached (const Account *account, gboolean *is_zero);
|
||||
|
||||
/** Test the account balance as of today for it passing the
|
||||
* lower limit if set.
|
||||
*
|
||||
* @param account A pointer to the account.
|
||||
*
|
||||
* @param is_zero A return value, set to TRUE if limit is zero
|
||||
*
|
||||
* @return TRUE if account balance has passed limit.
|
||||
*/
|
||||
gboolean gnc_ui_account_is_lower_balance_limit_reached (const Account *account);
|
||||
gboolean gnc_ui_account_is_lower_balance_limit_reached (const Account *account, gboolean *is_zero);
|
||||
|
||||
/** Test the account balance as of today for it passing the
|
||||
* lower and higher limits if set.
|
||||
*
|
||||
* @param account A pointer to the account.
|
||||
*
|
||||
* @return The icon name to be displayed.
|
||||
*/
|
||||
gchar * gnc_ui_account_get_balance_limit_icon_name (const Account *account);
|
||||
|
||||
#endif /* GNC_UI_BALANCES_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user