2006-02-22 15:52:46 -06:00
|
|
|
/********************************************************************\
|
|
|
|
* 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
|
|
|
|
@{ */
|
2011-05-16 04:13:40 -05:00
|
|
|
/** @addtogroup Transaction Transaction, Split
|
2010-02-17 23:31:54 -06:00
|
|
|
A good overview of transactions, splits and accounts can be
|
2006-02-22 15:52:46 -06:00
|
|
|
found in the texinfo documentation, together with an overview of
|
|
|
|
how to use this API.
|
|
|
|
|
|
|
|
@{ */
|
2010-02-17 23:31:54 -06:00
|
|
|
/** @file Split.h
|
2006-02-22 15:52:46 -06:00
|
|
|
@brief API for Transactions and Splits (journal entries)
|
|
|
|
@author Copyright (C) 1997 Robin D. Clark
|
|
|
|
@author Copyright (C) 1997-2001 Linas Vepstas <linas@linas.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XACC_SPLIT_H
|
|
|
|
#define XACC_SPLIT_H
|
|
|
|
|
2007-04-04 19:23:50 -05:00
|
|
|
typedef struct _SplitClass SplitClass;
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
#include <time.h>
|
|
|
|
|
2011-05-23 14:36:01 -05:00
|
|
|
#include "gnc-commodity.h"
|
2011-05-23 14:44:24 -05:00
|
|
|
#include "gnc-engine.h"
|
2006-02-22 15:52:46 -06:00
|
|
|
|
2017-08-14 13:32:45 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-04-04 19:23:50 -05:00
|
|
|
/* --- type macros --- */
|
|
|
|
#define GNC_TYPE_SPLIT (gnc_split_get_type ())
|
|
|
|
#define GNC_SPLIT(o) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, Split))
|
|
|
|
#define GNC_SPLIT_CLASS(k) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, SplitClass))
|
|
|
|
#define GNC_IS_SPLIT(o) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT))
|
|
|
|
#define GNC_IS_SPLIT_CLASS(k) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT))
|
|
|
|
#define GNC_SPLIT_GET_CLASS(o) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, SplitClass))
|
|
|
|
GType gnc_split_get_type(void);
|
|
|
|
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/** @name Split Reconciled field values
|
|
|
|
|
|
|
|
If you change these
|
|
|
|
be sure to change gnc-ui-util.c:gnc_get_reconciled_str() and
|
|
|
|
associated functions
|
|
|
|
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
#define CREC 'c' /**< The Split has been cleared */
|
|
|
|
#define YREC 'y' /**< The Split has been reconciled */
|
|
|
|
#define FREC 'f' /**< frozen into accounting period */
|
|
|
|
#define NREC 'n' /**< not reconciled or cleared */
|
|
|
|
#define VREC 'v' /**< split is void */
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/* Convert the amount/value of the Split for viewing in the account --
|
|
|
|
* in particular we want to convert the Split to be in to_commodity.
|
|
|
|
* Returns the amount.
|
|
|
|
*/
|
2010-03-07 15:28:15 -06:00
|
|
|
gnc_numeric xaccSplitConvertAmount (const Split *split, const Account * account);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------
|
|
|
|
* Splits
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/** @name Split general getters/setters
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor. */
|
|
|
|
Split * xaccMallocSplit (QofBook *book);
|
|
|
|
|
|
|
|
/* Reinit a previously malloc'd split. Split remains in the book it
|
2007-04-01 17:18:50 -05:00
|
|
|
was already in, and the QofInstance portions also remain unchanged.
|
2006-02-22 15:52:46 -06:00
|
|
|
It's basically the data elements that are reverted to default
|
|
|
|
values. */
|
|
|
|
void xaccSplitReinit(Split * split);
|
|
|
|
|
|
|
|
/** Destructor.
|
|
|
|
*
|
|
|
|
* The xaccSplitDestroy() method will update its parent account and
|
|
|
|
* transaction in a consistent manner, resulting in the complete
|
|
|
|
* unlinking of the split, and the freeing of its associated memory.
|
|
|
|
* The goal of this routine is to perform the removal and destruction
|
|
|
|
* of the split in an atomic fashion, with no chance of accidentally
|
|
|
|
* leaving the accounting structure out-of-balance or otherwise
|
|
|
|
* inconsistent.
|
|
|
|
*
|
|
|
|
* If the deletion of the split leaves the transaction with no splits,
|
|
|
|
* then the transaction will be marked for deletion. (It will not be
|
|
|
|
* deleted until the xaccTransCommitEdit() routine is called.)
|
|
|
|
*
|
|
|
|
* @return TRUE upon successful deletion of the split. FALSE when
|
|
|
|
* the parenting Transaction is a read-only one.
|
|
|
|
*/
|
|
|
|
gboolean xaccSplitDestroy (Split *split);
|
|
|
|
|
2013-02-28 03:52:12 -06:00
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
/** This is really a helper for xaccTransCopyOnto. It doesn't reparent
|
|
|
|
* the 'to' split to from's transaction, because xaccTransCopyOnto is
|
|
|
|
* responsible for parenting the split to the correct transaction.
|
|
|
|
* Also, from's parent transaction may not even be a valid
|
|
|
|
* transaction, so this function may not modify anything about 'from'
|
|
|
|
* or from's transaction.
|
|
|
|
*/
|
|
|
|
void xaccSplitCopyOnto(const Split *from_split, Split *to_split);
|
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/** Returns the book of this split, i.e. the entity where this split
|
|
|
|
* is stored. */
|
|
|
|
QofBook * xaccSplitGetBook (const Split *split);
|
|
|
|
|
|
|
|
/** Returns the account of this split, which was set through
|
|
|
|
* xaccAccountInsertSplit(). */
|
|
|
|
Account * xaccSplitGetAccount (const Split *split);
|
2006-03-03 18:09:03 -06:00
|
|
|
void xaccSplitSetAccount (Split *s, Account *acc);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
2006-03-03 18:09:03 -06:00
|
|
|
/** Returns the parent transaction of the split. */
|
2006-02-22 15:52:46 -06:00
|
|
|
Transaction * xaccSplitGetParent (const Split *split);
|
2006-03-03 18:09:03 -06:00
|
|
|
void xaccSplitSetParent (Split *split, Transaction *trans);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
|
|
|
/** Returns the pointer to the debited/credited Lot where this split
|
|
|
|
* belongs to, or NULL if it doesn't belong to any. */
|
|
|
|
GNCLot * xaccSplitGetLot (const Split *split);
|
|
|
|
|
2008-08-01 11:02:07 -05:00
|
|
|
/** Assigns the split to a specific Lot */
|
|
|
|
void xaccSplitSetLot(Split* split, GNCLot* lot);
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/** The memo is an arbitrary string associated with a split. It is
|
|
|
|
* intended to hold a short (zero to forty character) string that is
|
|
|
|
* displayed by the GUI along with this split. Users typically type
|
|
|
|
* in free form text from the GUI. */
|
|
|
|
void xaccSplitSetMemo (Split *split, const char *memo);
|
|
|
|
|
|
|
|
/** Returns the memo string. */
|
|
|
|
const char * xaccSplitGetMemo (const Split *split);
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** The Action is an arbitrary user-assigned string.
|
2006-02-22 15:52:46 -06:00
|
|
|
* The action field is an arbitrary user-assigned value.
|
2009-02-03 15:19:31 -06:00
|
|
|
* It is meant to be a very short (one to ten character) string that
|
2006-02-22 15:52:46 -06:00
|
|
|
* signifies the "type" of this split, such as e.g. Buy, Sell, Div,
|
|
|
|
* Withdraw, Deposit, ATM, Check, etc. The idea is that this field
|
2016-09-07 10:10:44 -05:00
|
|
|
* can be used to create custom reports or graphs of data. Note that the
|
|
|
|
* business features auto-fill this value, but doesn't depend on it. Rather than use
|
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
|
|
|
* this function directly, see 'gnc_set_num_action' in
|
|
|
|
* engine/engine-helpers.c & .h which takes a user-set book option for selecting
|
|
|
|
* the source for the num-cell (the transaction-number or the split-action field)
|
|
|
|
* in registers/reports into account automatically */
|
2006-02-22 15:52:46 -06:00
|
|
|
void xaccSplitSetAction (Split *split, const char *action);
|
|
|
|
|
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
|
|
|
/** Returns the action string. Rather than use this function directly, see
|
|
|
|
* 'gnc_get_num_action' and 'gnc_get_action_num'in
|
|
|
|
* engine/engine-helpers.c & .h which takes a user-set book option for selecting
|
|
|
|
* the source for the num-cell (the transaction-number or the split-action field)
|
|
|
|
* in registers/reports into account automatically */
|
2006-02-22 15:52:46 -06:00
|
|
|
const char * xaccSplitGetAction (const Split *split);
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** @name Split Date getters/setters
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
/** Set the reconcile flag. The Reconcile flag is a single char, whose
|
|
|
|
* values are typically are 'n', 'y', 'c'. In Transaction.h, macros
|
|
|
|
* are defined for typical values (e.g. CREC, YREC). */
|
|
|
|
void xaccSplitSetReconcile (Split *split, char reconciled_flag);
|
|
|
|
/** Returns the value of the reconcile flag. */
|
|
|
|
char xaccSplitGetReconcile (const Split *split);
|
|
|
|
|
|
|
|
/** Set the date on which this split was reconciled by specifying the
|
2012-12-01 16:44:53 -06:00
|
|
|
* time as time64. */
|
|
|
|
void xaccSplitSetDateReconciledSecs (Split *split, time64 time);
|
2006-02-22 15:52:46 -06:00
|
|
|
/** Set the date on which this split was reconciled by specifying the
|
2006-03-03 18:09:03 -06:00
|
|
|
* time as Timespec. Caller still owns *ts! */
|
2006-02-22 15:52:46 -06:00
|
|
|
void xaccSplitSetDateReconciledTS (Split *split, Timespec *ts);
|
|
|
|
/** Get the date on which this split was reconciled by having it
|
|
|
|
* written into the Timespec that 'ts' is pointing to. */
|
2010-02-17 23:31:54 -06:00
|
|
|
void xaccSplitGetDateReconciledTS (const Split *split,
|
|
|
|
Timespec *ts);
|
2006-02-22 15:52:46 -06:00
|
|
|
/** Returns the date (as Timespec) on which this split was reconciled. */
|
|
|
|
Timespec xaccSplitRetDateReconciledTS (const Split *split);
|
|
|
|
|
2013-08-02 12:55:10 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
/** Retrieve the date when the Split was reconciled. */
|
|
|
|
time64 xaccSplitGetDateReconciled (const Split *split);
|
|
|
|
/*################## Added for Reg2 #################*/
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** @name Split amount getters/setters
|
2006-02-22 15:52:46 -06:00
|
|
|
*
|
|
|
|
* 'value' vs. 'amount' of a Split: The 'value' is the amount of the
|
|
|
|
* _transaction_ balancing commodity (i.e. currency) involved,
|
|
|
|
* 'amount' is the amount of the _account's_ commodity involved.
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** The xaccSplitSetAmount() method sets the amount in the account's
|
2006-02-22 15:52:46 -06:00
|
|
|
* commodity that the split should have.
|
|
|
|
*
|
|
|
|
* The following four setter functions set the prices and amounts.
|
|
|
|
* All of the routines always maintain balance: that is, invoking any
|
|
|
|
* of them will cause other splits in the transaction to be modified
|
|
|
|
* so that the net value of the transaction is zero.
|
|
|
|
*
|
|
|
|
* IMPORTANT: The split should be parented by an account before
|
|
|
|
* any of these routines are invoked! This is because the actual
|
|
|
|
* setting of amounts/values requires SCU settings from the account.
|
2010-02-17 23:31:54 -06:00
|
|
|
* If these are not available, then amounts/values will be set to
|
2009-02-03 15:19:31 -06:00
|
|
|
* -1/0, which is an invalid value. I believe this order dependency
|
2010-02-17 23:31:54 -06:00
|
|
|
* is a bug, but I'm too lazy to find, fix & test at the moment ...
|
2006-02-22 15:52:46 -06:00
|
|
|
*
|
|
|
|
* @note If you use this on a newly created transaction, make sure
|
|
|
|
* that the 'value' is also set so that it doesn't remain zero.
|
|
|
|
*/
|
|
|
|
void xaccSplitSetAmount (Split *split, gnc_numeric amount);
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** Returns the amount of the split in the account's commodity.
|
2006-02-22 15:52:46 -06:00
|
|
|
* Note that for cap-gains splits, this is slaved to the transaction
|
|
|
|
* that is causing the gains to occur.
|
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitGetAmount (const Split * split);
|
|
|
|
|
|
|
|
/** The xaccSplitSetValue() method sets the value of this split in the
|
2010-02-17 23:31:54 -06:00
|
|
|
* transaction's commodity.
|
2006-02-22 15:52:46 -06:00
|
|
|
*
|
|
|
|
* @note If you use this on a newly created transaction, make sure
|
|
|
|
* that the 'amount' is also set so that it doesn't remain zero.
|
|
|
|
*/
|
|
|
|
void xaccSplitSetValue (Split *split, gnc_numeric value);
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** Returns the value of this split in the transaction's commodity.
|
2006-02-22 15:52:46 -06:00
|
|
|
* Note that for cap-gains splits, this is slaved to the transaction
|
|
|
|
* that is causing the gains to occur.
|
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitGetValue (const Split * split);
|
|
|
|
|
|
|
|
/** The xaccSplitSetSharePriceAndAmount() method will simultaneously
|
|
|
|
* update the share price and the number of shares. This is a utility
|
|
|
|
* routine that is equivalent to a xaccSplitSetSharePrice() followed
|
|
|
|
* by and xaccSplitSetAmount(), except that it incurs the processing
|
|
|
|
* overhead of balancing only once, instead of twice. */
|
2010-02-17 23:31:54 -06:00
|
|
|
void xaccSplitSetSharePriceAndAmount (Split *split,
|
|
|
|
gnc_numeric price,
|
|
|
|
gnc_numeric amount);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
|
|
|
/** Returns the price of the split, that is, the value divided by the
|
|
|
|
* amount. If the amount is zero, returns a gnc_numeric of value
|
|
|
|
* one. */
|
|
|
|
gnc_numeric xaccSplitGetSharePrice (const Split * split);
|
|
|
|
|
|
|
|
/** Depending on the base_currency, set either the value or the amount
|
|
|
|
* of this split or both: If the base_currency is the transaction's
|
|
|
|
* commodity, set the value. If it is the account's commodity, set the
|
2010-02-17 23:31:54 -06:00
|
|
|
* amount. If both, set both.
|
2006-02-22 15:52:46 -06:00
|
|
|
*
|
|
|
|
* @note <b>WATCH OUT:</b> When using this function and the
|
|
|
|
* transaction's and account's commodities are different, the amount
|
|
|
|
* or the value will be left as zero. This might screw up the
|
|
|
|
* multi-currency handling code in the register. So please think twice
|
|
|
|
* whether you need this function -- using xaccSplitSetValue()
|
|
|
|
* together with xaccSplitSetAmount() is definitely the better and
|
|
|
|
* safer solution!
|
|
|
|
*/
|
|
|
|
void xaccSplitSetBaseValue (Split *split, gnc_numeric value,
|
|
|
|
const gnc_commodity * base_currency);
|
|
|
|
|
|
|
|
/** Depending on the base_currency, return either the value or the
|
|
|
|
* amount of this split: If the base_curreny is the transaction's
|
|
|
|
* commodity, return the value. If it is the account's commodity,
|
|
|
|
* return the amount. If it is neither print a warning message and
|
|
|
|
* return gnc_numeric_zero().
|
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
gnc_numeric xaccSplitGetBaseValue (const Split *split,
|
2006-02-22 15:52:46 -06:00
|
|
|
const gnc_commodity * base_currency);
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** Returns the running balance up to and including the indicated split.
|
2006-02-22 15:52:46 -06:00
|
|
|
* The balance is the currency-denominated balance. For accounts
|
|
|
|
* with non-unit share prices, it is correctly adjusted for
|
|
|
|
* share prices.
|
|
|
|
*
|
2010-02-17 23:31:54 -06:00
|
|
|
* Returns the running balance up to & including the indicated split.
|
2006-02-22 15:52:46 -06:00
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitGetBalance (const Split *split);
|
|
|
|
|
|
|
|
/**
|
2010-02-17 23:31:54 -06:00
|
|
|
* The cleared-balance is the currency-denominated balance
|
2006-02-22 15:52:46 -06:00
|
|
|
* of all transactions that have been marked as cleared or reconciled.
|
|
|
|
* It is correctly adjusted for price fluctuations.
|
|
|
|
*
|
2010-02-17 23:31:54 -06:00
|
|
|
* Returns the running balance up to & including the indicated split.
|
2006-02-22 15:52:46 -06:00
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitGetClearedBalance (const Split *split);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the reconciled-balance of this split. The
|
|
|
|
* reconciled-balance is the currency-denominated balance of all
|
|
|
|
* transactions that have been marked as reconciled.
|
|
|
|
*
|
2010-02-17 23:31:54 -06:00
|
|
|
* Returns the running balance up to & including the indicated split.
|
2006-02-22 15:52:46 -06:00
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitGetReconciledBalance (const Split *split);
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** @name Split utility functions
|
2006-02-22 15:52:46 -06:00
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Equality.
|
|
|
|
*
|
|
|
|
* @param sa First split to compare
|
|
|
|
* @param sb Second split to compare
|
|
|
|
*
|
|
|
|
* @param check_guids If TRUE, try a guid_equal() on the GUIDs of both
|
|
|
|
* splits if their pointers are not equal in the first place.
|
|
|
|
*
|
|
|
|
* @param check_balances If TRUE, compare balances between the two
|
|
|
|
* splits. Balances are recalculated whenever a split is added or
|
|
|
|
* removed from an account, so YMMV on whether this should be set.
|
|
|
|
*
|
|
|
|
* @param check_txn_splits If the pointers are not equal, but
|
|
|
|
* everything else so far is equal (including memo, amount, value,
|
2015-06-09 18:19:41 -05:00
|
|
|
* kvp), then, when comparing the parenting transactions with
|
2006-02-22 15:52:46 -06:00
|
|
|
* xaccTransEqual(), set its argument check_splits to be TRUE.
|
|
|
|
*/
|
|
|
|
gboolean xaccSplitEqual(const Split *sa, const Split *sb,
|
|
|
|
gboolean check_guids,
|
2010-02-17 23:31:54 -06:00
|
|
|
gboolean check_balances,
|
2006-02-22 15:52:46 -06:00
|
|
|
gboolean check_txn_splits);
|
|
|
|
|
|
|
|
/** The xaccSplitLookup() subroutine will return the
|
|
|
|
* split associated with the given id, or NULL
|
|
|
|
* if there is no such split. */
|
2010-03-27 16:01:21 -05:00
|
|
|
Split * xaccSplitLookup (const GncGUID *guid, QofBook *book);
|
2006-02-22 15:52:46 -06:00
|
|
|
#define xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b)
|
|
|
|
|
2012-10-18 03:15:21 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
2012-08-07 12:24:33 -05:00
|
|
|
/* Get a GList of unique transactions containing the given list of Splits. */
|
|
|
|
GList *xaccSplitListGetUniqueTransactions(const GList *splits);
|
2012-10-18 03:15:21 -05:00
|
|
|
/*################## Added for Reg2 #################*/
|
2015-05-31 19:59:01 -05:00
|
|
|
/** Add a peer split to this split's lot-split list.
|
|
|
|
* @param other_split: The split whose guid to add
|
|
|
|
* @param timestamp: The time to be recorded for the split.
|
|
|
|
*/
|
|
|
|
void xaccSplitAddPeerSplit (Split *split, const Split *other_split,
|
|
|
|
const time64 timestamp);
|
|
|
|
/** Does this split have peers?
|
|
|
|
*/
|
|
|
|
gboolean xaccSplitHasPeers (const Split *split);
|
|
|
|
/** Report if a split is a peer of this one.
|
|
|
|
* @param other_split: The split to test for being a peer of this one.
|
|
|
|
* @return: True if other_split is registered as a peer of this one.
|
|
|
|
*/
|
|
|
|
gboolean xaccSplitIsPeerSplit (const Split *split, const Split *other_split);
|
|
|
|
/** Remove a peer split from this split's lot-split list.
|
|
|
|
* @param other_split: The split whose guid to remove
|
|
|
|
*/
|
|
|
|
void xaccSplitRemovePeerSplit (Split *split, const Split *other_split);
|
|
|
|
|
|
|
|
/** Merge the other_split's peer splits into split's peers.
|
|
|
|
* @param other_split: The split donating the peer splits.
|
|
|
|
*/
|
|
|
|
void xaccSplitMergePeerSplits (Split *split, const Split *other_split);
|
2012-08-07 12:24:33 -05:00
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/**
|
2006-02-22 15:52:46 -06:00
|
|
|
* The xaccSplitGetOtherSplit() is a convenience routine that returns
|
2010-02-17 23:31:54 -06:00
|
|
|
* the other of a pair of splits. If there are more than two
|
2006-02-22 15:52:46 -06:00
|
|
|
* splits, it returns NULL.
|
|
|
|
*/
|
|
|
|
Split * xaccSplitGetOtherSplit (const Split *split);
|
|
|
|
|
|
|
|
/** The xaccIsPeerSplit() is a convenience routine that returns TRUE
|
|
|
|
* (a non-zero value) if the two splits share a common parent
|
|
|
|
* transaction, else it returns FALSE (zero).
|
2011-11-18 15:04:01 -06:00
|
|
|
*
|
2006-02-22 15:52:46 -06:00
|
|
|
gboolean xaccIsPeerSplit (const Split *split_1, const Split *split_2);
|
2011-11-18 15:04:01 -06:00
|
|
|
*/
|
2006-02-22 15:52:46 -06:00
|
|
|
/** Returns the split type, which is either the string "normal", or
|
|
|
|
* "stock-split" for a split from a stock split (pun intended? :-). */
|
|
|
|
const char *xaccSplitGetType(const Split *s);
|
|
|
|
|
|
|
|
/** Mark a split to be of type stock split - after this, you shouldn't
|
|
|
|
modify the value anymore, just the amount. */
|
|
|
|
void xaccSplitMakeStockSplit(Split *s);
|
|
|
|
|
|
|
|
/**
|
2007-04-05 21:31:28 -05:00
|
|
|
* The xaccSplitOrder(sa,sb) method is useful for sorting.
|
2006-02-22 15:52:46 -06:00
|
|
|
* if sa and sb have different transactions, return their xaccTransOrder
|
|
|
|
* return a negative value if split sa has a smaller currency-value than sb,
|
|
|
|
* return a positive value if split sa has a larger currency-value than sb,
|
2010-02-17 23:31:54 -06:00
|
|
|
* return a negative value if split sa has a smaller share-price than sb,
|
|
|
|
* return a positive value if split sa has a larger share-price than sb,
|
2006-02-22 15:52:46 -06:00
|
|
|
* then compares memo and action using the strcmp()
|
|
|
|
* c-library routine, returning what strcmp would return.
|
|
|
|
* Then it compares the reconciled flags, then the reconciled dates,
|
|
|
|
* Finally, it returns zero if all of the above match.
|
|
|
|
*/
|
2007-04-05 21:31:28 -05:00
|
|
|
gint xaccSplitOrder (const Split *sa, const Split *sb);
|
|
|
|
gint xaccSplitOrderDateOnly (const Split *sa, const Split *sb);
|
2006-02-22 15:52:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-02-17 23:31:54 -06:00
|
|
|
* These functions compare two splits by different criteria.
|
2006-02-22 15:52:46 -06:00
|
|
|
*
|
2010-02-17 23:31:54 -06:00
|
|
|
* These functions were added because converting strings to guile
|
2006-02-22 15:52:46 -06:00
|
|
|
* for comparisons in the transaction report is terribly inefficient.
|
|
|
|
* More may be added here in future if it turns out that other types
|
|
|
|
* of comparisons also induces guile slowdowns.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Compare two splits by full name of account. Returns similar to
|
|
|
|
* strcmp. */
|
|
|
|
int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb);
|
|
|
|
/** Compare two splits by code of account. Returns similar to
|
|
|
|
* strcmp. */
|
|
|
|
int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb);
|
|
|
|
/** Compare two splits by full name of the other account. Returns
|
|
|
|
* similar to strcmp. This function attempts to find the split on the
|
|
|
|
* other side of a transaction and compare on it. */
|
|
|
|
int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb);
|
|
|
|
/** Compare two splits by code of the other account. Returns similar
|
|
|
|
* to strcmp. This function attempts to find the split on the
|
|
|
|
* other side of a transaction and compare on it. */
|
|
|
|
int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* These functions take a split, get the corresponding split on the
|
|
|
|
* "other side" of the transaction, and extract either the name or code
|
2010-02-17 23:31:54 -06:00
|
|
|
* of that split, reverting to returning a constant "Split" if the
|
2006-02-22 15:52:46 -06:00
|
|
|
* transaction has more than one split on the "other side". These
|
|
|
|
* were added for the transaction report, and is in C because the code
|
2010-02-17 23:31:54 -06:00
|
|
|
* was already written in C for the above functions and duplication
|
|
|
|
* is silly.
|
2015-07-28 10:12:24 -05:00
|
|
|
*
|
|
|
|
* Note that this will only return a real value in case of a
|
|
|
|
* two-split transaction as that is the only situation in which
|
|
|
|
* a reliable value can be returned. In other situations
|
|
|
|
* "-- Split Transaction --" will be returned as Account Name
|
|
|
|
* or "Split" for Account Code.
|
2006-02-22 15:52:46 -06:00
|
|
|
*/
|
|
|
|
|
2006-03-02 01:20:33 -06:00
|
|
|
char * xaccSplitGetCorrAccountFullName(const Split *sa);
|
2006-02-22 15:52:46 -06:00
|
|
|
/** document me */
|
2011-11-18 15:53:28 -06:00
|
|
|
const char * xaccSplitGetCorrAccountName(const Split *sa);
|
|
|
|
/** document me */
|
2006-02-22 15:52:46 -06:00
|
|
|
const char * xaccSplitGetCorrAccountCode(const Split *sa);
|
|
|
|
|
2009-12-17 01:10:49 -06:00
|
|
|
#ifdef DUMP_FUNCTIONS
|
|
|
|
void xaccSplitDump (const Split *split, const char *tag);
|
|
|
|
#endif
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-17 23:31:54 -06:00
|
|
|
/** @name Split deprecated functions
|
2006-02-22 15:52:46 -06:00
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @deprecated The xaccSplitSetSharePrice() method sets the price of the
|
|
|
|
* split. DEPRECATED - set the value and amount instead. */
|
|
|
|
void xaccSplitSetSharePrice (Split *split, gnc_numeric price);
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************\
|
|
|
|
* Miscellaneous utility routines.
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Split voiding
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Returns the original pre-void amount of a split.
|
|
|
|
*
|
|
|
|
* @param split The split in question.
|
|
|
|
*
|
|
|
|
* @return A gnc_numeric containing the original value of this split.
|
|
|
|
* Returns a gnc_numeric of zero upon error.
|
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitVoidFormerAmount(const Split *split);
|
|
|
|
|
|
|
|
/** Returns the original pre-void value of a split.
|
|
|
|
*
|
|
|
|
* @param split The split in question.
|
|
|
|
*
|
|
|
|
* @return A gnc_numeric containing the original amount of this split.
|
|
|
|
* Returns a gnc_numeric of zero upon error.
|
|
|
|
*/
|
|
|
|
gnc_numeric xaccSplitVoidFormerValue(const Split *split);
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** @name Split Parameter names
|
|
|
|
|
|
|
|
* Note, if you want to get the equivalent of "ACCT_MATCH_ALL" you
|
|
|
|
* need to create a search on the following parameter list:
|
|
|
|
* SPLIT->SPLIT_TRANS->TRANS_SPLITLIST->SPLIT_ACCOUNT_GUID. If you do
|
|
|
|
* this, you might want to use the ACCOUNT_MATCH_ALL_TYPE as the
|
|
|
|
* override so the gnome-search dialog displays the right type.
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
#define SPLIT_DATE_RECONCILED "date-reconciled"
|
|
|
|
#define SPLIT_BALANCE "balance"
|
|
|
|
#define SPLIT_CLEARED_BALANCE "cleared-balance"
|
|
|
|
#define SPLIT_RECONCILED_BALANCE "reconciled-balance"
|
|
|
|
#define SPLIT_MEMO "memo"
|
|
|
|
#define SPLIT_ACTION "action"
|
|
|
|
#define SPLIT_RECONCILE "reconcile-flag"
|
|
|
|
#define SPLIT_AMOUNT "amount"
|
|
|
|
#define SPLIT_SHARE_PRICE "share-price"
|
|
|
|
#define SPLIT_VALUE "value"
|
|
|
|
#define SPLIT_TYPE "type"
|
|
|
|
#define SPLIT_VOIDED_AMOUNT "voided-amount"
|
|
|
|
#define SPLIT_VOIDED_VALUE "voided-value"
|
|
|
|
#define SPLIT_LOT "lot"
|
|
|
|
#define SPLIT_TRANS "trans"
|
|
|
|
#define SPLIT_ACCOUNT "account"
|
|
|
|
#define SPLIT_ACCOUNT_GUID "account-guid" /**< for guid_match_all */
|
|
|
|
/* used for SORTING ONLY */
|
|
|
|
#define SPLIT_ACCT_FULLNAME "acct-fullname"
|
|
|
|
#define SPLIT_CORR_ACCT_NAME "corr-acct-fullname"
|
|
|
|
#define SPLIT_CORR_ACCT_CODE "corr-acct-code"
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \deprecated */
|
2007-06-25 12:18:28 -05:00
|
|
|
#define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
2006-02-22 15:52:46 -06:00
|
|
|
/** \deprecated */
|
2007-06-25 12:18:28 -05:00
|
|
|
#define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
2006-02-22 15:52:46 -06:00
|
|
|
|
2017-08-14 13:32:45 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2006-02-22 15:52:46 -06:00
|
|
|
#endif /* XACC_SPLIT_H */
|
|
|
|
/** @} */
|
|
|
|
/** @} */
|