mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 798664 - Result of 'gnucash --nofile' is marked dirty
Don't create a new book in the new-user dialog unless the user says to. Don't automatically create a new book when retrieving default commodities because the retrieve might be requested in a context like the Preferences dialog when there is no book. Some report tests relied on requesting the default commodity creating the book, so in those tests ensure that the book is created first.
This commit is contained in:
parent
fae5de80d3
commit
b4bab92da2
@ -1049,6 +1049,5 @@
|
||||
(list (vector bank 150 150)
|
||||
(vector aapl -150 0))
|
||||
#:description "spin-off $150")
|
||||
|
||||
account-alist))
|
||||
|
||||
|
@ -75,6 +75,7 @@
|
||||
#include "gnc-prefs.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include <gnc-session.h>
|
||||
#include "gnc-component-manager.h"
|
||||
#include "dialog-preferences.h"
|
||||
#include "dialog-doclink-utils.h"
|
||||
@ -122,10 +123,14 @@ GSList *add_ins = NULL;
|
||||
static gchar *gnc_account_separator_is_valid (const gchar *separator,
|
||||
gchar **normalized_separator)
|
||||
{
|
||||
QofBook *book = gnc_get_current_book ();
|
||||
QofBook *book;
|
||||
GList *conflict_accts = NULL;
|
||||
gchar *message = NULL;
|
||||
|
||||
if (!gnc_current_session_exist())
|
||||
return NULL;
|
||||
|
||||
book = gnc_get_current_book ();
|
||||
*normalized_separator = gnc_normalize_account_separator (separator);
|
||||
conflict_accts = gnc_account_list_name_violations (book, *normalized_separator);
|
||||
if (conflict_accts)
|
||||
@ -151,7 +156,7 @@ gnc_account_separator_pref_changed_cb (GtkEntry *entry, GtkWidget *dialog)
|
||||
{
|
||||
GtkWidget *label, *image;
|
||||
gchar *sample;
|
||||
gchar *separator;
|
||||
gchar *separator = NULL;
|
||||
|
||||
gchar *conflict_msg = gnc_account_separator_is_valid (gtk_entry_get_text (entry), &separator);
|
||||
|
||||
@ -200,7 +205,7 @@ gnc_account_separator_validate (GtkWidget *dialog)
|
||||
{
|
||||
GtkWidget *entry = g_object_get_data (G_OBJECT(dialog), "account-separator");
|
||||
gboolean ret = TRUE;
|
||||
gchar *separator;
|
||||
gchar *separator = NULL;
|
||||
gchar *conflict_msg = gnc_account_separator_is_valid (gtk_entry_get_text (GTK_ENTRY(entry)), &separator);
|
||||
|
||||
/* Check if the new separator clashes with existing account names */
|
||||
@ -1337,7 +1342,6 @@ gnc_preferences_dialog_create (GtkWindow *parent)
|
||||
GtkTreeIter iter;
|
||||
gnc_commodity *locale_currency;
|
||||
const gchar *currency_name;
|
||||
QofBook *book;
|
||||
GDate fy_end;
|
||||
gboolean date_is_valid = FALSE;
|
||||
|
||||
@ -1412,11 +1416,14 @@ gnc_preferences_dialog_create (GtkWindow *parent)
|
||||
prefs_table, (GDestroyNotify)g_hash_table_destroy);
|
||||
|
||||
|
||||
book = gnc_get_current_book ();
|
||||
g_date_clear (&fy_end, 1);
|
||||
qof_instance_get (QOF_INSTANCE(book),
|
||||
"fy-end", &fy_end,
|
||||
NULL);
|
||||
if (gnc_current_session_exist())
|
||||
{
|
||||
QofBook *book = gnc_get_current_book ();
|
||||
g_date_clear (&fy_end, 1);
|
||||
qof_instance_get (QOF_INSTANCE(book),
|
||||
"fy-end", &fy_end,
|
||||
NULL);
|
||||
}
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder,
|
||||
"pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_PERIOD));
|
||||
period = gnc_period_select_new (TRUE);
|
||||
|
@ -123,7 +123,6 @@ gnc_ui_new_user_ok_cb (GtkWidget * widget, gpointer data)
|
||||
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (new_user->tutorial_button)))
|
||||
{
|
||||
gnc_gnome_help (GTK_WINDOW(new_user->window), HF_GUIDE, NULL);
|
||||
gncp_new_user_finish ();
|
||||
}
|
||||
gtk_widget_destroy (new_user->window);
|
||||
}
|
||||
@ -198,7 +197,6 @@ gnc_ui_new_user_cancel_dialog (GtkWindow *parent)
|
||||
keepshowing = (result == GTK_RESPONSE_YES);
|
||||
|
||||
gnc_set_first_startup (keepshowing);
|
||||
gncp_new_user_finish ();
|
||||
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
gtk_widget_destroy(dialog);
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
(define (test-average-balance)
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(account-alist (env-create-account-structure-alist env structure))
|
||||
(options (gnc:make-report-options uuid))
|
||||
(bank (cdr (assoc "Bank" account-alist)))
|
||||
|
@ -49,7 +49,9 @@
|
||||
(gnc-commodity-get-namespace (gnc-default-report-currency))
|
||||
sym))
|
||||
|
||||
(define USD (gnc-default-report-currency)) ;default currency should be USD because LC_ALL="C"
|
||||
(define USD
|
||||
(let ((book (gnc-get-current-book))) ; ensure the book is set
|
||||
(gnc-default-report-currency))) ;default currency should be USD because LC_ALL="C"
|
||||
(define GBP (mnemonic->commodity "GBP"))
|
||||
(define FUNDS (gnc-commodity-new (gnc-get-current-book)
|
||||
"Funds" ;fullname
|
||||
@ -91,6 +93,7 @@
|
||||
(define (create-test-data)
|
||||
;; This function will perform implementation testing on the transaction report.
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(account-alist (env-create-account-structure-alist env structure))
|
||||
(bank1savings (cdr (assoc "Savings" account-alist)))
|
||||
(bank1bonds (cdr (assoc "Bonds" account-alist)))
|
||||
|
@ -76,6 +76,7 @@
|
||||
(list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))))
|
||||
;; This function will perform implementation testing on the GST report.
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(account-alist (env-create-account-structure-alist env structure))
|
||||
(bank (cdr (assoc "Bank" account-alist)))
|
||||
(income (cdr (assoc "Income" account-alist)))
|
||||
@ -224,6 +225,7 @@
|
||||
(list "EU Reverse VAT Expenses"))))
|
||||
;; This function will perform implementation testing on the VAT report.
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(account-alist (env-create-account-structure-alist env structure))
|
||||
(YEAR (gnc:time64-get-year (gnc:get-today))))
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
|
||||
(define (portfolio-tests)
|
||||
(test-group-with-cleanup "portfolio-tests"
|
||||
(let* ((account-alist (create-stock-test-data))
|
||||
(let ((account-alist (create-stock-test-data))
|
||||
(options (gnc:make-report-options portfolio-uuid)))
|
||||
(set-option! options "General" "Price Source" 'pricedb-latest)
|
||||
(let ((sxml (options->sxml portfolio-uuid options "latest")))
|
||||
@ -97,7 +97,8 @@
|
||||
|
||||
(define (advanced-tests)
|
||||
(test-group-with-cleanup "advanced-portfolio-tests"
|
||||
(let ((account-alist (create-stock-test-data))
|
||||
;; let* required here to ensure that the book is created before creating the options.
|
||||
(let* ((account-alist (create-stock-test-data))
|
||||
(options (gnc:make-report-options advanced-uuid)))
|
||||
(let ((sxml (options->sxml advanced-uuid options "basic average")))
|
||||
(test-equal "advanced: average basis"
|
||||
|
@ -38,6 +38,7 @@
|
||||
(define (test-account-get-trans-type-splits-interval)
|
||||
(test-group-with-cleanup "test-account-get-trans-type-splits-interval"
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(ts-now (gnc-localtime (current-time)))
|
||||
(test-day (tm:mday ts-now))
|
||||
(test-month (+ 1 (tm:mon ts-now)))
|
||||
@ -287,6 +288,7 @@
|
||||
|
||||
(define (create-test-data)
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(account-alist (env-create-account-structure-alist env (structure)))
|
||||
(asset (cdr (assoc "Asset" account-alist)))
|
||||
(bank (cdr (assoc "Bank" account-alist)))
|
||||
@ -613,6 +615,7 @@
|
||||
(define (test-get-account-at-dates)
|
||||
(test-group-with-cleanup "test-get-balance-at-dates"
|
||||
(let* ((env (create-test-env))
|
||||
(book (gnc-get-current-book))
|
||||
(structure (list "Root" (list (cons 'type ACCT-TYPE-ASSET))
|
||||
(list "Asset"
|
||||
(list "Bank1")
|
||||
|
@ -565,7 +565,9 @@ gnc_get_current_root_account (void)
|
||||
gnc_commodity_table *
|
||||
gnc_get_current_commodities (void)
|
||||
{
|
||||
return gnc_commodity_table_get_table (gnc_get_current_book ());
|
||||
if (gnc_current_session_exist())
|
||||
return gnc_commodity_table_get_table (gnc_get_current_book ());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gchar *
|
||||
@ -1170,10 +1172,13 @@ gnc_default_currency_common (gchar *requested_currency,
|
||||
GNC_COMMODITY_NS_CURRENCY,
|
||||
requested_currency);
|
||||
|
||||
if (gnc_book_use_book_currency (gnc_get_current_book ()))
|
||||
if (gnc_current_session_exist() &&
|
||||
gnc_book_use_book_currency (gnc_get_current_book ()))
|
||||
return gnc_book_get_book_currency (gnc_get_current_book ());
|
||||
|
||||
if (gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
|
||||
|
||||
if (gnc_current_session_exist() &&
|
||||
gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
|
||||
{
|
||||
mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER);
|
||||
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
|
||||
@ -1185,11 +1190,13 @@ gnc_default_currency_common (gchar *requested_currency,
|
||||
|
||||
if (!currency)
|
||||
currency = gnc_locale_default_currency ();
|
||||
|
||||
if (currency)
|
||||
{
|
||||
mnemonic = requested_currency;
|
||||
g_free(mnemonic);
|
||||
}
|
||||
|
||||
return currency;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user