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)
|
(list (vector bank 150 150)
|
||||||
(vector aapl -150 0))
|
(vector aapl -150 0))
|
||||||
#:description "spin-off $150")
|
#:description "spin-off $150")
|
||||||
|
|
||||||
account-alist))
|
account-alist))
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
#include "gnc-prefs.h"
|
#include "gnc-prefs.h"
|
||||||
#include "gnc-ui.h"
|
#include "gnc-ui.h"
|
||||||
#include "gnc-ui-util.h"
|
#include "gnc-ui-util.h"
|
||||||
|
#include <gnc-session.h>
|
||||||
#include "gnc-component-manager.h"
|
#include "gnc-component-manager.h"
|
||||||
#include "dialog-preferences.h"
|
#include "dialog-preferences.h"
|
||||||
#include "dialog-doclink-utils.h"
|
#include "dialog-doclink-utils.h"
|
||||||
@ -122,10 +123,14 @@ GSList *add_ins = NULL;
|
|||||||
static gchar *gnc_account_separator_is_valid (const gchar *separator,
|
static gchar *gnc_account_separator_is_valid (const gchar *separator,
|
||||||
gchar **normalized_separator)
|
gchar **normalized_separator)
|
||||||
{
|
{
|
||||||
QofBook *book = gnc_get_current_book ();
|
QofBook *book;
|
||||||
GList *conflict_accts = NULL;
|
GList *conflict_accts = NULL;
|
||||||
gchar *message = NULL;
|
gchar *message = NULL;
|
||||||
|
|
||||||
|
if (!gnc_current_session_exist())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
book = gnc_get_current_book ();
|
||||||
*normalized_separator = gnc_normalize_account_separator (separator);
|
*normalized_separator = gnc_normalize_account_separator (separator);
|
||||||
conflict_accts = gnc_account_list_name_violations (book, *normalized_separator);
|
conflict_accts = gnc_account_list_name_violations (book, *normalized_separator);
|
||||||
if (conflict_accts)
|
if (conflict_accts)
|
||||||
@ -151,7 +156,7 @@ gnc_account_separator_pref_changed_cb (GtkEntry *entry, GtkWidget *dialog)
|
|||||||
{
|
{
|
||||||
GtkWidget *label, *image;
|
GtkWidget *label, *image;
|
||||||
gchar *sample;
|
gchar *sample;
|
||||||
gchar *separator;
|
gchar *separator = NULL;
|
||||||
|
|
||||||
gchar *conflict_msg = gnc_account_separator_is_valid (gtk_entry_get_text (entry), &separator);
|
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");
|
GtkWidget *entry = g_object_get_data (G_OBJECT(dialog), "account-separator");
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
gchar *separator;
|
gchar *separator = NULL;
|
||||||
gchar *conflict_msg = gnc_account_separator_is_valid (gtk_entry_get_text (GTK_ENTRY(entry)), &separator);
|
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 */
|
/* Check if the new separator clashes with existing account names */
|
||||||
@ -1337,7 +1342,6 @@ gnc_preferences_dialog_create (GtkWindow *parent)
|
|||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gnc_commodity *locale_currency;
|
gnc_commodity *locale_currency;
|
||||||
const gchar *currency_name;
|
const gchar *currency_name;
|
||||||
QofBook *book;
|
|
||||||
GDate fy_end;
|
GDate fy_end;
|
||||||
gboolean date_is_valid = FALSE;
|
gboolean date_is_valid = FALSE;
|
||||||
|
|
||||||
@ -1412,11 +1416,14 @@ gnc_preferences_dialog_create (GtkWindow *parent)
|
|||||||
prefs_table, (GDestroyNotify)g_hash_table_destroy);
|
prefs_table, (GDestroyNotify)g_hash_table_destroy);
|
||||||
|
|
||||||
|
|
||||||
book = gnc_get_current_book ();
|
if (gnc_current_session_exist())
|
||||||
g_date_clear (&fy_end, 1);
|
{
|
||||||
qof_instance_get (QOF_INSTANCE(book),
|
QofBook *book = gnc_get_current_book ();
|
||||||
"fy-end", &fy_end,
|
g_date_clear (&fy_end, 1);
|
||||||
NULL);
|
qof_instance_get (QOF_INSTANCE(book),
|
||||||
|
"fy-end", &fy_end,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
box = GTK_WIDGET(gtk_builder_get_object (builder,
|
box = GTK_WIDGET(gtk_builder_get_object (builder,
|
||||||
"pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_PERIOD));
|
"pref/" GNC_PREFS_GROUP_ACCT_SUMMARY "/" GNC_PREF_START_PERIOD));
|
||||||
period = gnc_period_select_new (TRUE);
|
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)))
|
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);
|
gnc_gnome_help (GTK_WINDOW(new_user->window), HF_GUIDE, NULL);
|
||||||
gncp_new_user_finish ();
|
|
||||||
}
|
}
|
||||||
gtk_widget_destroy (new_user->window);
|
gtk_widget_destroy (new_user->window);
|
||||||
}
|
}
|
||||||
@ -198,7 +197,6 @@ gnc_ui_new_user_cancel_dialog (GtkWindow *parent)
|
|||||||
keepshowing = (result == GTK_RESPONSE_YES);
|
keepshowing = (result == GTK_RESPONSE_YES);
|
||||||
|
|
||||||
gnc_set_first_startup (keepshowing);
|
gnc_set_first_startup (keepshowing);
|
||||||
gncp_new_user_finish ();
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(builder));
|
g_object_unref(G_OBJECT(builder));
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
(define (test-average-balance)
|
(define (test-average-balance)
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(account-alist (env-create-account-structure-alist env structure))
|
(account-alist (env-create-account-structure-alist env structure))
|
||||||
(options (gnc:make-report-options uuid))
|
(options (gnc:make-report-options uuid))
|
||||||
(bank (cdr (assoc "Bank" account-alist)))
|
(bank (cdr (assoc "Bank" account-alist)))
|
||||||
|
@ -49,7 +49,9 @@
|
|||||||
(gnc-commodity-get-namespace (gnc-default-report-currency))
|
(gnc-commodity-get-namespace (gnc-default-report-currency))
|
||||||
sym))
|
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 GBP (mnemonic->commodity "GBP"))
|
||||||
(define FUNDS (gnc-commodity-new (gnc-get-current-book)
|
(define FUNDS (gnc-commodity-new (gnc-get-current-book)
|
||||||
"Funds" ;fullname
|
"Funds" ;fullname
|
||||||
@ -91,6 +93,7 @@
|
|||||||
(define (create-test-data)
|
(define (create-test-data)
|
||||||
;; This function will perform implementation testing on the transaction report.
|
;; This function will perform implementation testing on the transaction report.
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(account-alist (env-create-account-structure-alist env structure))
|
(account-alist (env-create-account-structure-alist env structure))
|
||||||
(bank1savings (cdr (assoc "Savings" account-alist)))
|
(bank1savings (cdr (assoc "Savings" account-alist)))
|
||||||
(bank1bonds (cdr (assoc "Bonds" account-alist)))
|
(bank1bonds (cdr (assoc "Bonds" account-alist)))
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
(list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))))
|
(list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))))
|
||||||
;; This function will perform implementation testing on the GST report.
|
;; This function will perform implementation testing on the GST report.
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(account-alist (env-create-account-structure-alist env structure))
|
(account-alist (env-create-account-structure-alist env structure))
|
||||||
(bank (cdr (assoc "Bank" account-alist)))
|
(bank (cdr (assoc "Bank" account-alist)))
|
||||||
(income (cdr (assoc "Income" account-alist)))
|
(income (cdr (assoc "Income" account-alist)))
|
||||||
@ -224,6 +225,7 @@
|
|||||||
(list "EU Reverse VAT Expenses"))))
|
(list "EU Reverse VAT Expenses"))))
|
||||||
;; This function will perform implementation testing on the VAT report.
|
;; This function will perform implementation testing on the VAT report.
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(account-alist (env-create-account-structure-alist env structure))
|
(account-alist (env-create-account-structure-alist env structure))
|
||||||
(YEAR (gnc:time64-get-year (gnc:get-today))))
|
(YEAR (gnc:time64-get-year (gnc:get-today))))
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
(define (portfolio-tests)
|
(define (portfolio-tests)
|
||||||
(test-group-with-cleanup "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)))
|
(options (gnc:make-report-options portfolio-uuid)))
|
||||||
(set-option! options "General" "Price Source" 'pricedb-latest)
|
(set-option! options "General" "Price Source" 'pricedb-latest)
|
||||||
(let ((sxml (options->sxml portfolio-uuid options "latest")))
|
(let ((sxml (options->sxml portfolio-uuid options "latest")))
|
||||||
@ -97,7 +97,8 @@
|
|||||||
|
|
||||||
(define (advanced-tests)
|
(define (advanced-tests)
|
||||||
(test-group-with-cleanup "advanced-portfolio-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)))
|
(options (gnc:make-report-options advanced-uuid)))
|
||||||
(let ((sxml (options->sxml advanced-uuid options "basic average")))
|
(let ((sxml (options->sxml advanced-uuid options "basic average")))
|
||||||
(test-equal "advanced: average basis"
|
(test-equal "advanced: average basis"
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
(define (test-account-get-trans-type-splits-interval)
|
(define (test-account-get-trans-type-splits-interval)
|
||||||
(test-group-with-cleanup "test-account-get-trans-type-splits-interval"
|
(test-group-with-cleanup "test-account-get-trans-type-splits-interval"
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(ts-now (gnc-localtime (current-time)))
|
(ts-now (gnc-localtime (current-time)))
|
||||||
(test-day (tm:mday ts-now))
|
(test-day (tm:mday ts-now))
|
||||||
(test-month (+ 1 (tm:mon ts-now)))
|
(test-month (+ 1 (tm:mon ts-now)))
|
||||||
@ -287,6 +288,7 @@
|
|||||||
|
|
||||||
(define (create-test-data)
|
(define (create-test-data)
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(account-alist (env-create-account-structure-alist env (structure)))
|
(account-alist (env-create-account-structure-alist env (structure)))
|
||||||
(asset (cdr (assoc "Asset" account-alist)))
|
(asset (cdr (assoc "Asset" account-alist)))
|
||||||
(bank (cdr (assoc "Bank" account-alist)))
|
(bank (cdr (assoc "Bank" account-alist)))
|
||||||
@ -613,6 +615,7 @@
|
|||||||
(define (test-get-account-at-dates)
|
(define (test-get-account-at-dates)
|
||||||
(test-group-with-cleanup "test-get-balance-at-dates"
|
(test-group-with-cleanup "test-get-balance-at-dates"
|
||||||
(let* ((env (create-test-env))
|
(let* ((env (create-test-env))
|
||||||
|
(book (gnc-get-current-book))
|
||||||
(structure (list "Root" (list (cons 'type ACCT-TYPE-ASSET))
|
(structure (list "Root" (list (cons 'type ACCT-TYPE-ASSET))
|
||||||
(list "Asset"
|
(list "Asset"
|
||||||
(list "Bank1")
|
(list "Bank1")
|
||||||
|
@ -565,7 +565,9 @@ gnc_get_current_root_account (void)
|
|||||||
gnc_commodity_table *
|
gnc_commodity_table *
|
||||||
gnc_get_current_commodities (void)
|
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 *
|
gchar *
|
||||||
@ -1170,10 +1172,13 @@ gnc_default_currency_common (gchar *requested_currency,
|
|||||||
GNC_COMMODITY_NS_CURRENCY,
|
GNC_COMMODITY_NS_CURRENCY,
|
||||||
requested_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 ());
|
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);
|
mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER);
|
||||||
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
|
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
|
||||||
@ -1185,11 +1190,13 @@ gnc_default_currency_common (gchar *requested_currency,
|
|||||||
|
|
||||||
if (!currency)
|
if (!currency)
|
||||||
currency = gnc_locale_default_currency ();
|
currency = gnc_locale_default_currency ();
|
||||||
|
|
||||||
if (currency)
|
if (currency)
|
||||||
{
|
{
|
||||||
mnemonic = requested_currency;
|
mnemonic = requested_currency;
|
||||||
g_free(mnemonic);
|
g_free(mnemonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user