mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
81 lines
3.5 KiB
C
81 lines
3.5 KiB
C
/********************************************************************\
|
|
* policy-p.h -- Implement Accounting Policy Private Header File *
|
|
* *
|
|
* 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 *
|
|
\********************************************************************/
|
|
|
|
/** @file policy-p.h
|
|
* @brief Implement Accounting Policy Private header File.
|
|
* @author Created by Linas Vepstas August 2003
|
|
* @author Copyright (c) 2003 Linas Vepstas <linas@linas.org>
|
|
*
|
|
* This file implements Accounting Policy. The Accounting Policy
|
|
* determines how splits are assigned to lots. The default policy
|
|
* is the FIFO policy: the first thing bought is also the first
|
|
* thing sold.
|
|
*/
|
|
|
|
#ifndef XACC_POLICY_P_H
|
|
#define XACC_POLICY_P_H
|
|
|
|
#include "gnc-engine.h"
|
|
#include "policy.h"
|
|
|
|
/* ============================================================== */
|
|
/** The Policy routines try to encapsulate the FIFO/LIFO-specific
|
|
* parts of the cap-gains routine, and can be replaced by something
|
|
* else for other policies.
|
|
*
|
|
* The PolicyGetLot() routine returns a lot into which the
|
|
* indicated split should be placed.
|
|
*
|
|
* The PolicyGetSplit() routine returns an unassinged split
|
|
* from the account that is appropriate for placing into the
|
|
* indicated lot. For the FIFO policy, that would be the
|
|
* earliest split that is not in any account, and is of the
|
|
* appropriate sign. For a LIFO, it would be the latest.
|
|
*
|
|
* The PolicyIsOpeningSplit() predicate returns a true/false
|
|
* value, indicating if the indicated split was used to 'open'
|
|
* or 'grow' the lot.
|
|
*
|
|
* The PolicyGetLotOpening() routine returns information about
|
|
* the opening balances for the lot. The 'opening balances'
|
|
* are the sum of all the splits used to grow (increase the size
|
|
* of) the lot. For a LIFO or FIFO policy, there is only one
|
|
* split that opens a lot.
|
|
*/
|
|
|
|
struct gncpolicy_s
|
|
{
|
|
char *name;
|
|
char *description;
|
|
char *hint;
|
|
GNCLot * (*PolicyGetLot) (GNCPolicy *, Split *split);
|
|
Split * (*PolicyGetSplit) (GNCPolicy *, GNCLot *lot);
|
|
void (*PolicyGetLotOpening) (GNCPolicy *, GNCLot *lot,
|
|
gnc_numeric *ret_amount,
|
|
gnc_numeric *ret_value,
|
|
gnc_commodity **ret_currency);
|
|
|
|
gboolean (*PolicyIsOpeningSplit) (GNCPolicy *, GNCLot *lot,
|
|
Split *split);
|
|
};
|
|
|
|
#endif /* XACC_POLICY_P_H */
|