gnucash/src/engine/policy.h

74 lines
3.1 KiB
C
Raw Normal View History

/********************************************************************\
* policy.h -- Implement Accounting Policy *
* *
* 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 Engine
@{ */
/** @addtogroup Policy Accounting Policy (FIFO/LIFO)
* This file implements Accounting Policy. The Accounting Policy
* determines how Splits are assigned to Lots. The contents
* of a Lot determines the Gains on that Lot. The default policy
* is the FIFO policy: the first thing bought is also the first
* thing sold.
@{ */
/** @file policy.h
* @brief Implement Accounting Policy.
* @author Created by Linas Vepstas August 2003
* @author Copyright (c) 2003,2004 Linas Vepstas <linas@linas.org>
*/
#ifndef XACC_POLICY_H
#define XACC_POLICY_H
typedef struct gncpolicy_s GNCPolicy;
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
/** Valid Policy List
* Provides a glist of glists for implemented policies. For each implemented
* policy, this glist contains: name, description, hint, as follows:
* glist(
* glist("fifo", "First In First Out", "Use oldest lots first.")
* glist("lifo", "Last In First Out", "Use newest lots first.")
* etc.
* )
* Both levels of lists must be freed with g_list_free().
*/
GList * gnc_get_valid_policy_list (void);
/** Valid Policy
* Uses the Valid Policy List to determine if a policy name is valid.
*/
gboolean gnc_valid_policy (const gchar *name);
/** First-in, First-out Policy
* This policy will create FIFO Lots. FIFO Lots have the following
* properties:
* -- The lot is started with the earliest posted split that isn't
* a part of another lot already.
* -- Splits are added to the lot in date order, with earliest splits
* added first.
* -- All splits in the lot share the same transaction currency as
* the split that opened the lot.
*/
GNCPolicy *xaccGetFIFOPolicy (void);
#endif /* XACC_POLICY_H */
/** @} */
/** @} */