Merge branch 'maint'

This commit is contained in:
Christopher Lam 2019-09-29 14:15:37 +08:00
commit d590ba79e1
5 changed files with 7050 additions and 6330 deletions

View File

@ -69,6 +69,8 @@ typedef struct
GtkWidget *filter_button;
GtkWidget *filter_text_entry;
GtkWidget *filter_label;
gboolean apply_selection_filter;
GtkWidget *expand_button;
GtkWidget *collapse_button;
@ -236,20 +238,18 @@ gnc_imap_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_
}
static gboolean
filter_test_and_move_next (GtkTreeModel *model, GtkTreeIter *iter, ImapDialog *imap_dialog)
filter_test_and_move_next (GtkTreeModel *model, GtkTreeIter *iter,
const gchar *filter_text, ImapDialog *imap_dialog)
{
GtkTreePath *tree_path;
gint depth;
gboolean valid;
const gchar *filter_text;
const gchar *match_string;
const gchar *map_full_acc;
// Read the row
gtk_tree_model_get (model, iter, MATCH_STRING, &match_string, MAP_FULL_ACC, &map_full_acc, -1);
filter_text = gtk_entry_get_text (GTK_ENTRY(imap_dialog->filter_text_entry));
// Get the level we are at in the tree-model
tree_path = gtk_tree_model_get_path (model, iter);
depth = gtk_tree_path_get_depth (tree_path);
@ -258,7 +258,7 @@ filter_test_and_move_next (GtkTreeModel *model, GtkTreeIter *iter, ImapDialog *i
gtk_tree_store_set (GTK_TREE_STORE(model), iter, FILTER, TRUE, -1);
// Check for a filter_text entry
if (g_strcmp0 (filter_text, "") != 0)
if (filter_text && *filter_text != '\0')
{
if (match_string != NULL) // Check for match_string is not NULL, valid line
{
@ -295,19 +295,32 @@ filter_button_cb (GtkButton *button, ImapDialog *imap_dialog)
GtkTreeModel *model, *filter;
GtkTreeIter iter;
gboolean valid;
const gchar *filter_text;
filter = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(filter));
filter_text = gtk_entry_get_text (GTK_ENTRY(imap_dialog->filter_text_entry));
// Collapse all nodes
gtk_tree_view_collapse_all (GTK_TREE_VIEW(imap_dialog->view));
imap_dialog->apply_selection_filter = FALSE;
// clear any selection
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection
(GTK_TREE_VIEW(imap_dialog->view)));
// do we have a filter, apply selection filter
if (filter_text && *filter_text != '\0')
imap_dialog->apply_selection_filter = TRUE;
valid = gtk_tree_model_get_iter_first (model, &iter);
while (valid)
{
valid = filter_test_and_move_next (model, &iter, imap_dialog);
valid = filter_test_and_move_next (model, &iter, filter_text, imap_dialog);
}
gtk_widget_grab_focus (GTK_WIDGET(imap_dialog->view));
}
static void
@ -586,6 +599,7 @@ get_account_info (ImapDialog *imap_dialog)
// Clear the filter
gtk_entry_set_text (GTK_ENTRY(imap_dialog->filter_text_entry), "");
imap_dialog->apply_selection_filter = FALSE;
// Hide Count Column
show_count_column (imap_dialog, FALSE);
@ -622,6 +636,34 @@ get_account_info (ImapDialog *imap_dialog)
g_list_free (accts);
}
static gboolean
view_selection_function (GtkTreeSelection *selection,
GtkTreeModel *model,
GtkTreePath *path,
gboolean path_currently_selected,
gpointer user_data)
{
ImapDialog *imap_dialog = user_data;
GtkTreeIter iter;
if (!imap_dialog->apply_selection_filter)
return TRUE;
// do we have a valid row
if (gtk_tree_model_get_iter (model, &iter, path))
{
const gchar *match_string;
// read the row
gtk_tree_model_get (model, &iter, MATCH_STRING, &match_string, -1);
// match_string NULL, top level can not be selected with a filter
if (match_string == NULL)
return FALSE;
}
return TRUE;
}
static void
gnc_imap_dialog_create (GtkWidget *parent, ImapDialog *imap_dialog)
{
@ -687,6 +729,12 @@ gnc_imap_dialog_create (GtkWidget *parent, ImapDialog *imap_dialog)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(imap_dialog->view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
/* add a select function */
gtk_tree_selection_set_select_function (selection,
view_selection_function,
imap_dialog,
NULL);
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, imap_dialog);
g_object_unref (G_OBJECT(builder));

View File

@ -50,7 +50,7 @@
<object class="GtkLabel" id="start_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This assistant will help you import Prices from a CSV file.
<property name="label" translatable="yes" comments="You should localize the (british) examples to your region.">This assistant will help you import Prices from a CSV file.
There is a minimum number of columns that have to be present for a successful import, these are Date, Amount, From Namespace, From Symbol and Currency To. If all entries are for the same Commodity / Currency then you can select them and then the columns will be Date and Amount.
@ -1085,5 +1085,8 @@ Cancel to abort.&lt;/b&gt;</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -259,17 +259,9 @@
(define (get-budget-account-budget-balance budget account)
(gnc:budget-account-get-net budget account #f #f))
(define (get-budget-account-budget-balance-negated budget account)
(gnc:commodity-collector-get-negated
(get-budget-account-budget-balance budget account)))
(define (get-budget-account-initial-balance budget account)
(gnc:budget-account-get-initial-balance budget account))
(define (get-budget-account-initial-balance-negated budget account)
(gnc:commodity-collector-get-negated
(get-budget-account-initial-balance budget account)))
(define (get-budget-accountlist-budget-balance budget accountlist)
(gnc:budget-accountlist-get-net budget accountlist #f #f))
@ -282,25 +274,11 @@
(gnc:commodity-collector-get-negated
(gnc:get-assoc-account-balances-total account-balances)))
(define
(sum-prefetched-account-balances-for-account
initial-balances budget-balances account)
(let*
(
(initial-balance
(gnc:select-assoc-account-balance initial-balances account))
(budget-balance
(gnc:select-assoc-account-balance budget-balances account))
(total-balance
(if (or (not initial-balance) (not budget-balance))
#f
(gnc:make-commodity-collector))))
(if
total-balance
(begin
(total-balance 'merge initial-balance #f)
(total-balance 'merge budget-balance #f)))
total-balance))
(define (sum-prefetched-account-balances-for-account
initial-balances budget-balances account)
(let ((initial (gnc:select-assoc-account-balance initial-balances account))
(budget (gnc:select-assoc-account-balance budget-balances account)))
(and initial budget (gnc:collector+ initial budget))))
(gnc:report-starting reportname)
@ -393,9 +371,7 @@
signed-balance report-commodity exchange-fn)))))
(label (if neg? (or neg-label pos-label) pos-label))
(balance (if neg?
(let ((bal (gnc:make-commodity-collector)))
(bal 'minusmerge signed-balance #f)
bal)
(gnc:collector- signed-balance)
signed-balance))
)
(gnc:html-table-add-labeled-amount-line!
@ -573,50 +549,33 @@
(gnc:commodity-collector-get-negated liability-repayments))
;; Total liabilities.
(set! liability-balance (gnc:make-commodity-collector))
(liability-balance 'merge existing-liabilities #f)
(liability-balance 'merge new-liabilities #f)
(set! liability-balance
(gnc:collector+ existing-liabilities new-liabilities))
(gnc:report-percent-done 12)
;; Total existing retained earnings.
;; existing retained earnings = initial income - initial expenses
(set! existing-retained-earnings (gnc:make-commodity-collector))
;; Income is negative; negate to add.
(existing-retained-earnings 'minusmerge
(gnc:budget-accountlist-get-initial-balance budget income-accounts)
#f)
;; Expenses are positive; negate to subtract.
(existing-retained-earnings 'minusmerge
(gnc:budget-accountlist-get-initial-balance budget expense-accounts)
#f)
(set! existing-retained-earnings
(gnc:collector-
(gnc:collector+
(gnc:budget-accountlist-get-initial-balance budget income-accounts)
(gnc:budget-accountlist-get-initial-balance budget expense-accounts))))
(gnc:report-percent-done 14)
;; Total new retained earnings.
(set! new-retained-earnings (gnc:make-commodity-collector))
;; Budgeted income is positive; add.
(new-retained-earnings 'merge
(get-budget-accountlist-budget-balance budget income-accounts)
#f)
;; Budgeted expenses are positive; negate to subtract.
(new-retained-earnings 'minusmerge
(get-budget-accountlist-budget-balance budget expense-accounts)
#f)
(set! new-retained-earnings
(gnc:collector-
(get-budget-accountlist-budget-balance budget income-accounts)
(get-budget-accountlist-budget-balance budget expense-accounts)))
;; Total retained earnings.
(set! retained-earnings (gnc:make-commodity-collector))
(retained-earnings 'merge existing-retained-earnings #f)
(retained-earnings 'merge new-retained-earnings #f)
(set! retained-earnings
(gnc:collector+ existing-retained-earnings new-retained-earnings))
(gnc:report-percent-done 16)
;; Total existing assets.
(set! existing-assets
(gnc:get-assoc-account-balances-total
@ -630,77 +589,56 @@
;; Total unallocated assets.
;; unallocated-assets =
;; new-retained-earnings - allocated-assets - liability-repayments
(set! unallocated-assets (gnc:make-commodity-collector))
(unallocated-assets 'merge new-retained-earnings #f)
(unallocated-assets 'minusmerge allocated-assets #f)
(unallocated-assets 'minusmerge liability-repayments #f)
(set! unallocated-assets
(gnc:collector- new-retained-earnings
allocated-assets
liability-repayments))
;; Total assets.
(set! asset-balance (gnc:make-commodity-collector))
(asset-balance 'merge existing-assets #f)
(asset-balance 'merge allocated-assets #f)
(asset-balance 'merge unallocated-assets #f)
(set! asset-balance
(gnc:collector+ existing-assets allocated-assets unallocated-assets))
(gnc:report-percent-done 18)
;; Calculate unrealized gains.
(set! unrealized-gain (gnc:make-commodity-collector))
(let*
(
(get-total-value-fn
(lambda (account)
(gnc:account-get-comm-value-at-date account date-t64 #f)))
(asset-basis
(gnc:accounts-get-comm-total-assets
asset-accounts get-total-value-fn))
(liability-basis
(gnc:commodity-collector-get-negated
(let* ((get-total-value-fn
(lambda (account)
(gnc:account-get-comm-value-at-date account date-t64 #f)))
(asset-basis
(gnc:accounts-get-comm-total-assets
liability-accounts get-total-value-fn)))
)
;; Calculate unrealized gains from assets.
(unrealized-gain 'merge existing-assets #f)
(unrealized-gain 'minusmerge asset-basis #f)
;; Combine with unrealized gains from liabilities
(unrealized-gain 'minusmerge existing-liabilities #f)
(unrealized-gain 'merge liability-basis #f))
asset-accounts get-total-value-fn))
(liability-basis
(gnc:collector-
(gnc:accounts-get-comm-total-assets
liability-accounts get-total-value-fn))))
(set! unrealized-gain
(gnc:collector-
(gnc:collector- existing-assets asset-basis)
(gnc:collector- existing-liabilities liability-basis))))
(gnc:report-percent-done 22)
;; Total existing equity; negative.
(set! existing-equity
(get-assoc-account-balances-total-negated
equity-account-initial-balances))
;; Include existing retained earnings.
(existing-equity 'merge existing-retained-earnings #f)
;; Include unrealized gains.
(existing-equity 'merge unrealized-gain #f)
(gnc:collector+
(get-assoc-account-balances-total-negated equity-account-initial-balances)
existing-retained-earnings
unrealized-gain))
;; Total new equity; positive.
(set! new-equity
(gnc:get-assoc-account-balances-total
equity-account-budget-balances))
;; Include new retained earnings.
(new-equity 'merge new-retained-earnings #f)
(gnc:collector+
(gnc:get-assoc-account-balances-total equity-account-budget-balances)
new-retained-earnings))
;; Total equity.
(set! equity-balance (gnc:make-commodity-collector))
(equity-balance 'merge existing-equity #f)
(equity-balance 'merge new-equity #f)
(set! equity-balance
(gnc:collector+ existing-equity new-equity))
;; Total liability + equity.
(set! liability-plus-equity (gnc:make-commodity-collector))
(liability-plus-equity 'merge liability-balance #f)
(liability-plus-equity 'merge equity-balance #f)
(set! liability-plus-equity
(gnc:collector+ liability-balance equity-balance))
(gnc:report-percent-done 30)

View File

@ -303,24 +303,13 @@
(gnc:lookup-option
(gnc:report-options report-obj) pagename optname)))
(define
(get-assoc-account-balances-budget
budget
accountlist
period-start
period-end
get-balance-fn)
(define (get-assoc-account-balances-budget
budget accountlist period-start period-end get-balance-fn)
(gnc:get-assoc-account-balances
accountlist
(lambda (account)
(get-balance-fn budget account period-start period-end))))
accountlist (lambda (account)
(get-balance-fn budget account period-start period-end))))
(define
(get-budget-account-budget-balance
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))
(gnc:report-starting reportname)
@ -429,9 +418,7 @@
signed-balance report-commodity exchange-fn)))))
(label (if neg? (or neg-label pos-label) pos-label))
(balance (if neg?
(let ((bal (gnc:make-commodity-collector)))
(bal 'minusmerge signed-balance #f)
bal)
(gnc:collector- signed-balance)
signed-balance))
)
(gnc:html-table-add-labeled-amount-line!
@ -530,20 +517,16 @@
amount report-commodity exchange-fn)))))
(label (if neg? (or neg-label pos-label) pos-label))
(pos-bal (if neg?
(let ((bal (gnc:make-commodity-collector)))
(bal 'minusmerge amount #f)
bal)
(gnc:collector- amount)
amount))
(bal (gnc:sum-collector-commodity
pos-bal report-commodity exchange-fn))
(balance
(or (and (gnc:uniform-commodity? pos-bal report-commodity)
bal)
(and show-fcur?
(gnc-commodity-table
pos-bal report-commodity exchange-fn))
bal
))
pos-bal report-commodity exchange-fn))
(balance
(cond
((gnc:uniform-commodity? pos-bal report-commodity) bal)
(show-fcur? (gnc-commodity-table pos-bal report-commodity
exchange-fn))
(else bal)))
(column (or col 0))
)
(gnc:html-table-add-labeled-amount-line!
@ -553,10 +536,8 @@
)
)
(gnc:report-percent-done 5)
;; Pre-fetch expense account balances.
(set! expense-account-balances
(get-assoc-account-balances-budget
@ -575,10 +556,8 @@
(lambda (account start-date end-date)
(gnc:select-assoc-account-balance expense-account-balances account)))
(gnc:report-percent-done 10)
;; Pre-fetch revenue account balances.
(set! revenue-account-balances
(get-assoc-account-balances-budget
@ -599,15 +578,11 @@
(gnc:commodity-collector-get-negated
(gnc:select-assoc-account-balance revenue-account-balances account))))
(gnc:report-percent-done 20)
;; calculate net income
(set! net-income (gnc:make-commodity-collector))
(net-income 'merge revenue-total #f)
(net-income 'minusmerge expense-total #f)
(set! net-income
(gnc:collector- revenue-total expense-total))
(gnc:report-percent-done 30)

13098
po/hr.po

File diff suppressed because it is too large Load Diff