From 05df54193f287194822433c6cfded8b07911b189 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 23 Dec 2007 21:45:34 +0000 Subject: [PATCH 01/29] String improvements, as pointed out by Clytie Siddall. This changeset does not add any untranslated strings and does not change any existing translated strings. It can directly be back-ported. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16703 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome/glade/budget.glade | 8 ++++---- src/gnome/schemas/apps_gnucash_dialog_common.schemas.in | 2 +- src/report/locale-specific/us/taxtxf-de_DE.scm | 5 ++++- src/report/locale-specific/us/taxtxf.scm | 8 +++++++- src/report/report-system/report.scm | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gnome/glade/budget.glade b/src/gnome/glade/budget.glade index e976748fba..1899ccabe1 100644 --- a/src/gnome/glade/budget.glade +++ b/src/gnome/glade/budget.glade @@ -824,7 +824,7 @@ year(s) True True - button1 + button1 True GTK_RELIEF_NORMAL True @@ -840,7 +840,7 @@ year(s) True True - togglebutton1 + togglebutton1 True GTK_RELIEF_NORMAL True @@ -858,7 +858,7 @@ year(s) True True - checkbutton1 + checkbutton1 True GTK_RELIEF_NORMAL True @@ -877,7 +877,7 @@ year(s) True True - radiobutton1 + radiobutton1 True GTK_RELIEF_NORMAL True diff --git a/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in b/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in index 5b5d03e564..0ae9ec32af 100644 --- a/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in +++ b/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in @@ -160,7 +160,7 @@ 1.0 Default to 'new search' if fewer than this number of items is returned - Default to 'new search' if fewer than this number of items is returned. + Default to 'new search' if fewer than this number of items is returned diff --git a/src/report/locale-specific/us/taxtxf-de_DE.scm b/src/report/locale-specific/us/taxtxf-de_DE.scm index c9573b43d4..a5bb200cf5 100644 --- a/src/report/locale-specific/us/taxtxf-de_DE.scm +++ b/src/report/locale-specific/us/taxtxf-de_DE.scm @@ -137,6 +137,9 @@ (list->vector (list '2nd-est (N_ "2nd Est Tax Quarter") (N_ "Apr 1 - May 31"))) (list->vector + ;; Translators: The US tax quarters are different from + ;; actual year's quarters! See the definition of + ;; tax-qtr-real-qtr-year variable above. (list '3rd-est (N_ "3rd Est Tax Quarter") (N_ "Jun 1 - Aug 31"))) (list->vector (list '4th-est (N_ "4th Est Tax Quarter") (N_ "Sep 1 - Dec 31"))) @@ -283,7 +286,7 @@ '() (cons (gnc:make-html-table-header-cell/markup "number-header" - (_ "Sub-") + "Sub-" (number->string (- max-level 1))) (make-sub-headers (- max-level 1))))) diff --git a/src/report/locale-specific/us/taxtxf.scm b/src/report/locale-specific/us/taxtxf.scm index 87aa712927..b47a99bd49 100644 --- a/src/report/locale-specific/us/taxtxf.scm +++ b/src/report/locale-specific/us/taxtxf.scm @@ -121,6 +121,9 @@ (list->vector (list '2nd-est (N_ "2nd Est Tax Quarter") (N_ "Apr 1 - May 31"))) (list->vector + ;; Translators: The US tax quarters are different from + ;; actual year's quarters! See the definition of + ;; tax-qtr-real-qtr-year variable above. (list '3rd-est (N_ "3rd Est Tax Quarter") (N_ "Jun 1 - Aug 31"))) (list->vector (list '4th-est (N_ "4th Est Tax Quarter") (N_ "Sep 1 - Dec 31"))) @@ -134,6 +137,9 @@ (N_ "Apr 1 - May 31, Last year"))) (list->vector (list '3rd-last (N_ "Last Yr 3rd Est Tax Qtr") + ;; Translators: The US tax quarters are different from + ;; actual year's quarters! See the definition of + ;; tax-qtr-real-qtr-year variable above. (N_ "Jun 1 - Aug 31, Last year"))) (list->vector (list '4th-last (N_ "Last Yr 4th Est Tax Qtr") @@ -267,7 +273,7 @@ '() (cons (gnc:make-html-table-header-cell/markup "number-header" - (_ "Sub-") + "Sub-" (number->string (- max-level 1))) (make-sub-headers (- max-level 1))))) diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm index 8d1fd73305..3df716b46e 100644 --- a/src/report/report-system/report.scm +++ b/src/report/report-system/report.scm @@ -169,7 +169,7 @@ (string->symbol (gnc:html-style-sheet-name ss)) (gnc:html-style-sheet-name ss) (string-append (gnc:html-style-sheet-name ss) - (_ " Stylesheet")))) + " " (_ "Stylesheet")))) (gnc:get-html-style-sheets))))) (if (procedure? generator) From 3494820ae8bd400b1ed7f12f1cd51f41fb3c5c93 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 23 Dec 2007 21:45:41 +0000 Subject: [PATCH 02/29] String improvements in gconf labels and error messages as pointed out by Clytie Siddall. Those strings are invisible for almost any user anyway and can therefore be back-ported soon, too. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16704 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome/druid-merge.c | 2 +- .../schemas/apps_gnucash_dialog_commodities.schemas.in | 2 +- src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in | 2 +- src/gnome/schemas/apps_gnucash_warnings.schemas.in | 6 +++--- .../apps_gnucash_import_generic_matcher.schemas.in | 8 ++++---- src/report/report-gnome/window-report.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gnome/druid-merge.c b/src/gnome/druid-merge.c index 4ba70bc775..d45ca78dd6 100644 --- a/src/gnome/druid-merge.c +++ b/src/gnome/druid-merge.c @@ -352,7 +352,7 @@ void collision_rule_loop(QofBookMergeData *mergeData, QofBookMergeRule *rule, will allocate a new string; all of these need to be freed later. Currently this causes a lot of memory leaks. */ - buffer = g_strconcat(buffer, g_strdup_printf(_("%i:Parameter name: %s "), + buffer = g_strconcat(buffer, g_strdup_printf(_("%i: Parameter name: %s "), count, one_param->param_name), NULL); importstring = qof_book_merge_param_as_string(one_param, rule->importEnt); buffer = g_strconcat(buffer, diff --git a/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in b/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in index b87bb4897a..ed2de661b4 100644 --- a/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in +++ b/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in @@ -10,7 +10,7 @@ [namespace,symbol,name,printname,uniquename,cusip_code,fraction,quote_flag,quote_source,quote_timezone] Order of columns in the dialog - This setting contains a list of name which control the order + This setting contains a list of names which controls the order in which the columns are listed in the dialog. Names may be reordered or removed from this list to control which columns appear in the dialog and in what order. diff --git a/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in b/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in index 3294c0954b..fb66dbbf2d 100644 --- a/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in +++ b/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in @@ -10,7 +10,7 @@ [commodity,currency,date,source,type,price] Order of columns in the dialog - This setting contains a list of name which control the order + This setting contains a list of names which controls the order in which the columns are listed in the dialog. Names may be reordered or removed from this list to control which columns appear in the dialog and in what order. diff --git a/src/gnome/schemas/apps_gnucash_warnings.schemas.in b/src/gnome/schemas/apps_gnucash_warnings.schemas.in index 46ce0f5c9e..c9db1583b5 100644 --- a/src/gnome/schemas/apps_gnucash_warnings.schemas.in +++ b/src/gnome/schemas/apps_gnucash_warnings.schemas.in @@ -75,8 +75,8 @@ int 0 - Remove a splits from a transaction - This dialog is presented before allowing you to remove a splits from a transaction. + Remove a split from a transaction + This dialog is presented before allowing you to remove a split from a transaction. @@ -88,7 +88,7 @@ int 0 - Remove a splits from a transaction + Remove a reconciled split from a transaction This dialog is presented before allowing you to remove a reconciled split from a transaction. Doing so will throw off the reconciled value of the register and can make it hard to perform future reconciliations. diff --git a/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in b/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in index 806d8c4307..772b202f14 100644 --- a/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in +++ b/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in @@ -143,11 +143,11 @@ This field specifies the extra fee that is taken into account when matching imported transactions. In some places commercial ATMs (not belonging to a financial institution) - are installed in places like convienience store. These ATM - add its fee directly to the amount instead of showing up as + are installed in places like convenience stores. These ATMs + add their fee directly to the amount instead of showing up as a separate transaction or in your monthly banking fees. For - example, you withdraw 100$, and you are charged 101,50$ plus - Interac fees. If you manually entered that 100$, the + example, you withdraw $100, and you are charged $101,50 plus + Interac fees. If you manually entered that $100, the amounts won't match. You should set this to whatever is the maximum such fee in your area (in units of your local currency), so the transaction will be recognised as a match. diff --git a/src/report/report-gnome/window-report.c b/src/report/report-gnome/window-report.c index 65f797c1f7..321de184ba 100644 --- a/src/report/report-gnome/window-report.c +++ b/src/report/report-gnome/window-report.c @@ -243,7 +243,7 @@ gnc_html_options_url_cb (const char *location, const char *label, report == SCM_BOOL_F) { result->error_message = - g_strdup_printf (_("Badly report id: %s"), location); + g_strdup_printf (_("Badly-formed report id: %s"), location); return FALSE; } From fbf08c2a0de4a243deecdca0ce22dc8e471ff8a0 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 23 Dec 2007 21:45:46 +0000 Subject: [PATCH 03/29] Remove extra spaces in glade messages. Pointed out by Clytie Siddal. Those will break 2 translated strings. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16705 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/import-export/hbci/glade/hbci.glade | 2 +- src/import-export/qif-import/qif.glade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/import-export/hbci/glade/hbci.glade b/src/import-export/hbci/glade/hbci.glade index c5bede62af..cfb41671f5 100644 --- a/src/import-export/hbci/glade/hbci.glade +++ b/src/import-export/hbci/glade/hbci.glade @@ -86,7 +86,7 @@ Press "Cancel" if you do not wish to setup any Online Banking connecti True - The Setup of your Online Banking connection is handled by the external program "AqBanking Setup Wizard". Please press the button below to start this program. + The Setup of your Online Banking connection is handled by the external program "AqBanking Setup Wizard". Please press the button below to start this program. False False GTK_JUSTIFY_LEFT diff --git a/src/import-export/qif-import/qif.glade b/src/import-export/qif-import/qif.glade index eb83e33143..cb9ee1302d 100644 --- a/src/import-export/qif-import/qif.glade +++ b/src/import-export/qif-import/qif.glade @@ -1119,7 +1119,7 @@ Check to see if there is an existing Type that is appropriate; if not, you can e True If you are importing a QIF file downloaded from a bank or other financial institution, some of the information in the QIF file may duplicate information already in your GnuCash accounts. GnuCash will try to detect duplicates of existing transactions. -On the next page, you will be asked to confirm that an existing transaction matches an imported transaction. Imported transactions are shown on the left side of the page, and possible matches for the selected left-hand transaction are shown to the right. There may be several old transactions that could match an imported transaction; you will be able to select the correct one by double-clicking in the "Dup?" column of the correct transaction. +On the next page, you will be asked to confirm that an existing transaction matches an imported transaction. Imported transactions are shown on the left side of the page, and possible matches for the selected left-hand transaction are shown to the right. There may be several old transactions that could match an imported transaction; you will be able to select the correct one by double-clicking in the "Dup?" column of the correct transaction. You can control the rules used by GnuCash to find duplicate transactions in the "QIF Import" section of the GnuCash Preferences dialog. From 5115546ef8a89d2fc171033ee94d86ec3536d82f Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 23 Dec 2007 21:45:56 +0000 Subject: [PATCH 04/29] Fix spelling errors in UI messages. Pointed out by Clytie Siddall. Those will break several translated strings, but the fixed typos are an actual improvement. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16706 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-reports/aging.scm | 2 +- src/gnome-utils/gnc-main-window.c | 2 +- src/gnome/dialog-print-check.c | 2 +- src/gnome/glade/print.glade | 2 +- src/import-export/generic-import.glade | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/business/business-reports/aging.scm b/src/business/business-reports/aging.scm index b8db5c4488..485c3e742e 100644 --- a/src/business/business-reports/aging.scm +++ b/src/business/business-reports/aging.scm @@ -335,7 +335,7 @@ more than one currency. This report is not designed to cope with this possibili gnc:pagename-general optname-sort-by "i" - (N_ "Sort companys by") + (N_ "Sort companies by") 'name (list (vector 'name (N_ "Name") (N_ "Name of the company")) diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 23d565b6a1..04be57cc2e 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -275,7 +275,7 @@ static GtkActionEntry gnc_menu_actions [] = { "ScrubMenuAction", NULL, N_("_Check & Repair"), NULL, NULL, NULL }, { "ActionsForgetWarningsAction", NULL, N_("Reset _Warnings..."), NULL, - N_("Reset the state of all warning message so they will be shown again."), + N_("Reset the state of all warning messages so they will be shown again."), G_CALLBACK (gnc_main_window_cmd_actions_reset_warnings) }, { "ActionsRenamePageAction", NULL, N_("Re_name Page"), NULL, N_("Rename this page."), diff --git a/src/gnome/dialog-print-check.c b/src/gnome/dialog-print-check.c index 82a9d1f230..4454f98836 100644 --- a/src/gnome/dialog-print-check.c +++ b/src/gnome/dialog-print-check.c @@ -1088,7 +1088,7 @@ read_one_check_directory(PrintCheckDialog * pcd, GtkListStore *store, * is the filename of that format; %3$s the type of * the other check format; and %4$s the filename of * that other format. */ - _("The guids in the %s check format file '%s' and " + _("The GUIDs in the %s check format file '%s' and " "the %s check format file '%s' match."), existing->group, existing->filename, format->group, format->filename); diff --git a/src/gnome/glade/print.glade b/src/gnome/glade/print.glade index 16c1fc4ae2..fa5dd7099c 100644 --- a/src/gnome/glade/print.glade +++ b/src/gnome/glade/print.glade @@ -1153,7 +1153,7 @@ Points True True - Enter a title for this custom format. This title will appear in the "Check format" selector of the Print Check dialog. Using the title of an exiting custom format will cause that format to be overwritten. + Enter a title for this custom format. This title will appear in the "Check format" selector of the Print Check dialog. Using the title of an existing custom format will cause that format to be overwritten. False False GTK_JUSTIFY_LEFT diff --git a/src/import-export/generic-import.glade b/src/import-export/generic-import.glade index 4b2763e83f..d2684b62b3 100644 --- a/src/import-export/generic-import.glade +++ b/src/import-export/generic-import.glade @@ -576,7 +576,7 @@ For a transaction that is a duplicate of an existing one, click on the "Oth check whether GnuCash chose the right existing transaction. To switch transactions between both states, click on the checkmark in the "New" column. When all new transactions have the correct destination account and all duplicates are matched with the right existing transaction, -click "Ok". +click "OK". False False GTK_JUSTIFY_LEFT @@ -1073,7 +1073,7 @@ click "Ok". True - In some places commercial ATMs (not belonging to a financial institution) are installed in places like convienience store. These ATM add its fee directly to the amount instead of showing up as a separate transaction or in your monthly banking fees. For example, you withdraw 100$, and you are charged 101,50$ plus Interac fees. If you manually entered that 100$, the amounts won't match. You should set this to whatever is the maximum such fee in your area (in units of your local currency), so the transaction will be recognised as a match. + In some places commercial ATMs (not belonging to a financial institution) are installed in places like convenience stores. These ATMs add their fee directly to the amount instead of showing up as a separate transaction or in your monthly banking fees. For example, you withdraw $100, and you are charged $101,50 plus Interac fees. If you manually entered that $100, the amounts won't match. You should set this to whatever is the maximum such fee in your area (in units of your local currency), so the transaction will be recognised as a match. True 1 2 From 27fcf8ff7cc4405a5b8fd904dfe2b5a32bfa5886 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 24 Dec 2007 04:40:46 +0000 Subject: [PATCH 05/29] Back out r16619 (#492137) because it breaks test-lots git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16712 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/cap-gains.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/cap-gains.c b/src/engine/cap-gains.c index e3fa8b70fc..1988651a3e 100644 --- a/src/engine/cap-gains.c +++ b/src/engine/cap-gains.c @@ -168,7 +168,7 @@ finder_helper (GNCLot *lot, gpointer user_data) static inline GNCLot * xaccAccountFindOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency, - gint64 guess, + guint64 guess, gboolean (*date_pred)(Timespec, Timespec)) { struct find_lot_s es; @@ -195,7 +195,7 @@ xaccAccountFindEarliestOpenLot (Account *acc, gnc_numeric sign, sign.denom); lot = xaccAccountFindOpenLot (acc, sign, currency, - G_MAXINT64, earliest_pred); + G_MAXUINT64, earliest_pred); LEAVE ("found lot=%p %s baln=%s", lot, gnc_lot_get_title (lot), gnc_num_dbg_to_string(gnc_lot_get_balance(lot))); return lot; @@ -210,7 +210,7 @@ xaccAccountFindLatestOpenLot (Account *acc, gnc_numeric sign, sign.num, sign.denom); lot = xaccAccountFindOpenLot (acc, sign, currency, - G_MININT64, latest_pred); + 0, latest_pred); LEAVE ("found lot=%p %s", lot, gnc_lot_get_title (lot)); return lot; } From 8ca76d36350776031ad8ed366d75927a3739b976 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 24 Dec 2007 04:40:53 +0000 Subject: [PATCH 06/29] First pass at a Book Closing dialog (#106383) Helps the user to auto-zeroize Income and Expense accounts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16713 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/Makefile.am | 2 + src/gnome-utils/dialog-book-close.c | 327 ++++++++++++++++++ src/gnome-utils/dialog-book-close.h | 49 +++ src/gnome-utils/glade/Makefile.am | 1 + src/gnome-utils/glade/dialog-book-close.glade | 293 ++++++++++++++++ src/gnome/gnc-plugin-basic-commands.c | 12 + src/gnome/ui/gnc-plugin-basic-commands-ui.xml | 1 + 7 files changed, 685 insertions(+) create mode 100644 src/gnome-utils/dialog-book-close.c create mode 100644 src/gnome-utils/dialog-book-close.h create mode 100644 src/gnome-utils/glade/dialog-book-close.glade diff --git a/src/gnome-utils/Makefile.am b/src/gnome-utils/Makefile.am index de15eb1e94..2adf379bc8 100644 --- a/src/gnome-utils/Makefile.am +++ b/src/gnome-utils/Makefile.am @@ -27,6 +27,7 @@ libgncmod_gnome_utils_la_SOURCES = \ account-quickfill.c \ cursors.c \ dialog-account.c \ + dialog-book-close.c \ dialog-commodity.c \ dialog-options.c \ dialog-preferences.c \ @@ -100,6 +101,7 @@ gncinclude_HEADERS = \ QuickFill.h \ account-quickfill.h \ dialog-account.h \ + dialog-book-close.h \ dialog-commodity.h \ dialog-preferences.h \ dialog-options.h \ diff --git a/src/gnome-utils/dialog-book-close.c b/src/gnome-utils/dialog-book-close.c new file mode 100644 index 0000000000..aa97875144 --- /dev/null +++ b/src/gnome-utils/dialog-book-close.c @@ -0,0 +1,327 @@ +/********************************************************************\ + * dialog-book-close.c -- dialog for helping the user close the * + * book at the end of the year by adding * + * zero-izing splits to all Income and * + * Expense accounts * + * * + * Copyright (C) 2007-8 Derek Atkins * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * + * Boston, MA 02110-1301, USA gnu@gnu.org * +\********************************************************************/ + +#include "config.h" + +#include +#include +#include + +#include "dialog-utils.h" +#include "gnc-engine.h" +#include "Transaction.h" +#include "Split.h" +#include "Account.h" +#include "gnc-ui.h" +#include "gnc-gui-query.h" +#include "dialog-book-close.h" +#include "gnc-account-sel.h" +#include "gnc-date-edit.h" + +void gnc_book_close_response_cb(GtkDialog *, gint, GtkDialog *); + +struct CloseBookWindow +{ + /* Passed in by the creator */ + QofBook* book; + + /* Parts of the dialog */ + GtkWidget* dialog; + GtkWidget* close_date_widget; + GtkWidget* income_acct_widget; + GtkWidget* expense_acct_widget; + GtkWidget* desc_widget; + + /* The final settings */ + time_t close_date; + const char* desc; +}; + +struct CloseAccountsCB +{ + struct CloseBookWindow* cbw; + Account* base_acct; + GNCAccountType acct_type; + GHashTable* txns; + guint hash_size; +}; + +struct CACBTransactionList +{ + gnc_commodity* cmdty; + Transaction* txn; + gnc_numeric total; +}; + +static struct CACBTransactionList* +find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty) +{ + struct CACBTransactionList* txn; + + g_return_val_if_fail(cacb, NULL); + g_return_val_if_fail(cmdty, NULL); + + txn = g_hash_table_lookup(cacb->txns, cmdty); + if (!txn) + { + txn = g_new0(struct CACBTransactionList, 1); + txn->cmdty = cmdty; + txn->total = gnc_numeric_zero(); + txn->txn = xaccMallocTransaction(cacb->cbw->book); + xaccTransBeginEdit(txn->txn); + xaccTransSetDateEnteredSecs(txn->txn, time(NULL)); + xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date); + xaccTransSetDescription(txn->txn, cacb->cbw->desc); + xaccTransSetCurrency(txn->txn, cmdty); + + g_hash_table_insert(cacb->txns, cmdty, txn); + } + + return txn; +} + +/* Make sure that the account is of the correct type. + * then make sure the account has a balance as of the closing date. + * then get the account commodity and find the appropriate + * balancing transaction for that commodity and add this balance + * to it. + */ +static void close_accounts_cb(Account *a, gpointer data) +{ + struct CloseAccountsCB* cacb = data; + struct CACBTransactionList* txn; + gnc_commodity* acct_commodity; + Split* split; + gnc_numeric bal; + + g_return_if_fail(a); + g_return_if_fail(cacb); + g_return_if_fail(cacb->cbw); + g_return_if_fail(cacb->txns); + + if (cacb->acct_type != xaccAccountGetType(a)) + return; + + bal = xaccAccountGetBalanceAsOfDate(a, cacb->cbw->close_date); + if (gnc_numeric_zero_p(bal)) + return; + + acct_commodity = xaccAccountGetCommodity(a); + g_assert(acct_commodity); + + txn = find_or_create_txn(cacb, acct_commodity); + g_assert(txn); + + split = xaccMallocSplit(cacb->cbw->book); + xaccSplitSetParent(split, txn->txn); + xaccAccountBeginEdit(a); + xaccAccountInsertSplit(a, split); + xaccSplitSetBaseValue(split, gnc_numeric_neg(bal), acct_commodity); + xaccAccountCommitEdit(a); + txn->total = gnc_numeric_add(txn->total, bal, GNC_DENOM_AUTO, + GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER); +} + + +static void finish_txn_cb(gnc_commodity* cmdty, + struct CACBTransactionList* txn, + struct CloseAccountsCB* cacb) +{ + Account* acc; + Split* split; + + g_return_if_fail(cmdty); + g_return_if_fail(txn); + g_return_if_fail(cacb); + g_return_if_fail(cacb->hash_size); + + /* If we only have one currency and the base account uses + * that currency, then we can use that account. Otherwise, + * create a subaccount for each currency. + */ + if (cacb->hash_size == 1 && + gnc_commodity_equal(cmdty, xaccAccountGetCommodity(cacb->base_acct))) + acc = cacb->base_acct; + else + { + acc = xaccMallocAccount(cacb->cbw->book); + xaccAccountBeginEdit(acc); + xaccAccountSetType(acc, ACCT_TYPE_EQUITY); + xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty)); + xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty)); + xaccAccountCommitEdit(acc); + } + g_assert(acc); + + /* Create the split for the Equity account to balance out + * all the accounts of this. Use the "total". + */ + split = xaccMallocSplit(cacb->cbw->book); + xaccSplitSetParent(split, txn->txn); + xaccAccountBeginEdit(acc); + xaccAccountInsertSplit(acc, split); + xaccSplitSetBaseValue(split, txn->total, cmdty); + xaccAccountCommitEdit(acc); + xaccTransCommitEdit(txn->txn); +} + +static void close_accounts_of_type(struct CloseBookWindow* cbw, + Account* acct, + GNCAccountType acct_type) +{ + struct CloseAccountsCB cacb; + Account* root_acct; + + g_return_if_fail(cbw); + g_return_if_fail(acct); + + cacb.cbw = cbw; + cacb.base_acct = acct; + cacb.acct_type = acct_type; + cacb.txns = g_hash_table_new_full(g_direct_hash, + (GEqualFunc)gnc_commodity_equal, + NULL, g_free); + + /* Iterate through all accounts and set up the balancing splits */ + root_acct = gnc_book_get_root_account(cbw->book); + gnc_account_foreach_descendant(root_acct, close_accounts_cb, &cacb); + + /* now iterate through the transactions and handle each currency */ + cacb.hash_size = g_hash_table_size(cacb.txns); + if (cacb.hash_size) + g_hash_table_foreach(cacb.txns, (GHFunc)finish_txn_cb, &cacb); + + /* Destroy the table, freeing the used memory */ + g_hash_table_destroy(cacb.txns); +} + + +void +gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused) +{ + struct CloseBookWindow* cbw; + Account* income_acct; + Account* expense_acct; + + g_return_if_fail(dialog); + + cbw = g_object_get_data(G_OBJECT(dialog), "CloseBookWindow"); + g_return_if_fail(cbw); + + switch (response) + { + case GTK_RESPONSE_HELP: + gnc_gnome_help(HF_HELP, HL_GLOBPREFS); + break; + case GTK_RESPONSE_OK: + cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget)); + cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget)); + + income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget)); + expense_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->expense_acct_widget)); + + if (!income_acct) + { + gnc_error_dialog(cbw->dialog, "%s", + _("Please select an Equity account to hold the total Period Income.")); + break; + } + + if (!expense_acct) + { + gnc_error_dialog(cbw->dialog, "%s", + _("Please select an Equity account to hold the total Period Expense.")); + break; + } + + close_accounts_of_type(cbw, income_acct, ACCT_TYPE_INCOME); + close_accounts_of_type(cbw, expense_acct, ACCT_TYPE_EXPENSE); + + /* FALLTHROUGH */ + default: + gtk_widget_destroy(GTK_WIDGET(dialog)); + break; + } +} + +void gnc_ui_close_book (QofBook* book) +{ + struct CloseBookWindow *cbw; + GladeXML* xml; + GtkWidget* box; + GList* equity_list = NULL; + + g_return_if_fail(book); + + cbw = g_new0(struct CloseBookWindow, 1); + g_return_if_fail(cbw); + cbw->book = book; + + /* Open the dialog */ + xml = gnc_glade_xml_new("dialog-book-close.glade", "Close Book"); + cbw->dialog = glade_xml_get_widget(xml, "Close Book"); + + /* close date */ + box = glade_xml_get_widget(xml, "date_box"); + cbw->close_date_widget = gnc_date_edit_new(time(NULL), FALSE, FALSE); + gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0); + + /* income acct */ + equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY)); + box = glade_xml_get_widget(xml, "income_acct_box"); + cbw->income_acct_widget = gnc_account_sel_new(); + gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget), + equity_list); + gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE); + gtk_box_pack_start(GTK_BOX(box), cbw->income_acct_widget, TRUE, TRUE, 0); + + /* expense acct */ + box = glade_xml_get_widget(xml, "expense_acct_box"); + cbw->expense_acct_widget = gnc_account_sel_new(); + gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), + equity_list); + gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE); + gtk_box_pack_start(GTK_BOX(box), cbw->expense_acct_widget, TRUE, TRUE, 0); + + /* desc */ + cbw->desc_widget = glade_xml_get_widget(xml, "desc_entry"); + + /* Autoconnect signals */ + glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, + cbw->dialog); + + /* Clean up the xml data structure when the dialog is destroyed */ + g_object_set_data_full(G_OBJECT(cbw->dialog), "dialog-book-close.glade", + xml, g_object_unref); + g_object_set_data_full(G_OBJECT(cbw->dialog), "CloseBookWindow", cbw, + g_free); + + /* Run the dialog */ + gtk_widget_show_all(cbw->dialog); + + g_list_free(equity_list); +} + diff --git a/src/gnome-utils/dialog-book-close.h b/src/gnome-utils/dialog-book-close.h new file mode 100644 index 0000000000..363c0f16a0 --- /dev/null +++ b/src/gnome-utils/dialog-book-close.h @@ -0,0 +1,49 @@ +/********************************************************************\ + * dialog-book-close.h -- dialog for helping the user close the * + * book at the end of the year by adding * + * zero-izing splits to all Income and * + * Expense accounts * + * * + * Copyright (C) 2007-8 Derek Atkins * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * + * Boston, MA 02110-1301, USA gnu@gnu.org * +\********************************************************************/ + +#ifndef DIALOG_BOOK_CLOSE_H +#define DIALOG_BOOK_CLOSE_H + +/** @addtogroup GUI + @{ */ +/** @file dialog-book-close.h + * + * This file contains the functions to present a GUI to select + * a book closing date and accounts into which to close the + * Income and Expense accounts. + */ + +/** Create and run the dialog to close the book. + * + * @param book This parameter specifies the book whose data + * will be closed. + */ +void gnc_ui_close_book (QofBook* book); + + +/** @} */ + +#endif /* DIALOG_BOOK_CLOSE_H */ diff --git a/src/gnome-utils/glade/Makefile.am b/src/gnome-utils/glade/Makefile.am index 417b2b9318..7ee34b2c1b 100644 --- a/src/gnome-utils/glade/Makefile.am +++ b/src/gnome-utils/glade/Makefile.am @@ -1,6 +1,7 @@ gladedir = $(GNC_GLADE_DIR) glade_DATA = \ commodity.glade \ + dialog-book-close.glade \ dialog-query-list.glade \ dialog-reset-warnings.glade \ druid-provider-multifile.glade \ diff --git a/src/gnome-utils/glade/dialog-book-close.glade b/src/gnome-utils/glade/dialog-book-close.glade new file mode 100644 index 0000000000..6b179abb6f --- /dev/null +++ b/src/gnome-utils/glade/dialog-book-close.glade @@ -0,0 +1,293 @@ + + + + + + + True + Close Book + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 4 + 2 + False + 0 + 0 + + + + True + Closing Date: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Income Total: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Expense Total: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + False + 0 + + + + + + + 1 + 2 + 0 + 1 + fill + + + + + + True + False + 0 + + + + + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + False + 0 + + + + + + + 1 + 2 + 2 + 3 + fill + fill + + + + + + True + Description: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + True + True + 0 + + True + • + False + + + 1 + 2 + 3 + 4 + + + + + + 0 + True + True + + + + + + + diff --git a/src/gnome/gnc-plugin-basic-commands.c b/src/gnome/gnc-plugin-basic-commands.c index a09f990302..730f9b29eb 100644 --- a/src/gnome/gnc-plugin-basic-commands.c +++ b/src/gnome/gnc-plugin-basic-commands.c @@ -37,7 +37,9 @@ #include #include "gnc-plugin-basic-commands.h" +#include "gnc-ui-util.h" +#include "dialog-book-close.h" #include "dialog-chart-export.h" #include "dialog-fincalc.h" #include "dialog-find-transactions.h" @@ -76,6 +78,7 @@ static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction static void gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data); static void gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data); static void gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data); static void gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data); static void gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data); static void gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data); @@ -157,6 +160,9 @@ static GtkActionEntry gnc_plugin_actions [] = { { "ToolsFinancialCalculatorAction", NULL, N_("_Financial Calculator"), NULL, N_("Use the financial calculator"), G_CALLBACK (gnc_main_window_cmd_tools_financial_calculator) }, + { "ToolsBookCloseAction", NULL, N_("_Close Book"), NULL, + N_("Close the Book at the end of the Period"), + G_CALLBACK (gnc_main_window_cmd_tools_close_book) }, /* Help menu */ @@ -527,6 +533,12 @@ gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindow gnc_ui_fincalc_dialog_create(); } +static void +gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data) +{ + gnc_ui_close_book(gnc_get_current_book()); +} + static void gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data) { diff --git a/src/gnome/ui/gnc-plugin-basic-commands-ui.xml b/src/gnome/ui/gnc-plugin-basic-commands-ui.xml index c1d0dc57b2..8a16b66867 100644 --- a/src/gnome/ui/gnc-plugin-basic-commands-ui.xml +++ b/src/gnome/ui/gnc-plugin-basic-commands-ui.xml @@ -59,6 +59,7 @@ + From fe28cceea709e0eeebb7bd61f01b36a779e79666 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 24 Dec 2007 04:48:49 +0000 Subject: [PATCH 07/29] Fix a fencepost error in the book closing code (#106383). Add 12 hours to the close_date before asking for the BalanceAsOfDate() git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16714 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/dialog-book-close.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gnome-utils/dialog-book-close.c b/src/gnome-utils/dialog-book-close.c index aa97875144..fc692009e0 100644 --- a/src/gnome-utils/dialog-book-close.c +++ b/src/gnome-utils/dialog-book-close.c @@ -238,6 +238,7 @@ gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused) break; case GTK_RESPONSE_OK: cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget)); + cbw->close_date += (3600 * 12); /* Add 12 hours to the timestamp */ cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget)); income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget)); From 244a779d7ae4cdcf932d6da5f807401655c3a294 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 24 Dec 2007 20:28:02 +0000 Subject: [PATCH 08/29] Make sure to properly parent auto-created accounts. Make sure to properly set account commodity. Make sure a currency sub-account doesn't already exist before creating one. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16715 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/dialog-book-close.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gnome-utils/dialog-book-close.c b/src/gnome-utils/dialog-book-close.c index fc692009e0..b829d8d09b 100644 --- a/src/gnome-utils/dialog-book-close.c +++ b/src/gnome-utils/dialog-book-close.c @@ -167,14 +167,26 @@ static void finish_txn_cb(gnc_commodity* cmdty, acc = cacb->base_acct; else { - acc = xaccMallocAccount(cacb->cbw->book); - xaccAccountBeginEdit(acc); - xaccAccountSetType(acc, ACCT_TYPE_EQUITY); - xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty)); - xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty)); - xaccAccountCommitEdit(acc); + /* See if we already have an account by that name */ + acc = gnc_account_lookup_by_name(cacb->base_acct, + gnc_commodity_get_mnemonic(cmdty)); + + /* If not, then create one */ + if (!acc) + { + acc = xaccMallocAccount(cacb->cbw->book); + xaccAccountBeginEdit(acc); + xaccAccountSetType(acc, ACCT_TYPE_EQUITY); + xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty)); + xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty)); + xaccAccountSetCommodity(acc, cmdty); + gnc_account_append_child(cacb->base_acct, acc); + xaccAccountCommitEdit(acc); + } } + /* Make sure the account exists and is of the correct commodity */ g_assert(acc); + g_assert(gnc_commodity_equal(cmdty, xaccAccountGetCommodity(acc))); /* Create the split for the Equity account to balance out * all the accounts of this. Use the "total". From 6f39c0c26e3cdb52d2af2781a781eadb988ebe43 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 24 Dec 2007 21:18:09 +0000 Subject: [PATCH 09/29] (#492137) Re-apply r16619 and make a change to the test harness to actually get the checks to pass with r16690. This was an overflow in the test harness. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16716 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/cap-gains.c | 6 +++--- src/engine/test-core/test-engine-stuff.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/engine/cap-gains.c b/src/engine/cap-gains.c index 1988651a3e..e3fa8b70fc 100644 --- a/src/engine/cap-gains.c +++ b/src/engine/cap-gains.c @@ -168,7 +168,7 @@ finder_helper (GNCLot *lot, gpointer user_data) static inline GNCLot * xaccAccountFindOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency, - guint64 guess, + gint64 guess, gboolean (*date_pred)(Timespec, Timespec)) { struct find_lot_s es; @@ -195,7 +195,7 @@ xaccAccountFindEarliestOpenLot (Account *acc, gnc_numeric sign, sign.denom); lot = xaccAccountFindOpenLot (acc, sign, currency, - G_MAXUINT64, earliest_pred); + G_MAXINT64, earliest_pred); LEAVE ("found lot=%p %s baln=%s", lot, gnc_lot_get_title (lot), gnc_num_dbg_to_string(gnc_lot_get_balance(lot))); return lot; @@ -210,7 +210,7 @@ xaccAccountFindLatestOpenLot (Account *acc, gnc_numeric sign, sign.num, sign.denom); lot = xaccAccountFindOpenLot (acc, sign, currency, - 0, latest_pred); + G_MININT64, latest_pred); LEAVE ("found lot=%p %s", lot, gnc_lot_get_title (lot)); return lot; } diff --git a/src/engine/test-core/test-engine-stuff.c b/src/engine/test-core/test-engine-stuff.c index a3f0313708..855ed2c45f 100644 --- a/src/engine/test-core/test-engine-stuff.c +++ b/src/engine/test-core/test-engine-stuff.c @@ -447,9 +447,9 @@ get_random_gnc_numeric(void) } else { - gint64 norm = RAND_IN_RANGE (8ULL); + gint64 norm = RAND_IN_RANGE (7ULL); - /* multiple of 10, between 1 and 10 million */ + /* multiple of 10, between 1 and 1 million */ deno = 1; while (norm) { @@ -460,8 +460,14 @@ get_random_gnc_numeric(void) /* Arbitrary random numbers can cause pointless overflow * during calculations. Limit dynamic range in hopes - * of avoiding overflow. */ - numer = get_random_gint64()/1000000; + * of avoiding overflow. Right now limit it to approx 2^48. + * The initial division is to help us down towards the range. + * The loop is to "make sure" we get there. We might + * want to make this dependent on "deno" in the future. + */ + do { + numer = get_random_gint64()/1000000; + } while ((numer >> 31) > 0x1FFFF); if (0 == numer) numer = 1; /* Make sure we have a non-zero denominator */ if (0 == deno) deno = 1; From 3b983ff5cbe55b8aa661e6faa494ff47d5d72be2 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Tue, 25 Dec 2007 16:23:47 +0000 Subject: [PATCH 10/29] Choose a reasonable currency in stock registers (#116353) Based on the patch from Mike Alexander, walk up the account tree until we find a "currency" account and use that instead of always using the locale currency. Pop up a dialog if this fails search fails. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16718 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../ledger-core/split-register-load.c | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/register/ledger-core/split-register-load.c b/src/register/ledger-core/split-register-load.c index 196adaea3e..91af269b9a 100644 --- a/src/register/ledger-core/split-register-load.c +++ b/src/register/ledger-core/split-register-load.c @@ -24,11 +24,14 @@ #include "config.h" +#include + #include "account-quickfill.h" #include "combocell.h" #include "gnc-component-manager.h" #include "qof.h" #include "gnc-ui-util.h" +#include "gnc-gui-query.h" #include "numcell.h" #include "quickfillcell.h" #include "recncell.h" @@ -221,7 +224,34 @@ gnc_split_register_load (SplitRegister *reg, GList * slist, if (default_account != NULL) { gnc_commodity * commodity = xaccAccountGetCommodity (default_account); if (gnc_commodity_is_currency(commodity)) - currency = commodity; + currency = commodity; + else { + Account *parent_account = default_account; + /* Account commodity is not a currency, walk up the tree until + * we find a parent account that is a currency account and use + * it's currency. + */ + do { + parent_account = gnc_account_get_parent ( parent_account ); + if (parent_account) + { + commodity = xaccAccountGetCommodity (parent_account); + if (gnc_commodity_is_currency(commodity)) + { + currency = commodity; + break; + } + } + } while (parent_account && !currency); + } + + /* If we don't have a currency then pop up a warning dialog */ + if (!currency) + { + gnc_info_dialog(NULL, "%s", + _("Could not compute the currency for this register. " + "Using the locale currency.")); + } } gnc_suspend_gui_refresh (); From 238141c6c4ccf7a301f435c10fde78f9adf71603 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Tue, 25 Dec 2007 16:56:35 +0000 Subject: [PATCH 11/29] Maintain separate invoice number sequences for AR and AP (#327218) Actually, maintain separate number sequences for Customer Invoices, Vendor Bills, and Employee Expense Vouchers. Support Jobs, too. Based on a patch by Alex Prinsier. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16720 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/gncInvoice.c | 21 +++++++++++++++++--- src/business/business-core/gncInvoiceP.h | 3 ++- src/business/business-gnome/dialog-invoice.c | 6 +++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index fd07d91b6f..b60a88609e 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -1623,7 +1623,22 @@ gboolean gncInvoiceRegister (void) return qof_object_register (&gncInvoiceDesc); } -gint64 gncInvoiceNextID (QofBook *book) -{ - return qof_book_get_counter (book, _GNC_MOD_NAME); +gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner) +{ + gint64 nextID; + switch(gncOwnerGetType(gncOwnerGetEndOwner(owner))) { + case GNC_OWNER_CUSTOMER: + nextID = qof_book_get_counter (book, "gncInvoice"); + break; + case GNC_OWNER_VENDOR: + nextID = qof_book_get_counter (book, "gncBill"); + break; + case GNC_OWNER_EMPLOYEE: + nextID = qof_book_get_counter (book, "gncExpVoucher"); + break; + default: + nextID = qof_book_get_counter (book, _GNC_MOD_NAME); + break; + } + return nextID; } diff --git a/src/business/business-core/gncInvoiceP.h b/src/business/business-core/gncInvoiceP.h index 9d4c3ac012..d91ae6b7b9 100644 --- a/src/business/business-core/gncInvoiceP.h +++ b/src/business/business-core/gncInvoiceP.h @@ -32,9 +32,10 @@ #include "Account.h" #include "Transaction.h" #include "gnc-lot.h" +#include "gncOwner.h" gboolean gncInvoiceRegister (void); -gint64 gncInvoiceNextID (QofBook *book); +gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner); void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc); void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn); void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot); diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index 53bc42f2e1..606c674a28 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -344,8 +344,12 @@ gnc_invoice_window_verify_ok (InvoiceWindow *iw) /* Check the ID; set one if necessary */ res = gtk_entry_get_text (GTK_ENTRY (iw->id_entry)); if (safe_strcmp (res, "") == 0) { + /* Invoices and bills have separate counters. + Therefore we pass the GncOwer to gncInvoiceNextID + so it knows whether we are creating a bill + or an invoice. */ string = g_strdup_printf ("%.6" G_GINT64_FORMAT, - gncInvoiceNextID(iw->book)); + gncInvoiceNextID(iw->book, &(iw->owner))); gtk_entry_set_text (GTK_ENTRY (iw->id_entry), string); g_free(string); } From a4ec8b5e52d224afd4f827890686eff91fd87d5a Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 00:03:03 +0000 Subject: [PATCH 12/29] Add currencies XDR and XXX for IMF and "no-currency" (#504935) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16721 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/iso-4217-currencies.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/iso-4217-currencies.scm b/src/engine/iso-4217-currencies.scm index b20190796c..e9cecc70d7 100644 --- a/src/engine/iso-4217-currencies.scm +++ b/src/engine/iso-4217-currencies.scm @@ -205,6 +205,9 @@ ( "Zambian Kwacha" "kwacha" "ngwee" "ISO4217" "ZMK" "894" 100 100 ) ( "Zimbabwe Dollar" "dollar" "cent" "ISO4217" "ZWD" "716" 100 100 ) +( "Special Drawing Rights" "SDR" "SDR" "ISO4217" "XDR" "960" 1 1 ) ;; International Monetary Fund +( "No currency" "" "" "ISO4217" "XXX" "999" 1 1000000 ) + ( "Gold" "ounce" "ounce" "ISO4217" "XAU" "959" 1 1000000 ) ( "Palladium" "ounce" "ounce" "ISO4217" "XPD" "964" 1 1000000 ) ( "Platinum" "ounce" "ounce" "ISO4217" "XPT" "962" 1 1000000 ) From 67119eeb539aa8021ec1b2285fe634fd2a4a27db Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 00:10:03 +0000 Subject: [PATCH 13/29] Make sure we require slib in our RPM packaging (#471321) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16722 57a11ea4-9604-0410-9ed3-97b8803252fd --- packaging/gnucash.spec.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packaging/gnucash.spec.in b/packaging/gnucash.spec.in index a33f2120c2..83c18e035e 100644 --- a/packaging/gnucash.spec.in +++ b/packaging/gnucash.spec.in @@ -1,5 +1,5 @@ # -# Spec file for FC4 +# Spec file for Fedora and other RedHat distros and derivatives # # Check whether GnuCash should build optional modules. # To modify parameters, edit the .spec file, 0 is off, 1 is on @@ -10,6 +10,10 @@ # The --whatprovides redhat-release lets us work on RHEL as well as FC # Granted, it will look weird, but at least it wont fail outright. %define fc_rel %(rpm -q --queryformat='%{VERSION}' --whatprovides redhat-release) + +# Edit dist if not a Fedora release +%define dist FC%{fc_rel} + %define version @-VERSION-@ %define __libtoolize /bin/true @@ -24,7 +28,7 @@ Name: gnucash Summary: GnuCash is an application to keep track of your finances. Version: %{version} -Release: 1.FC%{fc_rel} +Release: 1.%{dist} License: GPL Group: Applications/Finance URL: http://www.gnucash.org @@ -40,6 +44,7 @@ Requires: libgnomeui >= %{libgnomeui_version} Requires: libgnomeprintui22 >= %{libgnomeprintui22_version} Requires: guile >= %{guile_version} Requires: gtkhtml3 >= %{gtkhtml3_version} +Requires: slib >= 3a1 BuildRequires: libgnomeui-devel >= %{libgnomeui_version} BuildRequires: libgnomeprintui22-devel >= %{libgnomeprintui22_version} From 04243f92fc0bc81045bae425e4849485597e1cbd Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 01:07:04 +0000 Subject: [PATCH 14/29] reduce the width of reports (#366934) Use   instead of extra columns. Patch by Paul Andreassen git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16723 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/report/report-system/html-acct-table.scm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/report/report-system/html-acct-table.scm b/src/report/report-system/html-acct-table.scm index 0984c3e01c..9ba6ab3aef 100644 --- a/src/report/report-system/html-acct-table.scm +++ b/src/report/report-system/html-acct-table.scm @@ -1029,6 +1029,11 @@ ;; Here are some standard functions to help process gnc:html-acct-tables. ;; +(define (gnc:html-make-nbsps n) + (if (> n 0) + (string-append "      " (gnc:html-make-nbsps (- n 1))) + "")) + ;; Stylesheets define the following cell styles which these functions ;; use: "text-cell" "total-label-cell" "number-cell" ;; "total-number-cell". Row styles include "normal-row", @@ -1065,16 +1070,15 @@ (tbl-width (or table-width (+ amt-depth amt-colspan))) (row (append - (gnc:html-make-empty-cells lbl-depth) ;; padding before label (list (if label-markup ;; the actual label (gnc:make-html-table-cell/size/markup - 1 lbl-colspan label-markup label) + 1 1 label-markup (gnc:make-html-text (gnc:html-make-nbsps lbl-depth)) label) (gnc:make-html-table-cell/size - 1 lbl-colspan label)) + 1 1 (gnc:make-html-text (gnc:html-make-nbsps lbl-depth)) label)) ) (gnc:html-make-empty-cells ;; padding after label - (+ (- amt-depth (+ lbl-depth lbl-colspan)) + (+ (- amt-depth (/ tbl-width 2)) (if total-rule? -1 0) ) ) From 480bb412c7e4b17fd0e2025953ee63399ada4faf Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 01:38:45 +0000 Subject: [PATCH 15/29] Fix a crash in the receivable aging report (#384879) Dont access the owner object after it's freed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16724 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-reports/aging.scm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/business/business-reports/aging.scm b/src/business/business-reports/aging.scm index 485c3e742e..ee08318b5e 100644 --- a/src/business/business-reports/aging.scm +++ b/src/business/business-reports/aging.scm @@ -196,20 +196,27 @@ ;; if it's an existing company, destroy the temp owner and ;; then make sure the currencies match (begin - (gncOwnerDestroy temp-owner) (if (not (gnc-commodity-equiv this-currency (company-get-currency company-info))) - (cons #f (sprintf - (_ "Transactions relating to '%s' contain \ -more than one currency. This report is not designed to cope with this possibility.") (gncOwnerGetName owner))) + (let ((error-str + (string-append "IGNORING TRANSACTION!\n" "Invoice Owner: " (gncOwnerGetName owner) + "\nTransaction GUID:" (gncTransGetGuid transaction) + "\nTransaction Currency" (gnc-commodity-get-mnemonic this-currency) + "\nClient Currency" (gnc-ommodity-get-mnemonic(company-get-currency company-info))))) + (gnc-error-dialog '() error-str) + (gnc:error error-str) + (cons #f (sprintf + (_ "Transactions relating to '%s' contain \ ++more than one currency. This report is not designed to cope with this possibility.") (gncOwnerGetName owner)))) (begin (gnc:debug "it's an old company") (if (gnc-numeric-negative-p value) (process-invoice company-info (gnc-numeric-neg value) bucket-intervals this-date) (process-payment company-info value)) (hash-set! hash guid company-info) - (cons #t guid)))) + (cons #t guid))) + (gncOwnerDestroy temp-owner)) ;; if it's a new company (begin From fec3d532965c028c113b7d69948f36f47365645b Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 02:14:55 +0000 Subject: [PATCH 16/29] Allow creation of new lots from lot viewer. (#420543) Patch by Klee Dienes * src/engine/Account.c (xaccAccountRemoveLot): Generate a QOF_EVENT_REMOVE for the lot and QOF_EVENT_MODIFY for the account. (xaccAccountInsertLot): Ditto, but QOF_EVENT_ADD. * src/engine/gnc-lot.c (gnc_lot_make_default): Move from cap-gains.c. * src/engine/gnc-lot.h (gnc_lot_make_default): Add prototype. * src/engine/cap-gains.c (MakeDefaultLot): Move to gnc-lot.c as gnc_lot_make_default(). * src/gnome/lot-viewer.c: Add code to support lot creation: (RESPONSE_NEW_LOT): Add enumerated value. (lv_save_current_row): New function. (lv_select_row): Add call to lv_save_current_row. (lv_unselect_row): Use lv_save_current_row. (lv_close_handler): Use lv_save_current_row. (lv_response_cb): Handle RESPONSE_NEW_LOT. (gnc_lot_viewer_dialog): Watch for QOF_EVENT_ADD and QOF_EVENT_REMOVE for lots. * src/gnome/glade/lots.glade: Add "new lot" button. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16725 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 5 +++ src/engine/cap-gains.c | 21 +---------- src/engine/gnc-lot.c | 22 +++++++++++ src/engine/gnc-lot.h | 3 ++ src/gnome/glade/lots.glade | 75 ++++++++++++++++++++++++++++++++++++++ src/gnome/lot-viewer.c | 64 +++++++++++++++++--------------- 6 files changed, 140 insertions(+), 50 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index 5c8db486d9..06672a24c7 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -1650,6 +1650,8 @@ xaccAccountRemoveLot (Account *acc, GNCLot *lot) ENTER ("(acc=%p, lot=%p)", acc, lot); priv->lots = g_list_remove(priv->lots, lot); + qof_event_gen (&lot->inst, QOF_EVENT_REMOVE, NULL); + qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL); LEAVE ("(acc=%p, lot=%p)", acc, lot); } @@ -1685,6 +1687,9 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot) * called from gnc_book_close_period since xaccAccountInsertSplit * will try to balance capital gains and things aren't ready for that. */ + qof_event_gen (&lot->inst, QOF_EVENT_ADD, NULL); + qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL); + LEAVE ("(acc=%p, lot=%p)", acc, lot); } diff --git a/src/engine/cap-gains.c b/src/engine/cap-gains.c index e3fa8b70fc..7c234aa37e 100644 --- a/src/engine/cap-gains.c +++ b/src/engine/cap-gains.c @@ -571,25 +571,6 @@ xaccSplitAssignToLot (Split *split, GNCLot *lot) /* ============================================================== */ -static GNCLot * -MakeDefaultLot (Account *acc) -{ - GNCLot * lot; - gint64 id; - char buff[200]; - - lot = gnc_lot_new (qof_instance_get_book(acc)); - - /* Provide a reasonable title for the new lot */ - id = kvp_frame_get_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id"); - snprintf (buff, 200, ("%s %" G_GINT64_FORMAT), _("Lot"), id); - kvp_frame_set_str (gnc_lot_get_slots (lot), "/title", buff); - id ++; - kvp_frame_set_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id", id); - - return lot; -} - /* Accounting-policy callback. Given an account and an amount, * this routine should return a lot. By implementing this as * a callback, we can 'easily' add other accounting policies. @@ -632,7 +613,7 @@ xaccSplitAssign (Split *split) lot = pcy->PolicyGetLot (pcy, split); if (!lot) { - lot = MakeDefaultLot (acc); + lot = gnc_lot_make_default (acc); PINFO ("start new lot (%s)", gnc_lot_get_title(lot)); } split = xaccSplitAssignToLot (split, lot); diff --git a/src/engine/gnc-lot.c b/src/engine/gnc-lot.c index a71ef646b4..76adeca161 100644 --- a/src/engine/gnc-lot.c +++ b/src/engine/gnc-lot.c @@ -39,8 +39,12 @@ * Copyright (c) 2002,2003 Linas Vepstas */ +#include +#include + #include "config.h" #include "Account.h" +#include "AccountP.h" #include "gnc-lot.h" #include "gnc-lot-p.h" #include "cap-gains.h" @@ -454,4 +458,22 @@ gboolean gnc_lot_register (void) return qof_object_register(&gncLotDesc); } +GNCLot * gnc_lot_make_default (Account *acc) +{ + GNCLot * lot; + gint64 id; + char buff[200]; + + lot = gnc_lot_new (qof_instance_get_book(acc)); + + /* Provide a reasonable title for the new lot */ + id = kvp_frame_get_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id"); + snprintf (buff, 200, ("%s %" G_GINT64_FORMAT), _("Lot"), id); + kvp_frame_set_str (gnc_lot_get_slots (lot), "/title", buff); + id ++; + kvp_frame_set_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id", id); + + return lot; +} + /* ========================== END OF FILE ========================= */ diff --git a/src/engine/gnc-lot.h b/src/engine/gnc-lot.h index 20195c96b6..e2cf8fcae9 100644 --- a/src/engine/gnc-lot.h +++ b/src/engine/gnc-lot.h @@ -156,6 +156,9 @@ void gnc_lot_set_notes (GNCLot *, const char *); * */ KvpFrame * gnc_lot_get_slots (const GNCLot *); +/** XXX: Document? */ +GNCLot * gnc_lot_make_default (Account * acc); + #define gnc_lot_get_guid(X) qof_entity_get_guid(QOF_INSTANCE(X)) #define LOT_IS_CLOSED "is-closed?" diff --git a/src/gnome/glade/lots.glade b/src/gnome/glade/lots.glade index 22835d3c43..6ddf353603 100644 --- a/src/gnome/glade/lots.glade +++ b/src/gnome/glade/lots.glade @@ -34,6 +34,81 @@ True GTK_BUTTONBOX_END + + + True + True + True + GTK_RELIEF_NORMAL + True + 5 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-new + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _New Lot + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + True diff --git a/src/gnome/lot-viewer.c b/src/gnome/lot-viewer.c index d382481202..5a20d0c5e9 100644 --- a/src/gnome/lot-viewer.c +++ b/src/gnome/lot-viewer.c @@ -64,6 +64,7 @@ enum lot_cols { #define RESPONSE_DELETE 2 #define RESPONSE_SCRUB_LOT 3 #define RESPONSE_SCRUB_ACCOUNT 4 +#define RESPONSE_NEW_LOT 5 #define GCONF_SECTION "dialogs/lot_viewer" #define GCONF_KEY_HPOSITION "hpane_position" @@ -77,6 +78,7 @@ struct _GNCLotViewer #endif GtkButton * delete_button; GtkButton * scrub_lot_button; + GtkButton * new_lot_button; GtkPaned * lot_hpaned; GtkPaned * lot_vpaned; GtkTreeView * lot_view; @@ -210,6 +212,26 @@ lv_clear_splits (GNCLotViewer *lv) gtk_clist_clear (lv->mini_clist); } +static void +lv_save_current_row (GNCLotViewer *lv) +{ + GNCLot *lot = lv->selected_lot; + const char * str; + char * notes; + + if (lot) + { + /* Get the title, save_the_title */ + str = gtk_entry_get_text (lv->title_entry); + gnc_lot_set_title (lot, str); + + /* Get the notes, save the notes */ + notes = xxxgtk_textview_get_text (lv->lot_notes); + gnc_lot_set_notes (lot, notes); + g_free(notes); + } +} + /* ======================================================================== */ /* Callback for selecting a row the the list-of-list clist */ @@ -219,6 +241,8 @@ lv_select_row (GNCLotViewer *lv, { const char * str; + lv_save_current_row (lv); + str = gnc_lot_get_title (lot); if (!str) str = ""; gtk_entry_set_text (lv->title_entry, str); @@ -273,21 +297,7 @@ lv_unset_lot (GNCLotViewer *lv) static void lv_unselect_row (GNCLotViewer *lv) { - GNCLot *lot = lv->selected_lot; - const char * str; - char * notes; - - if (lot) - { - /* Get the title, save_the_title */ - str = gtk_entry_get_text (lv->title_entry); - gnc_lot_set_title (lot, str); - - /* Get the notes, save the notes */ - notes = xxxgtk_textview_get_text (lv->lot_notes); - gnc_lot_set_notes (lot, notes); - g_free(notes); - } + lv_save_current_row (lv); lv_unset_lot (lv); } @@ -488,20 +498,7 @@ lv_close_handler (gpointer user_data) GNCLotViewer *lv = user_data; GNCLot *lot = lv->selected_lot; - if (lot) - { - const char * str; - char *notes; - - /* Get the title, save the title */ - str = gtk_entry_get_text (lv->title_entry); - gnc_lot_set_title (lot, str); - - /* Get the notes, save the notes */ - notes = xxxgtk_textview_get_text (lv->lot_notes); - gnc_lot_set_notes (lot, notes); - g_free(notes); - } + lv_save_current_row (lv); gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(lv->window)); gtk_widget_destroy (lv->window); @@ -582,6 +579,12 @@ lv_response_cb (GtkDialog *dialog, gint response, gpointer data) gnc_lot_viewer_fill (lv); lv_show_splits (lv); break; + + case RESPONSE_NEW_LOT: + lv_save_current_row (lv); + lot = gnc_lot_make_default (lv->account); + xaccAccountInsertLot (lv->account, lot); + break; } } @@ -659,6 +662,7 @@ lv_create (GNCLotViewer *lv) #endif lv->delete_button = GTK_BUTTON(glade_xml_get_widget (xml, "delete button")); lv->scrub_lot_button = GTK_BUTTON(glade_xml_get_widget (xml, "scrub lot button")); + lv->new_lot_button = GTK_BUTTON(glade_xml_get_widget (xml, "new lot button")); lv->lot_view = GTK_TREE_VIEW(glade_xml_get_widget (xml, "lot view")); lv_init_lot_view(lv); @@ -709,7 +713,7 @@ gnc_lot_viewer_dialog (Account *account) gnc_gui_component_watch_entity_type (component_id, GNC_ID_LOT, - QOF_EVENT_CREATE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); + QOF_EVENT_CREATE | QOF_EVENT_ADD | QOF_EVENT_REMOVE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); gtk_widget_show_all (lv->window); gnc_window_adjust_for_screen (GTK_WINDOW(lv->window)); From 3759d41f969ab4e00d762a26b7a37a40272d2279 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 02:26:39 +0000 Subject: [PATCH 17/29] Don't un-clear transactions improperly when postponing reconciliation (#497517) Patch by Jeff Green and Mark Jenkins BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16726 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome/reconcile-list.c | 12 ++++++++++-- src/gnome/reconcile-list.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gnome/reconcile-list.c b/src/gnome/reconcile-list.c index 8f8e0d97cc..93eb532600 100644 --- a/src/gnome/reconcile-list.c +++ b/src/gnome/reconcile-list.c @@ -138,6 +138,7 @@ gnc_reconcile_list_new(Account *account, GNCReconcileListType type, list->account = account; list->list_type = type; + list->statement_date = statement_date; query = xaccMallocQuery(); xaccQuerySetBook(query, gnc_get_current_book ()); @@ -577,9 +578,16 @@ gnc_reconcile_list_postpone (GNCReconcileList *list) split = gtk_clist_get_row_data (clist, i); - recn = g_hash_table_lookup (list->reconciled, split) ? CREC : NREC; + // Don't change splits past reconciliation date that haven't been + // set to be reconciled + if ( difftime(list->statement_date, + xaccTransGetDate(xaccSplitGetParent(split))) >= 0 || + g_hash_table_lookup(list->reconciled, split)) + { + recn = g_hash_table_lookup (list->reconciled, split) ? CREC : NREC; - xaccSplitSetReconcile (split, recn); + xaccSplitSetReconcile (split, recn); + } } gnc_resume_gui_refresh(); } diff --git a/src/gnome/reconcile-list.h b/src/gnome/reconcile-list.h index 5e56e959fd..d696785615 100644 --- a/src/gnome/reconcile-list.h +++ b/src/gnome/reconcile-list.h @@ -49,6 +49,8 @@ struct GNCReconcileList { Account *account; GList *column_list; + time_t statement_date; + GNCReconcileList *sibling; GNCReconcileListType list_type; gboolean no_toggle; From 8dfc49dc84fbd3745a92a25c5097a5312dcfe883 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 02:39:29 +0000 Subject: [PATCH 18/29] Wait for pending events before displaying the tree view (#463678) BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16727 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-tree-view-account.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gnome-utils/gnc-tree-view-account.c b/src/gnome-utils/gnc-tree-view-account.c index d539cf5740..06527c368e 100644 --- a/src/gnome-utils/gnc-tree-view-account.c +++ b/src/gnome-utils/gnc-tree-view-account.c @@ -1119,6 +1119,11 @@ gnc_tree_view_account_set_selected_account (GncTreeViewAccount *view, gtk_tree_path_free(parent_path); gtk_tree_selection_select_path (selection, s_path); + + /* give gtk+ a chance to resize the tree view first by handling pending + * configure events */ + while (gtk_events_pending ()) + gtk_main_iteration (); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0); debug_path(LEAVE, s_path); gtk_tree_path_free(s_path); From cd0574e346c9e9f5c3a8063ab8505c005f74590e Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 03:14:22 +0000 Subject: [PATCH 19/29] Including all bills/invoices since the beginning of time. Patch by Jeff Green. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16728 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-reports/aging.scm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/business/business-reports/aging.scm b/src/business/business-reports/aging.scm index ee08318b5e..325d4dba35 100644 --- a/src/business/business-reports/aging.scm +++ b/src/business/business-reports/aging.scm @@ -301,12 +301,8 @@ (define (setup-query query account date) (define (date-copy date) (cons (car date) (cdr date))) - (let ((begindate (date-copy date))) + (let ((begindate (make-zdate))) ;Set begindate to the start of the Epoch ; (gnc:debug "Account: " account) - (set! begindate (decdate begindate NinetyDayDelta)) - (set! begindate (decdate begindate NinetyDayDelta)) - (set! begindate (decdate begindate NinetyDayDelta)) - (set! begindate (decdate begindate NinetyDayDelta)) ;XXX - 360 days!?! (gnc:debug "begindate" begindate) (gnc:debug "date" date) (qof-query-set-book query (gnc-get-current-book)) From 0fc726dc0fa0dc3248e0d53ef7c2400404a567ff Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 03:28:09 +0000 Subject: [PATCH 20/29] Show the balance row for all transactions before the "from" date. Patch by Jeff Green BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16729 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../business-reports/owner-report.scm | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/business/business-reports/owner-report.scm b/src/business/business-reports/owner-report.scm index 3cf6c7c256..78ff52a556 100644 --- a/src/business/business-reports/owner-report.scm +++ b/src/business/business-reports/owner-report.scm @@ -184,6 +184,27 @@ table)) +;; +;; Adds the 'Balance' row to the table if it has not been printed and +;; total is not zero +;; +;; Returns printed? +;; +(define (add-balance-row table txn odd-row? printed? start-date total) + (if (not printed?) + (begin + (set! printed? #t) + (if (not (gnc-numeric-zero-p total)) + (let ((row (list (gnc-print-date start-date) "" "" "Balance" "" + (gnc:make-html-table-cell/markup "number-cell" + (gnc:make-gnc-monetary (xaccTransGetCurrency txn) total)))) + (row-style (if odd-row? "normal-row" "alternate-row"))) + (gnc:html-table-append-row/markup! table row-style row) + (set! odd-row? (not odd-row?)) + (set! row-style (if odd-row? "normal-row" "alternate-row"))) + ))) + printed?) + ;; ;; Make sure the caller checks the type first and only calls us with ;; invoice and payment transactions. we don't verify it here. @@ -240,19 +261,9 @@ (if (gnc:timepair-later start-date date) (begin - - ; Maybe print out the 'balance' row - (if (not printed?) - (begin - (set! printed? #t) - (if (not (gnc-numeric-zero-p total)) - (let ((row (make-row start-date #f "" (_ "Balance") "" total)) - (row-style (if odd-row? "normal-row" "alternate-row"))) - (gnc:html-table-append-row/markup! table row-style - (reverse row)) - (set! odd-row? (not odd-row?)) - (set! row-style (if odd-row? "normal-row" "alternate-row"))) - ))) + + ; Adds 'balance' row if needed + (set! printed? (add-balance-row table txn odd-row? printed? start-date total)) ; Now print out the invoice row (if (not (null? invoice)) @@ -305,7 +316,12 @@ (set! total (gnc-numeric-add-fixed total (cadr result))) (set! odd-row? (caddr result)) )))) - txns)) + txns) + ;Balance row may not have been added if all transactions were before + ;start-date (and no other rows would be added either) so add it now + (if (not (null? txns)) + (add-balance-row table (car txns) odd-row? printed? start-date total) + )) (gnc:html-table-append-row/markup! table From 971bc5b709e8ec291dda44c24ef20cefe668bb6c Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 05:17:37 +0000 Subject: [PATCH 21/29] Allow the user to permanently disable currency quotes (#499496) Patch by Daniel Harding git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16730 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 13 +-- src/engine/Period.c | 2 +- src/engine/gnc-commodity.c | 175 +++++++++++++++++++++++++++-- src/engine/gnc-commodity.h | 45 +++++++- src/gnome-utils/dialog-commodity.c | 4 +- 5 files changed, 218 insertions(+), 21 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index 06672a24c7..74012b77a8 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -871,6 +871,7 @@ xaccCloneAccountCommon(const Account *from, QofBook *book) /* The new book should contain a commodity that matches * the one in the old book. Find it, use it. */ priv->commodity = gnc_commodity_obtain_twin(from_priv->commodity, book); + gnc_commodity_increment_usage_count(priv->commodity); priv->commodity_scu = from_priv->commodity_scu; priv->non_standard_scu = from_priv->non_standard_scu; @@ -1004,6 +1005,7 @@ xaccFreeAccount (Account *acc) priv->reconciled_balance = gnc_numeric_zero(); priv->type = ACCT_TYPE_NONE; + gnc_commodity_decrement_usage_count(priv->commodity); priv->commodity = NULL; priv->balance_dirty = FALSE; @@ -2066,7 +2068,9 @@ xaccAccountSetCommodity (Account * acc, gnc_commodity * com) return; xaccAccountBeginEdit(acc); + gnc_commodity_decrement_usage_count(priv->commodity); priv->commodity = com; + gnc_commodity_increment_usage_count(com); priv->commodity_scu = gnc_commodity_get_fraction(com); priv->non_standard_scu = FALSE; @@ -2085,15 +2089,6 @@ xaccAccountSetCommodity (Account * acc, gnc_commodity * com) priv->balance_dirty = TRUE; mark_account (acc); - if (gnc_commodity_is_iso(com)) { - /* compatability hack - Gnucash 1.8 gets currency quotes when a - non-default currency is assigned to an account. */ - gnc_commodity_begin_edit(com); - gnc_commodity_set_quote_flag(com, TRUE); - gnc_commodity_set_quote_source(com, - gnc_commodity_get_default_quote_source(com)); - gnc_commodity_commit_edit(com); - } xaccAccountCommitEdit(acc); } diff --git a/src/engine/Period.c b/src/engine/Period.c index 558d4604dc..eae54c5e70 100644 --- a/src/engine/Period.c +++ b/src/engine/Period.c @@ -538,7 +538,7 @@ gnc_book_partition_txn (QofBook *dest_book, QofBook *src_book, QofQuery *query) /* Next, copy the commodity tables */ src_tbl = gnc_commodity_table_get_table (src_book); dst_tbl = gnc_commodity_table_get_table (dest_book); - gnc_commodity_table_copy (dst_tbl, src_tbl); + gnc_commodity_table_copy (dst_tbl, src_tbl, dest_book); /* Next, copy all of the accounts */ /* hack alert -- FIXME -- this should really be a merge, not a diff --git a/src/engine/gnc-commodity.c b/src/engine/gnc-commodity.c index dd8e321e25..87ee5efbb6 100644 --- a/src/engine/gnc-commodity.c +++ b/src/engine/gnc-commodity.c @@ -61,6 +61,10 @@ struct gnc_commodity_s gboolean quote_flag; /* user wants price quotes */ gnc_quote_source * quote_source; /* current/old source of quotes */ char * quote_tz; + + /* the number of accounts using this commodity - this field is not + * persisted */ + int usage_count; }; struct _GncCommodityClass @@ -624,6 +628,17 @@ gnc_commodity_destroy(gnc_commodity * cm) cm->mark = 0; +#if !ACCOUNTS_CLEANED_UP + /* Account objects are not actually cleaned up when a book is closed (in fact + * a memory leak), but commodities are, so in currently this warning gets hit + * quite frequently. Disable the check until cleaning up of accounts objects + * on close is implemented. */ + if(cm->usage_count != 0) { + PWARN("Destroying commodity (%p) with non-zero usage_count (%d).", cm, + cm->usage_count); + } +#endif + /* qof_instance_release (&cm->inst); */ g_object_unref(cm); } @@ -638,13 +653,15 @@ gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src) gnc_commodity_set_quote_flag (dest, src->quote_flag); gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src)); gnc_commodity_set_quote_tz (dest, src->quote_tz); + kvp_frame_delete (dest->inst.kvp_data); + dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data); } gnc_commodity * -gnc_commodity_clone(gnc_commodity *src) +gnc_commodity_clone(gnc_commodity *src, QofBook *dest_book) { gnc_commodity * dest = g_object_new(GNC_TYPE_COMMODITY, NULL); - /* qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, src->inst.book); */ + qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book); dest->fullname = CACHE_INSERT(src->fullname); dest->mnemonic = CACHE_INSERT(src->mnemonic); @@ -659,6 +676,9 @@ gnc_commodity_clone(gnc_commodity *src) gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src)); + kvp_frame_delete (dest->inst.kvp_data); + dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data); + reset_printname(dest); reset_unique_name(dest); @@ -774,6 +794,21 @@ gnc_commodity_get_mark(const gnc_commodity * cm) return cm->mark; } +/******************************************************************** + * gnc_commodity_get_auto_quote_control_flag + ********************************************************************/ + +static gboolean +gnc_commodity_get_auto_quote_control_flag(const gnc_commodity *cm) +{ + const char *str; + + if(!cm) return FALSE; + + str = kvp_frame_get_string(cm->inst.kvp_data, "auto_quote_control"); + return !str || (strcmp(str, "false") != 0); +} + /******************************************************************** * gnc_commodity_get_quote_flag ********************************************************************/ @@ -928,6 +963,60 @@ gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark) cm->mark = mark; } +/******************************************************************** + * gnc_commodity_set_auto_quote_control_flag + ********************************************************************/ + +static void +gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm, + const gboolean flag) +{ + ENTER ("(cm=%p, flag=%d)", cm, flag); + + if(!cm) { + LEAVE(""); + return; + } + + gnc_commodity_begin_edit(cm); + kvp_frame_set_string(cm->inst.kvp_data, + "auto_quote_control", flag ? NULL : "false"); + mark_commodity_dirty(cm); + gnc_commodity_commit_edit(cm); + LEAVE(""); +} + +/******************************************************************** + * gnc_commodity_user_set_quote_flag + ********************************************************************/ + +void +gnc_commodity_user_set_quote_flag(gnc_commodity *cm, const gboolean flag) +{ + ENTER ("(cm=%p, flag=%d)", cm, flag); + + if(!cm) { + LEAVE(""); + return; + } + + gnc_commodity_begin_edit(cm); + gnc_commodity_set_quote_flag(cm, flag); + if(gnc_commodity_is_iso(cm)) { + /* For currencies, disable auto quote control if the quote flag is being + * changed from its default value and enable it if the quote flag is being + * reset to its default value. The defaults for the quote flag are + * disabled if no accounts are using the currency, and true otherwise. + * Thus enable auto quote control if flag is FALSE and there are not any + * accounts using this currency OR flag is TRUE and there are accounts + * using this currency; otherwise disable auto quote control */ + gnc_commodity_set_auto_quote_control_flag(cm, + (!flag && (cm->usage_count == 0)) || (flag && (cm->usage_count != 0))); + } + gnc_commodity_commit_edit(cm); + LEAVE(""); +} + /******************************************************************** * gnc_commodity_set_quote_flag ********************************************************************/ @@ -981,6 +1070,70 @@ gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz) LEAVE(" "); } +/******************************************************************** + * gnc_commodity_increment_usage_count + ********************************************************************/ + +void +gnc_commodity_increment_usage_count(gnc_commodity *cm) +{ + const char *str; + + ENTER("(cm=%p)", cm); + + if(!cm) { + LEAVE(""); + return; + } + + if((cm->usage_count == 0) && !cm->quote_flag + && gnc_commodity_get_auto_quote_control_flag(cm) + && gnc_commodity_is_iso(cm)) { + /* compatability hack - Gnucash 1.8 gets currency quotes when a + non-default currency is assigned to an account. */ + gnc_commodity_begin_edit(cm); + gnc_commodity_set_quote_flag(cm, TRUE); + gnc_commodity_set_quote_source(cm, + gnc_commodity_get_default_quote_source(cm)); + gnc_commodity_commit_edit(cm); + } + cm->usage_count++; + LEAVE("(usage_count=%d)", cm->usage_count); +} + +/******************************************************************** + * gnc_commodity_decrement_usage_count + ********************************************************************/ + +void +gnc_commodity_decrement_usage_count(gnc_commodity *cm) +{ + const char *str; + + ENTER("(cm=%p)", cm); + + if(!cm) { + LEAVE(""); + return; + } + + if(cm->usage_count == 0) { + PWARN("usage_count already zero"); + LEAVE(""); + return; + } + + cm->usage_count--; + if((cm->usage_count == 0) && cm->quote_flag + && gnc_commodity_get_auto_quote_control_flag(cm) + && gnc_commodity_is_iso(cm)) { + /* if this is a currency with auto quote control enabled and no more + * accounts reference this currency, disable quote retrieval */ + gnc_commodity_set_quote_flag(cm, FALSE); + } + LEAVE("(usage_count=%d)", cm->usage_count); +} + /********************************************************************\ \********************************************************************/ @@ -1122,7 +1275,7 @@ gnc_commodity_obtain_twin (gnc_commodity *from, QofBook *book) twin = gnc_commodity_table_lookup_unique (comtbl, ucom); if (!twin) { - twin = gnc_commodity_clone (from); + twin = gnc_commodity_clone (from, book); twin = gnc_commodity_table_insert (comtbl, twin); } return twin; @@ -1779,19 +1932,27 @@ gnc_commodity_table_equal(gnc_commodity_table *t_1, /* =========================================================== */ +typedef struct { + gnc_commodity_table *dest; + QofBook *dest_book; +} table_copy_helper_data; + static gboolean table_copy_helper (gnc_commodity *src_cm, gpointer user_data) { - gnc_commodity_table *dest = user_data; - gnc_commodity_table_insert (dest, gnc_commodity_clone (src_cm)); + table_copy_helper_data *data = user_data; + gnc_commodity_table_insert (data->dest, + gnc_commodity_clone (src_cm, data->dest_book)); return TRUE; } void gnc_commodity_table_copy(gnc_commodity_table *dest, - gnc_commodity_table *src) + gnc_commodity_table *src, + QofBook *dest_book) { - gnc_commodity_table_foreach_commodity (src, table_copy_helper, dest); + table_copy_helper_data data = {dest, dest_book}; + gnc_commodity_table_foreach_commodity (src, table_copy_helper, &data); } /******************************************************************** diff --git a/src/engine/gnc-commodity.h b/src/engine/gnc-commodity.h index 5826c9ee2d..954d603454 100644 --- a/src/engine/gnc-commodity.h +++ b/src/engine/gnc-commodity.h @@ -312,7 +312,7 @@ void gnc_commodity_destroy(gnc_commodity * cm); void gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src); /** allocate and copy */ -gnc_commodity * gnc_commodity_clone(gnc_commodity *src); +gnc_commodity * gnc_commodity_clone(gnc_commodity *src, QofBook *dest_book); /** @} */ @@ -547,6 +547,23 @@ void gnc_commodity_set_cusip(gnc_commodity * cm, const char * cusip); */ void gnc_commodity_set_fraction(gnc_commodity * cm, int smallest_fraction); +/** Set the automatic price quote flag for the specified commodity, + * based on user input. This flag indicates whether stock quotes + * should be retrieved for the specified stock. + * + * It is necessary to have a separate function to distinguish when + * this setting is being modified by a user so that the + * auto-enabling/auto-disabling of currencies can be handled + * properly. + * + * @param cm A pointer to a commodity data structure. + * + * @param flag TRUE if quotes should be pulled for this commodity, FALSE + * otherwise. + */ +void gnc_commodity_user_set_quote_flag(gnc_commodity *cm, + const gboolean flag); + /** Set the automatic price quote flag for the specified commodity. * This flag indicates whether stock quotes should be retrieved for * the specified stock. @@ -584,6 +601,29 @@ void gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz); /** @} */ +/** @name Commodity Usage Count Adjustment Routines +@{ +*/ + +/** Increment a commodity's internal counter that tracks how many + * accounts are using that commodity. For currencies, this may have + * the side effect of enabling the commodity's quote flag. + * + * @param cm A pointer to a commodity data structure. + */ +void +gnc_commodity_increment_usage_count(gnc_commodity *cm); + +/** Decrement a commodity's internal counter that tracks how many + * accounts are using that commodity. For currencies, this may have + * the side effect of disabling the commodity's quote flag. + * + * @param cm A pointer to a commodity data structure. + */ +void +gnc_commodity_decrement_usage_count(gnc_commodity *cm); +/** @} */ + /** @name Commodity Comparison @{ @@ -653,7 +693,8 @@ gboolean gnc_commodity_table_equal(gnc_commodity_table *t_1, /** copy all commodities from src table to dest table */ void gnc_commodity_table_copy(gnc_commodity_table *dest, - gnc_commodity_table *src); + gnc_commodity_table *src, + QofBook *dest_book); /** @} */ /* ---------------------------------------------------------- */ /** @name Commodity Table Lookup functions diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c index ce4c4b8cf3..e5fffa94ab 100644 --- a/src/gnome-utils/dialog-commodity.c +++ b/src/gnome-utils/dialog-commodity.c @@ -1194,7 +1194,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) if (w->edit_commodity) { c = w->edit_commodity; gnc_commodity_begin_edit(c); - gnc_commodity_set_quote_flag (c, gtk_toggle_button_get_active + gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->get_quote_check))); selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu)); string = gnc_timezone_menu_position_to_string(selection); @@ -1237,7 +1237,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) gnc_commodity_set_fraction (c, fraction); } - gnc_commodity_set_quote_flag (c, gtk_toggle_button_get_active + gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->get_quote_check))); for (type = SOURCE_SINGLE; type < SOURCE_MAX; type++) { From 03aa05c2a62bb6dddb02f42171d189e56dfb8afc Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 26 Dec 2007 22:07:22 +0000 Subject: [PATCH 22/29] Remove unused import-export/qif files from translation input. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16733 57a11ea4-9604-0410-9ed3-97b8803252fd --- po/POTFILES.skip | 3 +++ 1 file changed, 3 insertions(+) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index d65f52179a..1bc2f86a4d 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -12,3 +12,6 @@ src/backend/file/io-gncbin-r.c src/import-export/binary-import/binary-import.glade src/import-export/binary-import/druid-commodity.c src/import-export/binary-import/gncmod-binary-import.c +# The features in import-export/qif are still unused. +src/import-export/qif/qif-defaults.c +src/import-export/qif/qif-parse.c From 5ac78bce1845b53268dbd705afcf3f0c9324157f Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Thu, 27 Dec 2007 10:44:44 +0000 Subject: [PATCH 23/29] Fix i18n string to translate only the meaningful part. Remove the unnecessary "for" in the report title. This doesn't introduce any new string. It can be back-ported right away. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16740 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/report/standard-reports/cash-flow.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/report/standard-reports/cash-flow.scm b/src/report/standard-reports/cash-flow.scm index 24fea47585..3493c54271 100644 --- a/src/report/standard-reports/cash-flow.scm +++ b/src/report/standard-reports/cash-flow.scm @@ -192,9 +192,11 @@ (gnc:html-document-set-title! - doc (sprintf #f (_ "%s - %s to %s for") - (get-option gnc:pagename-general gnc:optname-reportname) - (gnc-print-date from-date-tp) (gnc-print-date to-date-tp))) + doc (string-append + (get-option gnc:pagename-general gnc:optname-reportname) + " - " + (sprintf #f (_ "%s to %s") + (gnc-print-date from-date-tp) (gnc-print-date to-date-tp)))) ;; add subaccounts if requested From 9ffcb192b971e99052c9da505c338e9b332a4103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Thu, 27 Dec 2007 12:22:09 +0000 Subject: [PATCH 24/29] Correct Ertraege in latin1-encoded german account templates. This stems from r16550 and r16551 and is due to a weird mixture of utf-8 and iso-8859-1 in the de_* files. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16742 57a11ea4-9604-0410-9ed3-97b8803252fd --- accounts/de_AT/acctchrt_brokerage.gnucash-xea | 4 ++-- accounts/de_CH/acctchrt_brokerage.gnucash-xea | 4 ++-- accounts/de_CH/acctchrt_common.gnucash-xea | 8 ++++---- accounts/de_DE/acctchrt_brokerage.gnucash-xea | 4 ++-- accounts/de_DE/acctchrt_common.gnucash-xea | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/accounts/de_AT/acctchrt_brokerage.gnucash-xea b/accounts/de_AT/acctchrt_brokerage.gnucash-xea index 04b56be236..a997bc80c5 100644 --- a/accounts/de_AT/acctchrt_brokerage.gnucash-xea +++ b/accounts/de_AT/acctchrt_brokerage.gnucash-xea @@ -100,14 +100,14 @@ d6b0c9d2b6f67e852f627793cd4a8c45 - Erträge + Erträge 724c2a1128e49b0b28304d372b19f5a1 INCOME ISO4217 USD - Erträge + Erträge placeholder diff --git a/accounts/de_CH/acctchrt_brokerage.gnucash-xea b/accounts/de_CH/acctchrt_brokerage.gnucash-xea index 6dcf4fbc97..c87c41ee32 100644 --- a/accounts/de_CH/acctchrt_brokerage.gnucash-xea +++ b/accounts/de_CH/acctchrt_brokerage.gnucash-xea @@ -82,14 +82,14 @@ d6b0c9d2b6f67e852f627793cd4a8c45 - Erträge + Erträge 724c2a1128e49b0b28304d372b19f5a1 INCOME ISO4217 USD - Erträge + Erträge 1972cce2e2364f95b2b0bc014502661d diff --git a/accounts/de_CH/acctchrt_common.gnucash-xea b/accounts/de_CH/acctchrt_common.gnucash-xea index a1815d164c..48f707aac1 100644 --- a/accounts/de_CH/acctchrt_common.gnucash-xea +++ b/accounts/de_CH/acctchrt_common.gnucash-xea @@ -7,7 +7,7 @@ Grundlegende Kontenstruktur - Die meisten Anwender benötigen diese grundlegende Kontenstruktur. Sie finden hier die allgemein üblichen Konten wie Giro-, Sparkonto, Bargeld, Kreditkarte, Erträge und verschiedene Ausgaben. + Die meisten Anwender benötigen diese grundlegende Kontenstruktur. Sie finden hier die allgemein üblichen Konten wie Giro-, Sparkonto, Bargeld, Kreditkarte, Erträge und verschiedene Ausgaben. 1 @@ -105,14 +105,14 @@ 265c29e7f9adb75346f96a4f7e79654e - Erträge + Erträge 724c2a1128e49b0b28304d372b19f5a1 INCOME ISO4217 USD - Erträge + Erträge 1972cce2e2364f95b2b0bc014502661d @@ -167,7 +167,7 @@ ISO4217 USD - Sonstige Erträge + Sonstige Erträge 724c2a1128e49b0b28304d372b19f5a1 diff --git a/accounts/de_DE/acctchrt_brokerage.gnucash-xea b/accounts/de_DE/acctchrt_brokerage.gnucash-xea index 04b56be236..a997bc80c5 100644 --- a/accounts/de_DE/acctchrt_brokerage.gnucash-xea +++ b/accounts/de_DE/acctchrt_brokerage.gnucash-xea @@ -100,14 +100,14 @@ d6b0c9d2b6f67e852f627793cd4a8c45 - Erträge + Erträge 724c2a1128e49b0b28304d372b19f5a1 INCOME ISO4217 USD - Erträge + Erträge placeholder diff --git a/accounts/de_DE/acctchrt_common.gnucash-xea b/accounts/de_DE/acctchrt_common.gnucash-xea index 2d15c11805..a56d68ca5a 100644 --- a/accounts/de_DE/acctchrt_common.gnucash-xea +++ b/accounts/de_DE/acctchrt_common.gnucash-xea @@ -7,7 +7,7 @@ Grundlegende Kontenstruktur - Die meisten Anwender benötigen diese grundlegende Kontenstruktur. Sie finden hier die allgemein üblichen Konten wie Giro-, Sparkonto, Bargeld, Kreditkarte, Erträge und verschiedene Ausgaben. Wenn Sie aber einen SKR verwenden wollen, brauchen Sie sie nicht. + Die meisten Anwender benötigen diese grundlegende Kontenstruktur. Sie finden hier die allgemein üblichen Konten wie Giro-, Sparkonto, Bargeld, Kreditkarte, Erträge und verschiedene Ausgaben. Wenn Sie aber einen SKR verwenden wollen, brauchen Sie sie nicht. 1 @@ -129,14 +129,14 @@ 265c29e7f9adb75346f96a4f7e79654e - Erträge + Erträge 724c2a1128e49b0b28304d372b19f5a1 INCOME ISO4217 EUR - Erträge + Erträge placeholder @@ -203,7 +203,7 @@ ISO4217 EUR - Sonstige Erträge + Sonstige Erträge 724c2a1128e49b0b28304d372b19f5a1 From e6fbb91151ca46a337e65f75e6754e1093f2ee5f Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Thu, 27 Dec 2007 14:02:06 +0000 Subject: [PATCH 25/29] Fix the logic of the #if for the warning. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16745 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-commodity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gnc-commodity.c b/src/engine/gnc-commodity.c index 87ee5efbb6..0cc5537313 100644 --- a/src/engine/gnc-commodity.c +++ b/src/engine/gnc-commodity.c @@ -628,7 +628,7 @@ gnc_commodity_destroy(gnc_commodity * cm) cm->mark = 0; -#if !ACCOUNTS_CLEANED_UP +#ifdef ACCOUNTS_CLEANED_UP /* Account objects are not actually cleaned up when a book is closed (in fact * a memory leak), but commodities are, so in currently this warning gets hit * quite frequently. Disable the check until cleaning up of accounts objects From cfb048d1428b27d55abcbd1b8ba0330a81db6829 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Thu, 27 Dec 2007 14:15:15 +0000 Subject: [PATCH 26/29] Don't need to sleep in the test. (#505894) If we do need to sleep, next time the comment should explain why. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16746 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/test/test-book-merge.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/test/test-book-merge.c b/src/engine/test/test-book-merge.c index 74637d7d57..c5c2ddb594 100644 --- a/src/engine/test/test-book-merge.c +++ b/src/engine/test/test-book-merge.c @@ -24,7 +24,6 @@ #include "config.h" #include -#include #include "qof.h" #include "test-stuff.h" @@ -505,7 +504,6 @@ test_rule_loop (QofBookMergeData *mergeData, QofBookMergeRule *rule, guint remai int main (int argc, char **argv) { - sleep(10); qof_init(); myobjRegister(); test_merge(); From 6c914bdf7b9e906523ab9f55ae5d697323a6b4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Thu, 27 Dec 2007 15:12:12 +0000 Subject: [PATCH 27/29] Bump version number to 2.2.99 on trunk. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16747 57a11ea4-9604-0410-9ed3-97b8803252fd --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index f824ea23e0..ae63790fa4 100644 --- a/configure.in +++ b/configure.in @@ -20,7 +20,7 @@ dnl Process this file with autoconf to produce a configure script. # Autoconf initialization AC_PREREQ(2.59) -AC_INIT([gnucash], [2.2.1], [gnucash-devel@gnucash.org]) +AC_INIT([gnucash], [2.2.99], [gnucash-devel@gnucash.org]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_SRCDIR(src/engine/Transaction.h) From 66fd54555dcc801f8b38c022de515ca03970911a Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Fri, 28 Dec 2007 01:30:20 +0000 Subject: [PATCH 28/29] Create gobject-engine-dev2 branch from trunk r16747 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev2@16753 57a11ea4-9604-0410-9ed3-97b8803252fd From cc97c8484e7a84d5bf178301569e35d0034fa161 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sun, 20 Jul 2008 19:12:44 +0000 Subject: [PATCH 29/29] Convert GncBudget to be a GObject with parameters and private section. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev2@17352 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-budget.c | 238 ++++++++++++++++++++++++++++++++++------ src/engine/gnc-budget.h | 2 +- 2 files changed, 205 insertions(+), 35 deletions(-) diff --git a/src/engine/gnc-budget.c b/src/engine/gnc-budget.c index 9684fbad22..e9250a3002 100644 --- a/src/engine/gnc-budget.c +++ b/src/engine/gnc-budget.c @@ -39,14 +39,39 @@ static QofLogModule log_module = GNC_MOD_ENGINE; -struct gnc_budget_private{ - QofInstance inst; +enum { + PROP_0, + PROP_NAME, + PROP_DESCRIPTION, + PROP_NUM_PERIODS, + PROP_RECURRENCE, +}; + +struct budget_s +{ + QofInstance inst; +}; + +typedef struct { + QofInstanceClass parent_class; +} BudgetClass; +typedef struct BudgetPrivate { + /* The name is an arbitrary string assigned by the user. */ gchar* name; + + /* The description is an arbitrary string assigned by the user. */ gchar* description; + + /* Recurrence (period info) for the budget */ Recurrence recurrence; + + /* Number of periods */ guint num_periods; -}; +} BudgetPrivate; + +#define GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_BUDGET, BudgetPrivate)) struct _GncBudgetClass { @@ -54,21 +79,154 @@ struct _GncBudgetClass }; /* GObject Initialization */ -QOF_GOBJECT_IMPL(gnc_budget, GncBudget, QOF_TYPE_INSTANCE); +G_DEFINE_TYPE(GncBudget, gnc_budget, QOF_TYPE_INSTANCE) static void gnc_budget_init(GncBudget* budget) { + BudgetPrivate* priv; + GDate date; + + priv = GET_PRIVATE(budget); + priv->name = CACHE_INSERT(_("Unnamed Budget")); + priv->description = CACHE_INSERT(""); + + priv->num_periods = 12; + g_date_set_time_t(&date, time(NULL)); + g_date_subtract_days(&date, g_date_get_day(&date)-1); + recurrenceSet(&priv->recurrence, 1, PERIOD_MONTH, &date); } static void -gnc_budget_dispose_real (GObject *budgetp) +gnc_budget_dispose (GObject *budgetp) { + G_OBJECT_CLASS(gnc_budget_parent_class)->dispose(budgetp); } static void -gnc_budget_finalize_real(GObject* budgetp) +gnc_budget_finalize(GObject* budgetp) { + G_OBJECT_CLASS(gnc_budget_parent_class)->finalize(budgetp); +} + +static void +gnc_budget_get_property( GObject* object, + guint prop_id, + GValue* value, + GParamSpec* pspec) +{ + GncBudget* budget; + BudgetPrivate* priv; + + g_return_if_fail(GNC_IS_BUDGET(object)); + + budget = GNC_BUDGET(object); + priv = GET_PRIVATE(budget); + switch( prop_id ) { + case PROP_NAME: + g_value_set_string(value, priv->name); + break; + case PROP_DESCRIPTION: + g_value_set_string(value, priv->description); + break; + case PROP_NUM_PERIODS: + g_value_set_uint(value, priv->num_periods); + break; + case PROP_RECURRENCE: + /* TODO: Make this a BOXED type */ + g_value_set_pointer(value, &priv->recurrence); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +gnc_budget_set_property( GObject* object, + guint prop_id, + const GValue* value, + GParamSpec* pspec) +{ + GncBudget* budget; + + g_return_if_fail(GNC_IS_BUDGET(object)); + + budget = GNC_BUDGET(object); + switch( prop_id ) { + case PROP_NAME: + gnc_budget_set_name(budget, g_value_get_string(value)); + break; + case PROP_DESCRIPTION: + gnc_budget_set_description(budget, g_value_get_string(value)); + break; + case PROP_NUM_PERIODS: + gnc_budget_set_num_periods(budget, g_value_get_uint(value)); + break; + case PROP_RECURRENCE: + gnc_budget_set_recurrence(budget, g_value_get_pointer(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +gnc_budget_class_init(GncBudgetClass* klass) +{ + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = gnc_budget_dispose; + gobject_class->finalize = gnc_budget_finalize; + gobject_class->get_property = gnc_budget_get_property; + gobject_class->set_property = gnc_budget_set_property; + + g_type_class_add_private(klass, sizeof(BudgetPrivate)); + + g_object_class_install_property( + gobject_class, + PROP_NAME, + g_param_spec_string( "name", + "Budget Name", + "The name is an arbitrary string " + "assigned by the user. It is intended " + "to be a short, 5 to 30 character long string " + "that is displayed by the GUI as the " + "budget mnemonic", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property( + gobject_class, + PROP_DESCRIPTION, + g_param_spec_string( "description", + "Budget Description", + "The description is an arbitrary string " + "assigned by the user. It is intended " + "to be a longer, 1-5 sentence description of " + "what the budget is all about.", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property( + gobject_class, + PROP_NUM_PERIODS, + g_param_spec_uint( "num-periods", + "Number of Periods", + "The number of periods for this budget.", + 0, + G_MAXUINT32, + 12, + G_PARAM_READWRITE)); + + g_object_class_install_property( + gobject_class, + PROP_RECURRENCE, + g_param_spec_pointer( "recurrence", + "Budget Recurrence", + "about.", + G_PARAM_READWRITE)); } static void commit_err (QofInstance *inst, QofBackendError errcode) @@ -79,19 +237,23 @@ static void commit_err (QofInstance *inst, QofBackendError errcode) static void gnc_budget_free(QofInstance *inst) { - GncBudget *budget = GNC_BUDGET(inst); + GncBudget *budget; + BudgetPrivate* priv; + if (budget == NULL) return; - g_return_if_fail(GNC_IS_BUDGET(budget)); + budget = GNC_BUDGET(inst); + priv = GET_PRIVATE(budget); + /* We first send the message that this object is about to be * destroyed so that any GUI elements can remove it before it is * actually gone. */ qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, NULL); - CACHE_REMOVE(budget->name); - CACHE_REMOVE(budget->description); + CACHE_REMOVE(priv->name); + CACHE_REMOVE(priv->description); /* qof_instance_release (&budget->inst); */ g_object_unref(budget); @@ -117,23 +279,13 @@ GncBudget* gnc_budget_new(QofBook *book) { GncBudget* budget; - GDate date; + g_return_val_if_fail(book, NULL); ENTER(" "); budget = g_object_new(GNC_TYPE_BUDGET, NULL); qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book); - g_date_set_time_t(&date, time(NULL)); - g_date_subtract_days(&date, g_date_get_day(&date)-1); - recurrenceSet(&budget->recurrence, 1, PERIOD_MONTH, &date); - - gnc_budget_begin_edit(budget); - gnc_budget_set_name(budget, _("Unnamed Budget")); - gnc_budget_set_description(budget, ""); - gnc_budget_set_num_periods(budget, 12); - gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL); LEAVE(" "); @@ -153,10 +305,15 @@ gnc_budget_destroy(GncBudget *budget) void gnc_budget_set_name(GncBudget* budget, const gchar* name) { + BudgetPrivate* priv; + g_return_if_fail(GNC_IS_BUDGET(budget) && name); + priv = GET_PRIVATE(budget); + if( name == priv->name ) return; + gnc_budget_begin_edit(budget); - CACHE_REPLACE(budget->name, name); + CACHE_REPLACE(priv->name, name); qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); @@ -167,17 +324,21 @@ const gchar* gnc_budget_get_name(GncBudget* budget) { g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); - return budget->name; + return GET_PRIVATE(budget)->name; } void gnc_budget_set_description(GncBudget* budget, const gchar* description) { + BudgetPrivate* priv; + g_return_if_fail(GNC_IS_BUDGET(budget)); g_return_if_fail(description); + priv = GET_PRIVATE(budget); + if( description == priv->description ) return; gnc_budget_begin_edit(budget); - CACHE_REPLACE(budget->description, description); + CACHE_REPLACE(priv->description, description); qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); @@ -188,15 +349,19 @@ const gchar* gnc_budget_get_description(GncBudget* budget) { g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); - return budget->description; + return GET_PRIVATE(budget)->description; } void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r) { + BudgetPrivate* priv; + g_return_if_fail(budget && r); + priv = GET_PRIVATE(budget); + gnc_budget_begin_edit(budget); - budget->recurrence = *r; + priv->recurrence = *r; qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); @@ -207,7 +372,7 @@ const Recurrence * gnc_budget_get_recurrence(GncBudget *budget) { g_return_val_if_fail(budget, NULL); - return (&budget->recurrence); + return (&GET_PRIVATE(budget)->recurrence); } const GUID* @@ -221,10 +386,15 @@ gnc_budget_get_guid(GncBudget* budget) void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods) { + BudgetPrivate* priv; + g_return_if_fail(GNC_IS_BUDGET(budget)); + priv = GET_PRIVATE(budget); + if( priv->num_periods == num_periods ) return; + gnc_budget_begin_edit(budget); - budget->num_periods = num_periods; + priv->num_periods = num_periods; qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); @@ -235,7 +405,7 @@ guint gnc_budget_get_num_periods(GncBudget* budget) { g_return_val_if_fail(GNC_IS_BUDGET(budget), 0); - return budget->num_periods; + return GET_PRIVATE(budget)->num_periods; } #define BUF_SIZE (10 + GUID_ENCODING_LENGTH + \ @@ -370,7 +540,7 @@ gnc_budget_get_period_start_date(GncBudget *budget, guint period_num) { Timespec ts; timespecFromTime_t( - &ts, recurrenceGetPeriodTime(&budget->recurrence, period_num, FALSE)); + &ts, recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, FALSE)); return ts; } @@ -380,7 +550,7 @@ gnc_budget_get_account_period_actual_value( { // FIXME: maybe zero is not best error return val. g_return_val_if_fail(GNC_IS_BUDGET(budget) && acc, gnc_numeric_zero()); - return recurrenceGetAccountPeriodValue(&budget->recurrence, + return recurrenceGetAccountPeriodValue(&GET_PRIVATE(budget)->recurrence, acc, period_num); } @@ -441,11 +611,11 @@ static QofObject budget_object_def = /* Static wrapper getters for the recurrence params */ static PeriodType gnc_budget_get_rec_pt(const GncBudget *bgt) -{ return recurrenceGetPeriodType(&(bgt->recurrence)); } +{ return recurrenceGetPeriodType(&(GET_PRIVATE(bgt)->recurrence)); } static guint gnc_budget_get_rec_mult(const GncBudget *bgt) -{ return recurrenceGetMultiplier(&(bgt->recurrence)); } +{ return recurrenceGetMultiplier(&(GET_PRIVATE(bgt)->recurrence)); } static GDate gnc_budget_get_rec_date(const GncBudget *bgt) -{ return recurrenceGetDate(&(bgt->recurrence)); } +{ return recurrenceGetDate(&(GET_PRIVATE(bgt)->recurrence)); } /* Register ourselves with the engine. */ gboolean gnc_budget_register (void) diff --git a/src/engine/gnc-budget.h b/src/engine/gnc-budget.h index c9292ff32c..6ce362bfff 100644 --- a/src/engine/gnc-budget.h +++ b/src/engine/gnc-budget.h @@ -67,7 +67,7 @@ #include /** The budget data.*/ -typedef struct gnc_budget_private GncBudget; +typedef struct budget_s GncBudget; typedef struct _GncBudgetClass GncBudgetClass; #include "qof.h"