mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'maint'
This commit is contained in:
commit
279a5fcde8
@ -268,12 +268,12 @@ typedef char gchar;
|
||||
|
||||
%typemap(out) GList *, CommodityList *, SplitList *, AccountList *, LotList *,
|
||||
MonetaryList *, PriceList *, EntryList * {
|
||||
guint i;
|
||||
gpointer data;
|
||||
GList *l;
|
||||
PyObject *list = PyList_New(0);
|
||||
for (i = 0; i < g_list_length($1); i++)
|
||||
for (l = $1; l != NULL; l = l->next)
|
||||
{
|
||||
data = g_list_nth_data($1, i);
|
||||
data = l->data;
|
||||
if (GNC_IS_ACCOUNT(data))
|
||||
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p_Account, 0));
|
||||
else if (GNC_IS_SPLIT(data))
|
||||
|
@ -889,3 +889,14 @@ gnc_cost_policy_select_new (void)
|
||||
return cost_policy_widget;
|
||||
}
|
||||
|
||||
gchar*
|
||||
get_negative_color (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, "negative-numbers");
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
||||
return gdk_rgba_to_string (&color);
|
||||
}
|
||||
|
@ -161,4 +161,6 @@ gboolean gnc_new_book_option_display (GtkWidget *parent);
|
||||
GtkWidget *
|
||||
gnc_cost_policy_select_new (void);
|
||||
|
||||
gchar* get_negative_color (void);
|
||||
|
||||
#endif /* DIALOG_UTILS_H */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "gnc-tree-model-account.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "Account.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-accounting-period.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-prefs.h"
|
||||
@ -96,7 +97,7 @@ typedef struct GncTreeModelAccountPrivate
|
||||
QofBook *book;
|
||||
Account *root;
|
||||
gint event_handler_id;
|
||||
const gchar *negative_color;
|
||||
gchar *negative_color;
|
||||
|
||||
GHashTable *account_values_hash;
|
||||
|
||||
@ -109,17 +110,7 @@ typedef struct GncTreeModelAccountPrivate
|
||||
/************************************************************/
|
||||
/* Account Tree Model - Misc Functions */
|
||||
/************************************************************/
|
||||
static gchar*
|
||||
get_negative_color (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, "negative-numbers");
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
||||
return gdk_rgba_to_string (&color);
|
||||
}
|
||||
|
||||
/** Tell the GncTreeModelAccount code to update the color that it will
|
||||
* use for negative numbers. This function will iterate over all
|
||||
@ -144,7 +135,14 @@ gnc_tree_model_account_update_color (gpointer gsettings, gchar *key, gpointer us
|
||||
g_free, g_free);
|
||||
|
||||
use_red = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
priv->negative_color = use_red ? get_negative_color () : NULL;
|
||||
|
||||
if (priv->negative_color)
|
||||
g_free (priv->negative_color);
|
||||
|
||||
if (use_red)
|
||||
priv->negative_color = get_negative_color ();
|
||||
else
|
||||
priv->negative_color = NULL;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
@ -190,7 +188,14 @@ gnc_tree_model_account_init (GncTreeModelAccount *model)
|
||||
priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
|
||||
priv->book = NULL;
|
||||
priv->root = NULL;
|
||||
priv->negative_color = red ? get_negative_color () : NULL;
|
||||
|
||||
if (priv->negative_color)
|
||||
g_free (priv->negative_color);
|
||||
|
||||
if (red)
|
||||
priv->negative_color = get_negative_color ();
|
||||
else
|
||||
priv->negative_color = NULL;
|
||||
|
||||
// create the account values cache hash
|
||||
priv->account_values_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
@ -244,6 +249,9 @@ gnc_tree_model_account_dispose (GObject *object)
|
||||
priv->event_handler_id = 0;
|
||||
}
|
||||
|
||||
if (priv->negative_color)
|
||||
g_free (priv->negative_color);
|
||||
|
||||
// destroy the cached acount values
|
||||
g_hash_table_destroy (priv->account_values_hash);
|
||||
|
||||
|
@ -443,7 +443,7 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
}
|
||||
|
||||
static gchar*
|
||||
get_negative_color (void)
|
||||
get_negative_color_str (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GdkRGBA *rgba;
|
||||
@ -467,7 +467,7 @@ summarybar_update_color (gpointer gsettings, gchar *key, gpointer user_data)
|
||||
{
|
||||
GNCMainSummary *summary = user_data;
|
||||
|
||||
summary->negative_color = get_negative_color();
|
||||
summary->negative_color = get_negative_color_str();
|
||||
summary->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
|
||||
gnc_main_window_summary_refresh (summary);
|
||||
@ -640,7 +640,7 @@ gnc_main_window_summary_new (void)
|
||||
retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel));
|
||||
g_object_unref (retval->datamodel);
|
||||
|
||||
retval->negative_color = get_negative_color();
|
||||
retval->negative_color = get_negative_color_str();
|
||||
retval->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
|
||||
summarybar_update_color, retval);
|
||||
|
@ -95,8 +95,9 @@ enum
|
||||
{
|
||||
TOTALS_TYPE_INCOME, /**< This total is Income type*/
|
||||
TOTALS_TYPE_EXPENSES, /**< This total is Expenses type*/
|
||||
TOTALS_TYPE_TRANSFERS, /**< This total is Transfers type*/
|
||||
TOTALS_TYPE_TOTAL /**< This total is for Totals*/
|
||||
TOTALS_TYPE_ASSET, /**< This total is Assets type*/
|
||||
TOTALS_TYPE_LIABILITY, /**< This total is Liabilities type*/
|
||||
TOTALS_TYPE_EQUITY /**< This total is for Equity type*/
|
||||
};
|
||||
/**< \brief ENUM for different budget totals types.
|
||||
|
||||
@ -423,9 +424,11 @@ gbv_create_widget(GncBudgetView *view)
|
||||
gtk_list_store_append(totals_tree_model, &iter);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Expenses"), 1, TOTALS_TYPE_EXPENSES, -1);
|
||||
gtk_list_store_append(totals_tree_model, &iter);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Transfers"), 1, TOTALS_TYPE_TRANSFERS, -1);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Assets"), 1, TOTALS_TYPE_ASSET, -1);
|
||||
gtk_list_store_append(totals_tree_model, &iter);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Total"), 1, TOTALS_TYPE_TOTAL, -1);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Liabilities"), 1, TOTALS_TYPE_LIABILITY, -1);
|
||||
gtk_list_store_append(totals_tree_model, &iter);
|
||||
gtk_list_store_set(totals_tree_model, &iter, 0, _("Equity"), 1, TOTALS_TYPE_EQUITY, -1);
|
||||
|
||||
totals_tree_view = GTK_TREE_VIEW(gtk_tree_view_new());
|
||||
priv->totals_tree_view = totals_tree_view;
|
||||
@ -942,21 +945,13 @@ gbv_get_accumulated_budget_amount(GncBudget* budget, Account* account, guint per
|
||||
{
|
||||
info.total = gnc_budget_get_account_period_value(budget, account, period_num);
|
||||
}
|
||||
|
||||
if (gnc_reverse_budget_balance (account, TRUE))
|
||||
info.total = gnc_numeric_neg (info.total);
|
||||
|
||||
return info.total;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
get_negative_color (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, "negative-numbers");
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
gtk_widget_destroy(label);
|
||||
|
||||
return gdk_rgba_to_string(&color);
|
||||
}
|
||||
|
||||
/** \brief Calculates and displays budget amount for a period in a defined account.
|
||||
|
||||
@ -1021,13 +1016,21 @@ budget_col_source(Account *account, GtkTreeViewColumn *col,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gnc_reverse_budget_balance (account, TRUE))
|
||||
numeric = gnc_numeric_neg (numeric);
|
||||
|
||||
xaccSPrintAmount(amtbuff, numeric,
|
||||
gnc_account_print_info(account, FALSE));
|
||||
g_object_set(cell, "foreground",
|
||||
red && gnc_numeric_negative_p(numeric)
|
||||
? get_negative_color()
|
||||
: NULL,
|
||||
NULL);
|
||||
|
||||
if (red && gnc_numeric_negative_p(numeric))
|
||||
{
|
||||
gchar *color = get_negative_color ();
|
||||
g_object_set(cell, "foreground", color, NULL);
|
||||
g_free (color);
|
||||
}
|
||||
else
|
||||
g_object_set(cell, "foreground", NULL, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1065,6 +1068,9 @@ bgv_get_total_for_account(Account* account, GncBudget* budget, gnc_commodity *ne
|
||||
{
|
||||
numeric = gbv_get_accumulated_budget_amount(budget, account, period_num);
|
||||
|
||||
if (gnc_reverse_budget_balance (account, TRUE))
|
||||
numeric = gnc_numeric_neg (numeric);
|
||||
|
||||
if (new_currency)
|
||||
{
|
||||
numeric = gnc_pricedb_convert_balance_nearest_price_t64(
|
||||
@ -1089,6 +1095,10 @@ bgv_get_total_for_account(Account* account, GncBudget* budget, gnc_commodity *ne
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gnc_reverse_budget_balance (account, TRUE))
|
||||
total = gnc_numeric_neg(total);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@ -1107,8 +1117,16 @@ budget_total_col_source(Account *account, GtkTreeViewColumn *col,
|
||||
total = bgv_get_total_for_account(account, budget, NULL);
|
||||
xaccSPrintAmount(amtbuff, total,
|
||||
gnc_account_print_info(account, TRUE));
|
||||
g_object_set(cell, "foreground",
|
||||
red && gnc_numeric_negative_p(total) ? get_negative_color () : NULL, NULL);
|
||||
|
||||
if (red && gnc_numeric_negative_p(total))
|
||||
{
|
||||
gchar *color = get_negative_color ();
|
||||
g_object_set(cell, "foreground", color, NULL);
|
||||
g_free (color);
|
||||
}
|
||||
else
|
||||
g_object_set(cell, "foreground", NULL, NULL);
|
||||
|
||||
return g_strdup(amtbuff);
|
||||
}
|
||||
|
||||
@ -1139,8 +1157,12 @@ budget_col_edited(Account *account, GtkTreeViewColumn *col,
|
||||
if (new_text && *new_text == '\0')
|
||||
gnc_budget_unset_account_period_value(budget, account, period_num);
|
||||
else
|
||||
{
|
||||
if (gnc_reverse_budget_balance (account, TRUE))
|
||||
numeric = gnc_numeric_neg(numeric);
|
||||
gnc_budget_set_account_period_value(budget, account, period_num,
|
||||
numeric);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Function to find the total in a column of budget provided and
|
||||
@ -1170,7 +1192,7 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
|
||||
gchar amtbuff[100]; //FIXME: overkill, where's the #define?
|
||||
gint i;
|
||||
gint num_top_accounts;
|
||||
gboolean neg, red;
|
||||
gboolean red;
|
||||
GNCPriceDB *pdb;
|
||||
gnc_commodity *total_currency, *currency;
|
||||
|
||||
@ -1196,32 +1218,28 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
|
||||
{
|
||||
account = gnc_account_nth_child(priv->rootAcct, i);
|
||||
currency = gnc_account_get_currency_or_parent(account);
|
||||
neg = FALSE;
|
||||
|
||||
switch (xaccAccountGetType(account))
|
||||
{
|
||||
case ACCT_TYPE_INCOME:
|
||||
if (row_type != TOTALS_TYPE_INCOME &&
|
||||
row_type != TOTALS_TYPE_TOTAL)
|
||||
continue;
|
||||
break;
|
||||
case ACCT_TYPE_LIABILITY:
|
||||
case ACCT_TYPE_EQUITY:
|
||||
if (row_type != TOTALS_TYPE_TRANSFERS &&
|
||||
row_type != TOTALS_TYPE_TOTAL)
|
||||
if (row_type != TOTALS_TYPE_INCOME)
|
||||
continue;
|
||||
break;
|
||||
case ACCT_TYPE_EXPENSE:
|
||||
if (row_type == TOTALS_TYPE_TOTAL)
|
||||
neg = TRUE;
|
||||
else if (row_type != TOTALS_TYPE_EXPENSES)
|
||||
if (row_type != TOTALS_TYPE_EXPENSES)
|
||||
continue;
|
||||
break;
|
||||
case ACCT_TYPE_ASSET:
|
||||
if (row_type != TOTALS_TYPE_TRANSFERS &&
|
||||
row_type != TOTALS_TYPE_TOTAL)
|
||||
if (row_type != TOTALS_TYPE_ASSET)
|
||||
continue;
|
||||
break;
|
||||
case ACCT_TYPE_LIABILITY:
|
||||
if (row_type != TOTALS_TYPE_LIABILITY)
|
||||
continue;
|
||||
break;
|
||||
case ACCT_TYPE_EQUITY:
|
||||
if (row_type != TOTALS_TYPE_EQUITY)
|
||||
continue;
|
||||
neg = TRUE;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
@ -1234,27 +1252,27 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
|
||||
}
|
||||
else
|
||||
{
|
||||
value =
|
||||
gbv_get_accumulated_budget_amount(budget, account, period_num);
|
||||
value = gbv_get_accumulated_budget_amount(budget, account, period_num);
|
||||
|
||||
value = gnc_pricedb_convert_balance_nearest_price_t64(
|
||||
pdb, value, currency, total_currency,
|
||||
gnc_budget_get_period_start_date(budget, period_num));
|
||||
}
|
||||
|
||||
if (neg)
|
||||
total = gnc_numeric_sub(total, value, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_LCD);
|
||||
else
|
||||
total = gnc_numeric_add(total, value, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_LCD);
|
||||
total = gnc_numeric_add(total, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
|
||||
}
|
||||
|
||||
xaccSPrintAmount(amtbuff, total,
|
||||
gnc_commodity_print_info(total_currency,
|
||||
period_num < 0 ? TRUE : FALSE));
|
||||
g_object_set(cell, "foreground",
|
||||
red && gnc_numeric_negative_p(total) ? get_negative_color () : NULL, NULL);
|
||||
if (red && gnc_numeric_negative_p(total))
|
||||
{
|
||||
gchar *color = get_negative_color ();
|
||||
g_object_set(cell, "foreground", color, NULL);
|
||||
g_free (color);
|
||||
}
|
||||
else
|
||||
g_object_set(cell, "foreground", NULL, NULL);
|
||||
|
||||
g_object_set(G_OBJECT(cell), "text", amtbuff, "xalign", 1.0, NULL);
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) |
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
if (gnc_reverse_balance(acct))
|
||||
if (gnc_reverse_budget_balance(acct, FALSE))
|
||||
num = gnc_numeric_neg(num);
|
||||
|
||||
for (i = 0; i < num_periods; i++)
|
||||
@ -931,7 +931,7 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
|
||||
if (!gnc_numeric_check(num))
|
||||
{
|
||||
if (gnc_reverse_balance(acct))
|
||||
if (gnc_reverse_budget_balance(acct, FALSE))
|
||||
num = gnc_numeric_neg(num);
|
||||
|
||||
num = gnc_numeric_convert(num, GNC_DENOM_AUTO,
|
||||
@ -1031,7 +1031,7 @@ allperiods_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
{
|
||||
Account *acct;
|
||||
guint num_periods, i;
|
||||
gnc_numeric num;
|
||||
gnc_numeric num, allvalue;
|
||||
GncPluginPageBudgetPrivate *priv;
|
||||
GncPluginPageBudget *page = data;
|
||||
|
||||
@ -1039,7 +1039,9 @@ allperiods_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page);
|
||||
acct = gnc_budget_view_get_account_from_path(priv->budget_view, path);
|
||||
num_periods = gnc_budget_get_num_periods(priv->budget);
|
||||
num = priv->allValue;
|
||||
allvalue = priv->allValue;
|
||||
if (gnc_reverse_budget_balance(acct, TRUE))
|
||||
allvalue = gnc_numeric_neg(allvalue);
|
||||
|
||||
for (i = 0; i < num_periods; i++)
|
||||
{
|
||||
@ -1047,7 +1049,7 @@ allperiods_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
{
|
||||
case ADD:
|
||||
num = gnc_budget_get_account_period_value(priv->budget, acct, i);
|
||||
num = gnc_numeric_add(num, priv->allValue, GNC_DENOM_AUTO,
|
||||
num = gnc_numeric_add(num, allvalue, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) |
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_budget_set_account_period_value(priv->budget, acct, i, num);
|
||||
@ -1064,7 +1066,7 @@ allperiods_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
break;
|
||||
default:
|
||||
gnc_budget_set_account_period_value(priv->budget, acct, i,
|
||||
priv->allValue);
|
||||
allvalue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,8 @@
|
||||
(gnc:report-options report-obj) pagename optname)))
|
||||
|
||||
(define (get-budget-account-budget-balance budget account)
|
||||
(gnc:budget-account-get-net budget account #f #f))
|
||||
(let ((bal (gnc:budget-account-get-net budget account #f #f)))
|
||||
(if (gnc-reverse-budget-balance account #t) (gnc:collector- bal) bal)))
|
||||
|
||||
(define (get-budget-account-initial-balance budget account)
|
||||
(gnc:budget-account-get-initial-balance budget account))
|
||||
|
@ -308,7 +308,8 @@
|
||||
(get-balance-fn budget account period-start period-end))))
|
||||
|
||||
(define (get-budget-account-budget-balance budget account period-start period-end)
|
||||
(gnc:budget-account-get-net budget account period-start period-end))
|
||||
(let ((bal (gnc:budget-account-get-net budget account period-start period-end)))
|
||||
(if (gnc-reverse-budget-balance account #t) (gnc:collector- bal) bal)))
|
||||
|
||||
(gnc:report-starting reportname)
|
||||
|
||||
|
@ -360,6 +360,9 @@
|
||||
column-list exchange-fn)
|
||||
(let* ((comm (xaccAccountGetCommodity acct))
|
||||
(reverse-balance? (gnc-reverse-balance acct))
|
||||
(maybe-negate (lambda (amt) (if reverse-balance? (- amt) amt)))
|
||||
(unreversed? (gnc-using-unreversed-budgets
|
||||
(gnc-get-current-book))) ;fwd-compatibility
|
||||
(allperiods (filter number? (gnc:list-flatten column-list)))
|
||||
(total-periods (if (and accumulate? (not (null? allperiods)))
|
||||
(iota (1+ (apply max allperiods)))
|
||||
@ -409,6 +412,19 @@
|
||||
((null? column-list)
|
||||
#f)
|
||||
|
||||
;; fwd-compatibility: the next cond may be removed in master
|
||||
((and (eq? (car column-list) 'total) unreversed?)
|
||||
(let* ((bgt-total (maybe-negate
|
||||
(gnc:get-account-periodlist-budget-value
|
||||
budget acct total-periods)))
|
||||
(act-total (maybe-negate
|
||||
(gnc:get-account-periodlist-actual-value
|
||||
budget acct total-periods)))
|
||||
(dif-total (- bgt-total act-total)))
|
||||
(loop (cdr column-list)
|
||||
(disp-cols "total-number-cell" current-col
|
||||
bgt-total act-total dif-total))))
|
||||
|
||||
((eq? (car column-list) 'total)
|
||||
(let* ((bgt-total (gnc:get-account-periodlist-budget-value
|
||||
budget acct total-periods))
|
||||
@ -422,6 +438,23 @@
|
||||
(disp-cols "total-number-cell" current-col
|
||||
bgt-total act-total dif-total #f))))
|
||||
|
||||
;; fwd-compatibility: the next cond may be removed in master
|
||||
(unreversed?
|
||||
(let* ((period-list (cond
|
||||
((list? (car column-list)) (car column-list))
|
||||
(accumulate? (iota (1+ (car column-list))))
|
||||
(else (list (car column-list)))))
|
||||
(bgt-val (maybe-negate
|
||||
(gnc:get-account-periodlist-budget-value
|
||||
budget acct period-list)))
|
||||
(act-val (maybe-negate
|
||||
(gnc:get-account-periodlist-actual-value
|
||||
budget acct period-list)))
|
||||
(dif-val (- bgt-val act-val)))
|
||||
(loop (cdr column-list)
|
||||
(disp-cols "number-cell" current-col
|
||||
bgt-val act-val dif-val))))
|
||||
|
||||
(else
|
||||
(let* ((period-list (cond
|
||||
((list? (car column-list)) (car column-list))
|
||||
|
@ -41,6 +41,7 @@
|
||||
.company-table > table * { padding: 0px; }
|
||||
.client-table > table * { padding: 0px; }
|
||||
.invoice-details-table > table * { padding: 0px; }
|
||||
@media print { .main-table > table { width: 100%; }}
|
||||
")
|
||||
|
||||
(define (date-col columns-used)
|
||||
|
@ -105,6 +105,8 @@ const char * xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info);
|
||||
gchar *number_to_words(gdouble val, gint64 denom);
|
||||
const gchar *printable_value (gdouble val, gint denom);
|
||||
|
||||
gboolean gnc_using_unreversed_budgets (QofBook* book);
|
||||
gboolean gnc_reverse_budget_balance (const Account *account, gboolean unreversed);
|
||||
gboolean gnc_reverse_balance (const Account *account);
|
||||
|
||||
gboolean gnc_is_euro_currency(const gnc_commodity * currency);
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-features.h"
|
||||
#include "gnc-euro.h"
|
||||
#include "gnc-hooks.h"
|
||||
#include "gnc-locale-tax.h"
|
||||
@ -178,6 +179,23 @@ gnc_reverse_balance (const Account *account)
|
||||
return reverse_type[type];
|
||||
}
|
||||
|
||||
gboolean gnc_using_unreversed_budgets (QofBook* book)
|
||||
{
|
||||
return gnc_features_check_used (book, GNC_FEATURE_BUDGET_UNREVERSED);
|
||||
}
|
||||
|
||||
/* similar to gnc_reverse_balance but also accepts a gboolean
|
||||
unreversed which specifies the reversal strategy - FALSE = pre-4.x
|
||||
always-assume-credit-accounts, TRUE = all amounts unreversed */
|
||||
gboolean
|
||||
gnc_reverse_budget_balance (const Account *account, gboolean unreversed)
|
||||
{
|
||||
if (unreversed == gnc_using_unreversed_budgets(gnc_account_get_book(account)))
|
||||
return gnc_reverse_balance (account);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
gchar *
|
||||
gnc_get_default_directory (const gchar *section)
|
||||
|
@ -46,6 +46,16 @@ typedef QofSession * (*QofSessionCB) (void);
|
||||
gchar *gnc_normalize_account_separator (const gchar* separator);
|
||||
gboolean gnc_reverse_balance(const Account *account);
|
||||
|
||||
/* Backward compatibility *******************************************
|
||||
* Return book's UNREVERSED_BUDGET feature check. */
|
||||
gboolean gnc_using_unreversed_budgets (QofBook* book);
|
||||
|
||||
/* Backward compatibility *******************************************
|
||||
* Compare book's UNREVERSED_BUDGET with unreverse_check. If they
|
||||
* match, return account reversal according to global pref. If they
|
||||
* don't match, return FALSE. */
|
||||
gboolean gnc_reverse_budget_balance (const Account *account, gboolean unreversed);
|
||||
|
||||
/* Default directory sections ***************************************/
|
||||
#define GNC_PREFS_GROUP_OPEN_SAVE "dialogs.open-save"
|
||||
#define GNC_PREFS_GROUP_EXPORT "dialogs.export-accounts"
|
||||
|
@ -676,15 +676,25 @@ Transaction *
|
||||
xaccTransClone (const Transaction *from)
|
||||
{
|
||||
Transaction *to = xaccTransCloneNoKvp (from);
|
||||
int i = 0;
|
||||
int length = g_list_length (from->splits);
|
||||
GList *lfrom, *lto;
|
||||
|
||||
xaccTransBeginEdit (to);
|
||||
qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
|
||||
g_assert (g_list_length (to->splits) == length);
|
||||
for (i = 0; i < length; ++i)
|
||||
xaccSplitCopyKvp (g_list_nth_data (from->splits, i),
|
||||
g_list_nth_data (to->splits, i));
|
||||
g_return_val_if_fail (g_list_length (to->splits) == g_list_length (from->splits),
|
||||
NULL);
|
||||
|
||||
lfrom = from->splits;
|
||||
lto = to->splits;
|
||||
|
||||
/* lfrom and lto are known to be of equal length via above
|
||||
g_return_val_if_fail */
|
||||
while (lfrom != NULL)
|
||||
{
|
||||
xaccSplitCopyKvp (lfrom->data, lto->data);
|
||||
lfrom = lfrom->next;
|
||||
lto = lto->next;
|
||||
}
|
||||
|
||||
xaccTransCommitEdit (to);
|
||||
return to;
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ static gncFeature known_features[] =
|
||||
{ GNC_FEATURE_GUID_FLAT_BAYESIAN, "Use account GUID as key for bayesian data and store KVP flat (requires at least Gnucash 2.6.19)" },
|
||||
{ GNC_FEATURE_SQLITE3_ISO_DATES, "Use ISO formatted date-time strings in SQLite3 databases (requires at least GnuCash 2.6.20)"},
|
||||
{ GNC_FEATURE_REG_SORT_FILTER, "Store the register sort and filter settings in .gcm metadata file (requires at least GnuCash 3.3)"},
|
||||
{ GNC_FEATURE_BUDGET_UNREVERSED, "Store budget amounts unreversed (i.e. natural) signs (requires at least Gnucash 3.8)"},
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,7 @@ extern "C" {
|
||||
#define GNC_FEATURE_GUID_FLAT_BAYESIAN "Account GUID based bayesian with flat KVP"
|
||||
#define GNC_FEATURE_SQLITE3_ISO_DATES "ISO-8601 formatted date strings in SQLite3 databases."
|
||||
#define GNC_FEATURE_REG_SORT_FILTER "Register sort and filter settings stored in .gcm file"
|
||||
#define GNC_FEATURE_BUDGET_UNREVERSED "Use natural signs in budget amounts"
|
||||
|
||||
/** @} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user