gnucash/libgnucash/app-utils/gnc-ui-util.h

361 lines
15 KiB
C
Raw Normal View History

/********************************************************************\
* gnc-ui-util.h -- utility functions for the GnuCash UI *
* Copyright (C) 2000 Dave Peticolas <dave@krondo.com> *
* *
* 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 *
\********************************************************************/
/** @addtogroup GUI
@{ */
/** @addtogroup GuiUtility Utility functions for the GnuCash GUI
* @{ */
/** @file gnc-ui-util.h
@brief utility functions for the GnuCash UI
@author Copyright (C) 2000 Dave Peticolas <dave@krondo.com>
*/
#ifndef GNC_UI_UTIL_H
#define GNC_UI_UTIL_H
#include <glib.h>
#include <locale.h>
#include "Account.h"
#include "gncOwner.h"
#include "qof.h"
typedef QofSession * (*QofSessionCB) (void);
gchar *gnc_normalize_account_separator (const gchar* separator);
gboolean gnc_reverse_balance(const Account *account);
/* Default directory sections ***************************************/
#define GNC_PREFS_GROUP_OPEN_SAVE "dialogs.open-save"
#define GNC_PREFS_GROUP_EXPORT "dialogs.export-accounts"
#define GNC_PREFS_GROUP_REPORT "dialogs.report"
#define GNC_PREF_AUTO_DECIMAL_POINT "auto-decimal-point"
#define GNC_PREF_AUTO_DECIMAL_PLACES "auto-decimal-places"
/* Default directories **********************************************/
gchar *gnc_get_default_directory (const gchar *section);
void gnc_set_default_directory (const gchar *section,
const gchar *directory);
/* Engine enhancements & i18n ***************************************/
QofBook * gnc_get_current_book (void);
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations. The changes made are: 1. Implement the new book option to select source for 'num' cell: libqof/qof/qofbookslots.h - define num source option engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and 'SPLIT-ACTION' as a term for sorting queries app-utils/business-prefs.scm - define book option for num-field-source app-utils/app-utils.scm - define and export book option for num-field-source 2. Implement functions to get book option setting and to test: libqof/qof/qofbook.c & .h - define function to get number source book option libqof/qof/test/test-qofbook.c - test function to get number source book option 3. Implement a notification mechanism for book option changes: engine/engine-helpers.c & .h - define functions to register callbacks, define function to remove callbacks and define function to initiate callbacks on book num-source option changes core-utils/gnc-features.c & .h - define feature for num-source app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb; include setting of feature flag on initial use gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb function to gnc_book_options_dialog_apply_cb and adjust function to call function gnc_book_option_num_field_source_change_cb when book option for num-field-source changes; change name of gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb 4. Implement 'help' button response on Book Option Dialog: gnome-utils/gnc-ui.h - define "book-options" section of help manual gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb to make help button active 5. Implement utility functions to get/set number/action based on book option: engine/engine-helpers.c & .h - define 'gnc_get_num_action' function define 'gnc_get_action_num' function define 'gnc_set_num_action' function engine/engine.i - make get/set num/action functions available to guile & allow #f to be used in place of NULL from guile engine/Transaction.h - add reference to utility functions in comments to xaccTransSetNum and xaccTransGetNum functions engine/Split.h - add reference to utility functions in comments to xaccSplitSetAction and xaccSplitGetAction functions 6. Implement register use of num source book option; for General, Income and Search Ledgers, since there is no anchor split, always show tran-num in transaction cursor, but vary label to correspond to book option: register/ledger-core/split-register.h - define TNUM_CELL define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL add boolean to split_reg structure to hold num source book option register/ledger-core/split-register-layout.c - add logic to define and set up new ledger/journal cursors with TNUM_CELLs add logic to add the new cursors to a layout add logic to add TNUM_CELL to a layout register/ledger-core/split-register-model.c - define function to get TNUM_CELL label add logic to recognize ledger/journal cursors with TNUM_CELL modify function to get NUM_CELL value based on book option and register type define function to get TNUM_CELL value adjust num help text to reflect book option choice define function to get TNUM_CELL help modify function to get action help to reflect book option choice set up handlers for TNUM_CELL register/ledger-core/split-register-model-save.c - use 'gnc_set_num_action' function to set num/action for NUM_CELL based on book option define function to save TNUM_CELL using 'gnc_set_num_action' function set save handler for TNUM_CELL register/ledger-core/split-register-util.c - modify logic to recognize ledger/journal cursors with tnum_cell register/ledger-core/split-register.c - define split_register_book_option_changed function register split_register_book_option_changed function in register init initialize register structure setting to book option remove split_register_book_option_changed function in register destroy modify gnc_split_register_save_to_scm to handle TNUM_CELL 7. Enhance transaction copy/duplicate logic to accommodate new book option: gnome/gtkbuilder/gnc-plugin-page-register.glade - add widgets to handle trans number and/or split action based on book option gnome-utils/dialog-dup-trans.c & .h - add capability to display and handle 'Num' field according to book option gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account register/ledger-core/split-register.c - modify gnc_split_register_duplicate_current to accomodate book option setting register/ledger-core/Makefile.am - add GNOME_CFLAGS register/ledger-core/test/Makefile.am - add libgnc-gnome.la 8. Adjust register sort and sort labels related to Num/Action radio buttons to correspond to book option for clarity: gnome/gnc-plugin-page-register.c - define gnc_plugin_page_register_sort_book_option_changed to adjust labels register function in gnc_plugin_page_register_cmd_view_sort_by and save num and action radio widgets initialize radio widget labels to correspond to book option remove function in gnc_plugin_page_register_sort_response_cb and clear num and action radio widgets gnome/gnc-split-reg.c & h. - create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force a re-sort to be used when num-source book option changes engine/Transaction.c & .h - modify default sort to use split action in place of tran num per book option if called from xaccSplitOrder engine/Split.c - modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of split action and tran num per book option engine/test/utest-Split.c - modify test_xaccSplitOrder to call xaccTransOrder_num_action based on book option 9. Adjust transaction find labels related to Num/Action to correspond to book option for clarity: gnome/dialog-find-transactions.c - adjust labels in search criteria based on book option gnome-search/dialog-search.c - define gnc_search_dialog_book_option_changed to adjust labels register function in gnc_search_dialog_init_widgets when searching for splits remove function in gnc_search_dialog_close_cb if registered 10. Modify new file process to allow setting of num-source (actually, all) book option(s) during New Account Hierarchy Setup: gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for the default setting for 'num-source' for new books core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE gnome-utils/gnc-gnome-utils.c & h. - define gnc_options_dialog_set_new_book_option_values to retrieve preference values gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to surpress apply button gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb with arguments so that the window can be called in modal mode and the title changed and return dialog widget; call gnc_options_dialog_new_modal instead of gnc_options_dialog_new; call this function from gnc_main_window_cmd_file_properties with new arguments; for modal mode, call gnc-options-dialog-set-new-book-option-values to initialize values from preferences app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for determining when a new book is being created gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to display book options dialog in modal mode gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book options to currency page gnome/assistant-hierarchy.c - add ability to set book option initialized from preferences value for new books by using functions gnc_is_new_book and gnc_new_book_option_display 11. Modify Import QIF process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/qif-import/assistant-qif-import.glade - add notification about book options to currency page import-export/qif-import/assistant-qif-import.c - using function gnc_is_new_book to identify 'new book' situation and set flag; add logic to handle 'new-book' situation by calling gnc_new_book_option_display function import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function to import number to correct field based on book option 12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import number based on book option; identify 'new book' situation using function gnc_is_new_book and set flag; add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function import-export/import-backend.c - use 'gnc_get_num_action' function to retrieve number from transactions to be matched based on book option 13. Modify Import AqBanking process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number: import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book' situation using function gnc_is_new_book and handle by raising book options dialog by calling gnc_new_book_option_display function import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function to set number based on book option 14. Modify Import Transactions from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/csv-import/assistant-csv-trans-import.glade - modify commments to alert user of raising book options dialog in cases of csv import into a new book import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action' function to import number based on book option import-export/csv-import/assistant-csv-trans-import.c - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 15. Modify Import Accounts from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book import-export/csv-import/assistant-csv-account-import.c & .h - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 16. Modify Export Transactions to CSV process to follow book option setting for num source in exporting transactions: import-export/csv-export/csv-transactions-export.c - modify headings to reflect num-source book option and use 'gnc_get_num_action' function to retrieve number and action 17. Modify register reporting to reflect book option setting for num source: gnome/gnc-plugin-page-register.c - determine and pass along ledger-type? argument to gnc:register-report-create function gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type? argument to gnc:register-report-create function report/standard-reports/standard-reports.scm - add ledger-type? argument to gnc:register-report-create function; pass it along to gnc:register-report-create-internal function report/standard-reports/register.scm - add ledger-type? argument to gnc:register-report-create-internal function; use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly 18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use 'gnc_set_num_action' function to set number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c: engine/gncOwner.c - use 'gnc_set_num_action' function to set number based on book option engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based on book option engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and action engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set number based on book option gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function to set number/action based on book option gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set split-action 19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use 'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & h., engine/test/utest-Split.c, engine/engine-helpers.c, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/test/test-xml-transaction.c: gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve number based on book option gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to retrieve number and action gnome/dialog-print-check.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action register/ledger-core/split-register-model.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-load.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-control.c - use 'gnc_get_num_action' function to retrieve action register/ledger-core/split-register.c - use 'gnc_get_num_action' function to retrieve transaction-num engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function to retrieve transaction-number but may not be getting what is expected if book option to use split-action for 'num' is set report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly report/standard-reports/transaction.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum, adjust sorting based on book option and modify report headings and option text accordingly; add 'SPLIT-ACTION' as a term for sorting queries report/business-reports/customer-summary.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/owner-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/job-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum business/business-gnome/dialog-payment.c - use 'gnc_get_num_action' function to retrieve number based on book option git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
/* If there is no current session, there is no book and we must be dealing
* with a new book. When gnucash is started with --nofile, there is
* initially no session (and no book), but by the time we check, one
* could have been created (for example, if an empty account tree tab is
* opened, a session is created which creates a new, but empty, book).
* A session is created and a book is loaded from a backend when gnucash is
* started with a file, but selecting 'new file' keeps a session open. So we
* need to check as well for a book with no accounts (root with no children). */
gboolean gnc_is_new_book (void);
void gnc_set_current_book_tax_name_type (gboolean name_changed,
const gchar *tax_name,
gboolean type_changed,
const gchar *tax_type);
Bug #554394: Income Tax Enhancements Patch by J. Alex Aycinena. Patch does the following: - update the tax information in 'txf.scm', which is based on V037 of the TXF Spec, to V041, the last version issued (bug #554394) - provide support for multiple copies of certain tax Forms/Schedules (e.g., Schedule C(1), Schedule C(2), etc.) - support multiple types of tax entities: partnerships, corporations and S corporations, in addition to individual tax payers - support balance sheet accounts, required for these new tax entity types - add the term 'Income' in several places to avoid confusion with sales or VAT style taxes in the business features (e.g., change the menu from 'Tax Options' to 'Income Tax Options') The following files were changed, as follows, to implement these changes: 1. src/engine/Account.c and 2. src/engine/Account.h: add copy number capability (define 'xaccAccountGetTaxUSCopyNumber' and 'xaccAccountSetTaxUSCopyNumber'); modify 'xaccAccountSetTaxUSCode' to remove KVP when no tax-code assigned, clean up tax-source descriptions 3. src/gnome/gnc-plugin-basic-commands.c: change 'Tax Options' to 'Income Tax Options' 4. src/app-utils/gnc-ui-util.c and 5. src/app-utils/gnc-ui-util.h: add setter and getter functions for book tax name and book tax type which are stored in a book KVP, show copy information in accounts page, tax column, show error messages for various conditions 6. src/app-utils/app-utils.i: add 'gnc_get_current_book_tax_name' and 'gnc_get_current_book_tax_type' functions 7. src/gnome/dialog-tax-info.c: add copy number and tax entity name and type, and balance sheet account handling capability 8. src/gnome/glade/tax.glade: add tax entity name, tax entity type, asset, liability/equity and copy number widgets 9. src/tax/us/txf.scm: update to V041 for individuals, add V041 support for multiple additional tax entity types and balance sheet accounts and related tax codes, add tax form line data 10. src/tax/us/us.scm: export new functions defined in txf.scm 11. src/report/locale-specific/us/taxtxf.scm: add support for multiple copies of Forms/Schedules, add support for Format 6, use Form/Schedule line #'s to sort report, update from "V037" to "V041", add support for taxpayer types other than F1040, add warning messages if there are some inconsistent codes assigned and list 12. src/tax/us/txf-de_DE.scm: make functions called from outside (e.g., from dialog-tax-info.c) have a consistent signature with those same functions in txf.scm (define tax-entity-type , define getters/setters, add tax-entity-type as an argument to existing functions) 13. src/tax/us/de_DE.scm: export new functions added to txf-de_DE.scm 14. src/report/locale-specific/us/taxtxf-de_DE.scm: add "" as tax-entity-type argument to functions called on txf-de_DE.scm (which defaults to existing codes) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18413 57a11ea4-9604-0410-9ed3-97b8803252fd
2009-11-15 14:35:50 -06:00
const gchar * gnc_get_current_book_tax_name (void);
const gchar * gnc_get_current_book_tax_type (void);
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations. The changes made are: 1. Implement the new book option to select source for 'num' cell: libqof/qof/qofbookslots.h - define num source option engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and 'SPLIT-ACTION' as a term for sorting queries app-utils/business-prefs.scm - define book option for num-field-source app-utils/app-utils.scm - define and export book option for num-field-source 2. Implement functions to get book option setting and to test: libqof/qof/qofbook.c & .h - define function to get number source book option libqof/qof/test/test-qofbook.c - test function to get number source book option 3. Implement a notification mechanism for book option changes: engine/engine-helpers.c & .h - define functions to register callbacks, define function to remove callbacks and define function to initiate callbacks on book num-source option changes core-utils/gnc-features.c & .h - define feature for num-source app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb; include setting of feature flag on initial use gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb function to gnc_book_options_dialog_apply_cb and adjust function to call function gnc_book_option_num_field_source_change_cb when book option for num-field-source changes; change name of gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb 4. Implement 'help' button response on Book Option Dialog: gnome-utils/gnc-ui.h - define "book-options" section of help manual gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb to make help button active 5. Implement utility functions to get/set number/action based on book option: engine/engine-helpers.c & .h - define 'gnc_get_num_action' function define 'gnc_get_action_num' function define 'gnc_set_num_action' function engine/engine.i - make get/set num/action functions available to guile & allow #f to be used in place of NULL from guile engine/Transaction.h - add reference to utility functions in comments to xaccTransSetNum and xaccTransGetNum functions engine/Split.h - add reference to utility functions in comments to xaccSplitSetAction and xaccSplitGetAction functions 6. Implement register use of num source book option; for General, Income and Search Ledgers, since there is no anchor split, always show tran-num in transaction cursor, but vary label to correspond to book option: register/ledger-core/split-register.h - define TNUM_CELL define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL add boolean to split_reg structure to hold num source book option register/ledger-core/split-register-layout.c - add logic to define and set up new ledger/journal cursors with TNUM_CELLs add logic to add the new cursors to a layout add logic to add TNUM_CELL to a layout register/ledger-core/split-register-model.c - define function to get TNUM_CELL label add logic to recognize ledger/journal cursors with TNUM_CELL modify function to get NUM_CELL value based on book option and register type define function to get TNUM_CELL value adjust num help text to reflect book option choice define function to get TNUM_CELL help modify function to get action help to reflect book option choice set up handlers for TNUM_CELL register/ledger-core/split-register-model-save.c - use 'gnc_set_num_action' function to set num/action for NUM_CELL based on book option define function to save TNUM_CELL using 'gnc_set_num_action' function set save handler for TNUM_CELL register/ledger-core/split-register-util.c - modify logic to recognize ledger/journal cursors with tnum_cell register/ledger-core/split-register.c - define split_register_book_option_changed function register split_register_book_option_changed function in register init initialize register structure setting to book option remove split_register_book_option_changed function in register destroy modify gnc_split_register_save_to_scm to handle TNUM_CELL 7. Enhance transaction copy/duplicate logic to accommodate new book option: gnome/gtkbuilder/gnc-plugin-page-register.glade - add widgets to handle trans number and/or split action based on book option gnome-utils/dialog-dup-trans.c & .h - add capability to display and handle 'Num' field according to book option gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account register/ledger-core/split-register.c - modify gnc_split_register_duplicate_current to accomodate book option setting register/ledger-core/Makefile.am - add GNOME_CFLAGS register/ledger-core/test/Makefile.am - add libgnc-gnome.la 8. Adjust register sort and sort labels related to Num/Action radio buttons to correspond to book option for clarity: gnome/gnc-plugin-page-register.c - define gnc_plugin_page_register_sort_book_option_changed to adjust labels register function in gnc_plugin_page_register_cmd_view_sort_by and save num and action radio widgets initialize radio widget labels to correspond to book option remove function in gnc_plugin_page_register_sort_response_cb and clear num and action radio widgets gnome/gnc-split-reg.c & h. - create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force a re-sort to be used when num-source book option changes engine/Transaction.c & .h - modify default sort to use split action in place of tran num per book option if called from xaccSplitOrder engine/Split.c - modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of split action and tran num per book option engine/test/utest-Split.c - modify test_xaccSplitOrder to call xaccTransOrder_num_action based on book option 9. Adjust transaction find labels related to Num/Action to correspond to book option for clarity: gnome/dialog-find-transactions.c - adjust labels in search criteria based on book option gnome-search/dialog-search.c - define gnc_search_dialog_book_option_changed to adjust labels register function in gnc_search_dialog_init_widgets when searching for splits remove function in gnc_search_dialog_close_cb if registered 10. Modify new file process to allow setting of num-source (actually, all) book option(s) during New Account Hierarchy Setup: gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for the default setting for 'num-source' for new books core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE gnome-utils/gnc-gnome-utils.c & h. - define gnc_options_dialog_set_new_book_option_values to retrieve preference values gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to surpress apply button gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb with arguments so that the window can be called in modal mode and the title changed and return dialog widget; call gnc_options_dialog_new_modal instead of gnc_options_dialog_new; call this function from gnc_main_window_cmd_file_properties with new arguments; for modal mode, call gnc-options-dialog-set-new-book-option-values to initialize values from preferences app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for determining when a new book is being created gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to display book options dialog in modal mode gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book options to currency page gnome/assistant-hierarchy.c - add ability to set book option initialized from preferences value for new books by using functions gnc_is_new_book and gnc_new_book_option_display 11. Modify Import QIF process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/qif-import/assistant-qif-import.glade - add notification about book options to currency page import-export/qif-import/assistant-qif-import.c - using function gnc_is_new_book to identify 'new book' situation and set flag; add logic to handle 'new-book' situation by calling gnc_new_book_option_display function import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function to import number to correct field based on book option 12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import number based on book option; identify 'new book' situation using function gnc_is_new_book and set flag; add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function import-export/import-backend.c - use 'gnc_get_num_action' function to retrieve number from transactions to be matched based on book option 13. Modify Import AqBanking process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number: import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book' situation using function gnc_is_new_book and handle by raising book options dialog by calling gnc_new_book_option_display function import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function to set number based on book option 14. Modify Import Transactions from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/csv-import/assistant-csv-trans-import.glade - modify commments to alert user of raising book options dialog in cases of csv import into a new book import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action' function to import number based on book option import-export/csv-import/assistant-csv-trans-import.c - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 15. Modify Import Accounts from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book import-export/csv-import/assistant-csv-account-import.c & .h - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 16. Modify Export Transactions to CSV process to follow book option setting for num source in exporting transactions: import-export/csv-export/csv-transactions-export.c - modify headings to reflect num-source book option and use 'gnc_get_num_action' function to retrieve number and action 17. Modify register reporting to reflect book option setting for num source: gnome/gnc-plugin-page-register.c - determine and pass along ledger-type? argument to gnc:register-report-create function gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type? argument to gnc:register-report-create function report/standard-reports/standard-reports.scm - add ledger-type? argument to gnc:register-report-create function; pass it along to gnc:register-report-create-internal function report/standard-reports/register.scm - add ledger-type? argument to gnc:register-report-create-internal function; use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly 18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use 'gnc_set_num_action' function to set number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c: engine/gncOwner.c - use 'gnc_set_num_action' function to set number based on book option engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based on book option engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and action engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set number based on book option gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function to set number/action based on book option gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set split-action 19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use 'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & h., engine/test/utest-Split.c, engine/engine-helpers.c, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/test/test-xml-transaction.c: gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve number based on book option gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to retrieve number and action gnome/dialog-print-check.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action register/ledger-core/split-register-model.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-load.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-control.c - use 'gnc_get_num_action' function to retrieve action register/ledger-core/split-register.c - use 'gnc_get_num_action' function to retrieve transaction-num engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function to retrieve transaction-number but may not be getting what is expected if book option to use split-action for 'num' is set report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly report/standard-reports/transaction.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum, adjust sorting based on book option and modify report headings and option text accordingly; add 'SPLIT-ACTION' as a term for sorting queries report/business-reports/customer-summary.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/owner-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/job-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum business/business-gnome/dialog-payment.c - use 'gnc_get_num_action' function to retrieve number based on book option git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 00:00:54 -06:00
/** Calls gnc_book_option_num_field_source_change to initiate registered
* callbacks when num_field_source book option changes so that
* registers/reports can update themselves; sets feature flag */
void gnc_book_option_num_field_source_change_cb (gboolean num_action);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
/** Calls gnc_book_option_book_currency_selected to initiate registered
* callbacks when currency accounting book option changes to book-currency so
* that registers/reports can update themselves; sets feature flag */
void gnc_book_option_book_currency_selected_cb (gboolean use_book_currency);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
/** Returns TRUE if both book-currency and default gain/loss policy KVPs exist
* and are valid and trading accounts are not used */
gboolean gnc_book_use_book_currency (QofBook *book);
/** Returns pointer to Book Currency name for book or NULL; determines
* that both book-currency and default gain/loss policy KVPs exist and that
* both are valid, a requirement for the 'book-currency' currency accounting
* method to apply. */
Book-Currency Feature step 5 Save a default gain/loss account in a book KVP and clean up some other book-currency items. The changes made are: app-utils/gnc-ui-util.c & h - define new functions: gnc_book_get_book_currency_name, gnc_book_get_default_gain_loss_acct; reflect changed function names: qof_book_get_book_currency_name, gnc_valid_policy_name app-utils/options.scm - reflect changed function name: gnc-valid-policy-name app-utils/test/test-gnc-ui-util.c - include tests for gnc_book_get_default_gain_loss_acct; reflect changed function name: gnc_book_get_book_currency_name engine/policy-p.h - add policy name, description and hint to policy structure engine/policy.c & h - simplify gnc_get_valid_policy_list & define new functions: gnc_valid_policy, PolicyGetName, PolicyGetDescription, PolicyGetHint, xaccGetLIFOPolicy gnome-utils/dialog-options.c - conform to changes to gnc_get_valid_policy_list and use new function gnc_cost_policy_select_new gnome-utils/dialog-utils.c & h - define new function: gnc_cost_policy_select_new libqof/qof/qofbook.cpp & h - define new property: PROP_OPT_DEFAULT_GAINS_ACCOUNT_GUID and new function: qof_book_get_default_gain_loss_acct_guid changed function name: qof_book_get_book_currency_name libqof/qof/qofbookslots.h - define new option: OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID libqof/qof/test/test-qofbook.c - reflect changed function names: qof_book_get_book_currency_name, gnc_valid_policy_name; add test for qof_book_get_default_gain_loss_acct_guid
2016-06-17 15:48:03 -05:00
const gchar * gnc_book_get_book_currency_name (QofBook *book);
/** Returns pointer to Book Currency for book or NULL; determines
* that both book-currency and default gain/loss policy KVPs exist and that
* both are valid, a requirement for the 'book-currency' currency accounting
* method to apply. */
gnc_commodity * gnc_book_get_book_currency (QofBook *book);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
/** Returns pointer to default gain/loss policy for book or NULL; determines
* that both book-currency and default gain/loss policy KVPs exist and that
* both are valid, a requirement for the 'book-currency' currency accounting
* method to apply. */
const gchar * gnc_book_get_default_gains_policy (QofBook *book);
Book-Currency Feature step 5 Save a default gain/loss account in a book KVP and clean up some other book-currency items. The changes made are: app-utils/gnc-ui-util.c & h - define new functions: gnc_book_get_book_currency_name, gnc_book_get_default_gain_loss_acct; reflect changed function names: qof_book_get_book_currency_name, gnc_valid_policy_name app-utils/options.scm - reflect changed function name: gnc-valid-policy-name app-utils/test/test-gnc-ui-util.c - include tests for gnc_book_get_default_gain_loss_acct; reflect changed function name: gnc_book_get_book_currency_name engine/policy-p.h - add policy name, description and hint to policy structure engine/policy.c & h - simplify gnc_get_valid_policy_list & define new functions: gnc_valid_policy, PolicyGetName, PolicyGetDescription, PolicyGetHint, xaccGetLIFOPolicy gnome-utils/dialog-options.c - conform to changes to gnc_get_valid_policy_list and use new function gnc_cost_policy_select_new gnome-utils/dialog-utils.c & h - define new function: gnc_cost_policy_select_new libqof/qof/qofbook.cpp & h - define new property: PROP_OPT_DEFAULT_GAINS_ACCOUNT_GUID and new function: qof_book_get_default_gain_loss_acct_guid changed function name: qof_book_get_book_currency_name libqof/qof/qofbookslots.h - define new option: OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID libqof/qof/test/test-qofbook.c - reflect changed function names: qof_book_get_book_currency_name, gnc_valid_policy_name; add test for qof_book_get_default_gain_loss_acct_guid
2016-06-17 15:48:03 -05:00
/** Returns pointer to default gain/loss account for book or NULL; determines
* that both book-currency and default gain/loss policy KVPs exist and that
* both are valid, a requirement for the 'book-currency' currency accounting
* method to apply. */
Account * gnc_book_get_default_gain_loss_acct (QofBook *book);
Account * gnc_get_current_root_account (void);
gnc_commodity_table * gnc_get_current_commodities (void);
/**
* Get either the full name of the account or the simple name, depending on the
* configuration parameter general/register/show_leaf_account_names.
*
* @param account The account to retrieve the name for.
* @return A newly allocated string.
*/
gchar *gnc_get_account_name_for_register(const Account *account);
/**
* Retrieve the account matching the given name starting from the descendants of
* base_account.
* @a name is either considered to be the name of the leaf in the account tree
* or to be the full account path, depending on the configuration parameter
* general.register/show_leaf_account_names.
*
* @param base_account The account to start the search at.
* @param name The name to search for.
* @return A pointer to the account, or NULL if the account was not found.
*/
Account *gnc_account_lookup_for_register(const Account *base_account, const
gchar *name);
/**
* Get either the full name of the account or the simple name, depending on the
* show_leaf_accounts.
*
* @param account The account to retrieve the name for.
* @param show_leaf_accounts Whether the full name will be returned.
* @return A newly allocated string.
*/
gchar *gnc_get_account_name_for_split_register(const Account *account,
gboolean show_leaf_accounts);
/*
* This is a wrapper routine around an xaccGetBalanceInCurrency
* function that handles additional needs of the gui.
*
* @param fn The underlying function in Account.c to call to retrieve
* a specific balance from the account.
* @param account The account to retrieve data about.
* @param recurse Include all sub-accounts of this account.
* @param negative An indication of whether or not the returned value
* is negative. This can be used by the caller to
* easily decode whether or not to color the output.
* @param commodity The commodity in which the account balance should
* be returned. If NULL, the value will be returned in
* the commodity of the account. This is normally used
* to specify a currency, which forces the conversion
* of things like stock account values from share
* values to an amount the requested currency.
*/
char *gnc_ui_account_get_tax_info_string (const Account *account);
char *gnc_ui_account_get_tax_info_sub_acct_string (const Account *account);
const char * gnc_get_reconcile_str (char reconciled_flag);
const char * gnc_get_reconcile_valid_flags (void);
const char * gnc_get_reconcile_flag_order (void);
typedef enum
{
EQUITY_OPENING_BALANCE,
EQUITY_RETAINED_EARNINGS,
NUM_EQUITY_TYPES
} GNCEquityType;
Account * gnc_find_or_create_equity_account (Account *root,
GNCEquityType equity_type,
gnc_commodity *currency);
gboolean gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
time64 date,
QofBook *book);
/* Locale functions *************************************************/
/* Returns the default currency of the current locale, or NULL if no
* sensible currency could be identified from the locale. */
gnc_commodity * gnc_locale_default_currency_nodefault (void);
/* Returns the default currency of the current locale. WATCH OUT: If
* no currency could be identified from the locale, this one returns
* "USD", but this will have nothing to do with the actual locale. */
gnc_commodity * gnc_locale_default_currency (void);
/* Returns the default ISO currency string of the current locale. */
const char * gnc_locale_default_iso_currency_code (void);
/** Return the default currency set by the user. If the user's
* preference is invalid, then this routine will return the default
* currency for the user's locale.
*
* @return A pointer to a currency.
*/
gnc_commodity * gnc_default_currency (void);
/** Returns a gnc_commodity that is a currency, suitable for being a
Transaction's currency. The gnc_commodity is taken either from the current
account, or from the next parent account that has a gnc_commodity that is a
currency, or from gnc_default_currency().
If the given account or any of its parent account have a commodity that is a
currency, it is returned and the gboolean currency_from_account_found is set to
TRUE (if non-NULL). If neither this account nor any of its parent accounts have
such a commodity, gnc_default_currency() is returned and the gboolean
currency_from_account_found is set to FALSE (if non-NULL). This can be used to
show an appropriate warning message.
If account is NULL, gnc_default_currency() is returned and
currency_from_account_found is set to FALSE.
@param account The account where the currency should be looked up. May be NULL.
@param currency_from_account_found A gboolean pointer that takes the output
argument of whether the returned currency was found in the account. May be
NULL.
@return A currency pointer (and never NULL).
*/
gnc_commodity * gnc_account_or_default_currency(const Account* account, gboolean * currency_from_account_found);
/** Return the default currency for use in reports, as set by the
* user. If the user's preference is invalid, then this routine will
* return the default currency for the user's locale.
*
* @return A pointer to a currency.
*/
gnc_commodity * gnc_default_report_currency (void);
/* Amount printing and parsing **************************************/
/*
* The xaccPrintAmount() and xaccSPrintAmount() routines provide
* i18n'ed convenience routines for printing gnc_numerics.
* amounts. Both routines take a gnc_numeric argument and
* a printing information object.
*
* The xaccPrintAmount() routine returns a pointer to a statically
* allocated buffer, and is therefore not thread-safe.
*
* The xaccSPrintAmount() routine accepts a pointer to the buffer to be
* printed to. It returns the length of the printed string.
*/
typedef struct _GNCPrintAmountInfo
{
const gnc_commodity *commodity; /* may be NULL */
guint8 max_decimal_places;
guint8 min_decimal_places;
unsigned int use_separators : 1; /* Print thousands separators */
unsigned int use_symbol : 1; /* Print currency symbol */
unsigned int use_locale : 1; /* Use locale for some positioning */
unsigned int monetary : 1; /* Is a monetary quantity */
unsigned int force_fit : 1; /* Don't print more than max_dp places */
unsigned int round : 1; /* Round at max_dp instead of truncating */
} GNCPrintAmountInfo;
GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol);
GNCPrintAmountInfo gnc_commodity_print_info (const gnc_commodity *commodity,
gboolean use_symbol);
GNCPrintAmountInfo gnc_account_print_info (const Account *account,
gboolean use_symbol);
GNCPrintAmountInfo gnc_split_amount_print_info (Split *split,
gboolean use_symbol);
GNCPrintAmountInfo gnc_share_print_info_places (int decplaces);
GNCPrintAmountInfo gnc_default_share_print_info (void);
GNCPrintAmountInfo gnc_default_price_print_info (const gnc_commodity *curr);
GNCPrintAmountInfo gnc_integral_print_info (void);
/* WARNING: Garbage in, garbage out. You must check the validity of
the supplied gnc_numeric. If it's invalid, the returned string
could point to ANYTHING. */
const char * xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info);
int xaccSPrintAmount (char *buf, gnc_numeric val, GNCPrintAmountInfo info);
const gchar *printable_value(gdouble val, gint denom);
gchar *number_to_words(gdouble val, gint64 denom);
gchar *numeric_to_words(gnc_numeric val);
/* xaccParseAmount parses in_str to obtain a numeric result. The
* routine will parse as much of in_str as it can to obtain a single
* number. The number is parsed using the current locale information
* and the 'monetary' flag. The routine will return TRUE if it
* successfully parsed a number and FALSE otherwise. If TRUE is
* returned and result is non-NULL, the value of the parsed number
* is stored in *result. If FALSE is returned, *result is
* unchanged. If TRUE is returned and endstr is non-NULL, the
* location of the first character in in_str not used by the parser
* will be returned in *endstr. If FALSE is returned and endstr is
* non-NULL, *endstr will point to in_str. */
gboolean xaccParseAmount (const char * in_str, gboolean monetary,
gnc_numeric *result, char **endstr);
/*
* xaccParseAmountPosSign is just like xaccParseAmount except the
* caller can choose whether the locale's postive sign (or in absense
* the '+') character is ignored. Setting skip to TRUE will cause
* the function to ignore any positive sign. Setting it to FALSE,
* and positive signs will be treated as unrecognized characters.
* xaccParseAmount will run as if skip is FALSE for compatibility
* reasons (gnc-expression-parser depends on this behaviour).
*/
gboolean
xaccParseAmountPosSign (const char * in_str, gboolean monetary, gnc_numeric *result,
char **endstr, gboolean skip);
/*
* xaccParseAmountExtended is just like xaccParseAmount except the
* caller must provide all the locale-specific information.
*
* Note: if group is NULL, no group-size verification will take place.
* ignore_list is a list of characters that are completely ignored
* while processing the input string. If ignore_list is NULL, nothing
* is ignored.
*/
gboolean
xaccParseAmountExtended (const char * in_str, gboolean monetary,
gunichar negative_sign, gunichar decimal_point,
gunichar group_separator, const char *group, const char *ignore_list,
gnc_numeric *result, char **endstr);
/* Initialization ***************************************************/
void gnc_ui_util_init (void);
#endif
/** @} */
/** @} */