GnuCash  5.6-150-g038405b370+
split-register.h
Go to the documentation of this file.
1 /********************************************************************\
2  * split-register.h -- split register API *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
22 #ifndef SPLIT_REGISTER_H
23 #define SPLIT_REGISTER_H
24 
25 #include <glib.h>
26 
27 #include "Transaction.h"
28 #include "table-allgui.h"
29 
145 typedef enum
146 {
147  BANK_REGISTER,
148  CASH_REGISTER,
149  ASSET_REGISTER,
150  CREDIT_REGISTER,
151  LIABILITY_REGISTER,
152  INCOME_REGISTER,
153  EXPENSE_REGISTER,
154  EQUITY_REGISTER,
155  STOCK_REGISTER,
156  CURRENCY_REGISTER,
157  RECEIVABLE_REGISTER,
158  PAYABLE_REGISTER,
159  TRADING_REGISTER,
160  NUM_SINGLE_REGISTER_TYPES,
161 
162  GENERAL_JOURNAL = NUM_SINGLE_REGISTER_TYPES,
163  INCOME_LEDGER,
164  PORTFOLIO_LEDGER,
165  SEARCH_LEDGER,
166 
167  NUM_REGISTER_TYPES
169 
173 typedef enum
174 {
175  REG_TYPE_GROUP_UNKNOWN,
176  REG_TYPE_GROUP_CURRENCY,
177  REG_TYPE_GROUP_APAR,
178  REG_TYPE_GROUP_STOCK,
179  REG_TYPE_GROUP_JOURNAL,
180  REG_TYPE_GROUP_PORTFOLIO,
182 
184 typedef enum
185 {
186  REG_STYLE_LEDGER,
187  REG_STYLE_AUTO_LEDGER,
188  REG_STYLE_JOURNAL
190 
195 #define ACTN_CELL "action"
196 #define DOCLINK_CELL "doclink"
197 #define BALN_CELL "balance"
198 #define CRED_CELL "credit"
199 #define DATE_CELL "date"
200 #define DDUE_CELL "date-due"
201 #define DEBT_CELL "debit"
202 #define DESC_CELL "description"
203 #define FCRED_CELL "credit-formula"
204 #define FDEBT_CELL "debit-formula"
205 #define MEMO_CELL "memo"
206 #define MXFRM_CELL "transfer"
207 #define NOTES_CELL "notes"
208 #define NUM_CELL "num"
209 #define TNUM_CELL "trans-num"
210 #define PRIC_CELL "price"
211 #define RATE_CELL "exchrate"
212 #define RECN_CELL "reconcile"
213 #define SHRS_CELL "shares"
214 #define TBALN_CELL "trans-balance"
215 #define TCRED_CELL "trans-credit"
216 #define TDEBT_CELL "trans-debit"
217 #define TSHRS_CELL "trans-shares"
218 #define TYPE_CELL "split-type"
219 #define XFRM_CELL "account"
220 #define VNOTES_CELL "void-notes"
221 #define RBALN_CELL "reg-run-balance"
222 
229 #define CURSOR_SINGLE_LEDGER "cursor-single-ledger"
230 #define CURSOR_DOUBLE_LEDGER "cursor-double-ledger"
231 #define CURSOR_DOUBLE_LEDGER_NUM_ACTN "cursor-double-ledger-num-actn"
232 #define CURSOR_SINGLE_JOURNAL "cursor-single-journal"
233 #define CURSOR_DOUBLE_JOURNAL "cursor-double-journal"
234 #define CURSOR_DOUBLE_JOURNAL_NUM_ACTN "cursor-double-journal-num-actn"
235 #define CURSOR_SPLIT "cursor-split"
236 
240 typedef enum
241 {
242  CURSOR_CLASS_NONE = -1,
243  CURSOR_CLASS_SPLIT,
244  CURSOR_CLASS_TRANS,
245  NUM_CURSOR_CLASSES
246 } CursorClass;
247 
248 
250 typedef struct split_register SplitRegister;
251 typedef struct sr_info SRInfo;
252 
255 {
256  Table* table;
258  SplitRegisterType type;
259  SplitRegisterStyle style;
260 
261  gboolean use_double_line;
266  gboolean double_alt_color;
268  gboolean is_template;
269  gboolean do_auto_complete;
273  SplitList*
276  SRInfo* sr_info;
277 };
278 
280 typedef GtkWidget* (*SRGetParentCallback) (gpointer user_data);
281 
282 
283 /* Prototypes ******************************************************/
284 
298 SplitRegister* gnc_split_register_new (SplitRegisterType type,
299  SplitRegisterStyle style,
300  gboolean use_double_line,
301  gboolean is_template,
302  gboolean mismatched_commodities);
303 
308 void gnc_split_register_destroy (SplitRegister* reg);
309 
321 void gnc_split_register_config (SplitRegister* reg,
322  SplitRegisterType type,
323  SplitRegisterStyle style,
324  gboolean use_double_line);
325 
332 void gnc_split_register_set_reverse_sort (SplitRegister* reg,
333  gboolean reverse_sort);
334 
341 void gnc_split_register_set_auto_complete (SplitRegister* reg,
342  gboolean do_auto_complete);
343 
350 void gnc_split_register_set_read_only (SplitRegister* reg, gboolean read_only);
351 
358 
365 void gnc_split_register_set_template_account (SplitRegister* reg,
366  Account* template_account);
367 
369 void gnc_split_register_set_data (SplitRegister* reg, gpointer user_data,
370  SRGetParentCallback get_parent);
371 
379 
389 (SplitRegister* reg,
390  VirtualCellLocation vcell_loc);
391 
399 Transaction* gnc_split_register_get_current_trans (SplitRegister* reg);
400 
411 Split*
413  VirtualCellLocation* vcell_loc);
414 
422 Split* gnc_split_register_get_current_split (SplitRegister* reg);
423 
431 Split* gnc_split_register_get_blank_split (SplitRegister* reg);
432 
447 gboolean
448 gnc_split_register_get_split_virt_loc (SplitRegister* reg, Split* split,
449  VirtualCellLocation* vcell_loc);
450 
463 gboolean
464 gnc_split_register_get_split_amount_virt_loc (SplitRegister* reg, Split* split,
465  VirtualLocation* virt_loc);
466 
471 Split* gnc_split_register_duplicate_current (SplitRegister* reg);
472 
475 void gnc_split_register_copy_current (SplitRegister* reg);
476 
479 void gnc_split_register_cut_current (SplitRegister* reg);
480 
483 void gnc_split_register_paste_current (SplitRegister* reg);
484 
487 void gnc_split_register_delete_current_split (SplitRegister* reg);
488 
491 void gnc_split_register_delete_current_trans (SplitRegister* reg);
492 
495 void gnc_split_register_void_current_trans (SplitRegister* reg,
496  const char* reason);
497 
500 void gnc_split_register_unvoid_current_trans (SplitRegister* reg);
501 
505  Split* split);
506 void gnc_split_register_empty_current_trans (SplitRegister* reg);
507 
511 void gnc_split_register_cancel_cursor_split_changes (SplitRegister* reg);
512 
516 void gnc_split_register_cancel_cursor_trans_changes (SplitRegister* reg);
517 
537 void gnc_split_register_load (SplitRegister* reg, GList* slist,
538  GList* pre_filter_slist, Account* default_account);
539 
547 gboolean gnc_split_register_save (SplitRegister* reg, gboolean do_commit);
548 
550 void gnc_split_register_redraw (SplitRegister* reg);
551 
553 gboolean gnc_split_register_changed (SplitRegister* reg);
554 
558 void gnc_split_register_show_present_divider (SplitRegister* reg,
559  gboolean show_present);
560 
562 void gnc_split_register_expand_current_trans (SplitRegister* reg,
563  gboolean expand);
564 
566 void gnc_split_register_collapse_current_trans (SplitRegister* reg);
567 
569 gboolean gnc_split_register_current_trans_expanded (SplitRegister* reg);
570 
572 const char* gnc_split_register_get_debit_string (SplitRegister* reg);
573 
575 const char* gnc_split_register_get_credit_string (SplitRegister* reg);
576 
578 gboolean gnc_split_register_is_blank_split (SplitRegister* reg, Split* split);
579 
584 void gnc_split_register_change_blank_split_ref (SplitRegister* reg,
585  Split* split);
586 
592 gboolean
593 gnc_split_register_handle_exchange (SplitRegister* reg, gboolean force_dialog);
594 
595 /* returns TRUE if begin_edit was aborted */
596 gboolean
597 gnc_split_register_begin_edit_or_warn (SRInfo* info, Transaction* trans);
598 
602 /* -------------------------------------------------------------- */
603 
605 gboolean gnc_split_register_full_refresh_ok (SplitRegister* reg);
606 
608 void gnc_copy_trans_onto_trans (Transaction* from, Transaction* to,
609  gboolean use_cut_semantics,
610  gboolean do_commit);
611 
612 #endif
CursorClass gnc_split_register_get_current_cursor_class(SplitRegister *reg)
Returns the class of a register&#39;s current cursor.
Split * gnc_split_register_get_current_trans_split(SplitRegister *reg, VirtualCellLocation *vcell_loc)
Gets the anchoring split of the transaction at the current cursor location, which may be on the trans...
void gnc_copy_trans_onto_trans(Transaction *from, Transaction *to, gboolean use_cut_semantics, gboolean do_commit)
Private function – outsiders must not use this.
gboolean use_double_line
whether to use two lines per transaction
const char * gnc_split_register_get_credit_string(SplitRegister *reg)
Return the credit string used in the register.
void gnc_split_register_set_reverse_sort(SplitRegister *reg, gboolean reverse_sort)
Sets a split register&#39;s reverse sort order based on register.
gboolean do_auto_complete
whether to use auto-completion
gboolean gnc_split_register_save(SplitRegister *reg, gboolean do_commit)
Copy the contents of the current cursor to a split.
void gnc_split_register_collapse_current_trans(SplitRegister *reg)
Mark the current transaction as collapsed, and do callbacks.
void gnc_split_register_destroy(SplitRegister *reg)
Destroys a split register.
void gnc_split_register_unvoid_current_trans(SplitRegister *reg)
Unvoids the transaction associated with the current cursor, if non-NULL.
void gnc_split_register_expand_current_trans(SplitRegister *reg, gboolean expand)
Expand the current transaction if it is collapsed.
The type, style and table for the register.
Transaction * gnc_split_register_get_current_trans(SplitRegister *reg)
Gets the transaction at the current cursor location, which may be on the transaction itself or on any...
STRUCTS.
SplitRegisterTypeGroup gnc_split_register_get_register_group(SplitRegister *reg)
Group registers for common layouts.
void gnc_split_register_delete_current_split(SplitRegister *reg)
Deletes the split associated with the current cursor, if both are non-NULL.
CursorClass gnc_split_register_get_cursor_class(SplitRegister *reg, VirtualCellLocation vcell_loc)
Returns the class of the cursor at the given virtual cell location.
gboolean gnc_split_register_full_refresh_ok(SplitRegister *reg)
Private function – outsiders must not use this.
SRInfo * sr_info
private data; outsiders should not access this
void gnc_split_register_set_template_account(SplitRegister *reg, Account *template_account)
Set the template account for use in a template register.
Table * table
The table itself that implements the underlying GUI.
void gnc_split_register_set_data(SplitRegister *reg, gpointer user_data, SRGetParentCallback get_parent)
Sets the user data and callback hooks for the register.
void gnc_split_register_delete_current_trans(SplitRegister *reg)
Deletes the transaction associated with the current cursor, if both are non-NULL. ...
void gnc_split_register_load(SplitRegister *reg, GList *slist, GList *pre_filter_slist, Account *default_account)
Populates the rows of a register.
SplitRegisterTypeGroup
Register group types.
void gnc_split_register_set_read_only(SplitRegister *reg, gboolean read_only)
Sets whether a register window is "read only".
gboolean gnc_split_register_current_trans_expanded(SplitRegister *reg)
Return TRUE if current trans is expanded and style is REG_STYLE_LEDGER.
GList SplitList
GList of Split.
Definition: gnc-engine.h:207
void gnc_split_register_redraw(SplitRegister *reg)
Causes a redraw of the register window associated with reg.
const char * gnc_split_register_get_debit_string(SplitRegister *reg)
Return the debit string used in the register.
CursorClass
Types of cursors.
void gnc_split_register_cut_current(SplitRegister *reg)
Equivalent to copying the current entity and the deleting it with the appropriate delete method...
gboolean show_leaf_accounts
whether to show full account names
Split * gnc_split_register_get_blank_split(SplitRegister *reg)
Gets the blank split for a register.
gboolean gnc_split_register_changed(SplitRegister *reg)
Returns TRUE if the register has changed cells.
gboolean double_alt_color
whether transaction use alternate colors
void gnc_split_register_config(SplitRegister *reg, SplitRegisterType type, SplitRegisterStyle style, gboolean use_double_line)
Sets a split register&#39;s type, style or line use.
void gnc_split_register_cancel_cursor_split_changes(SplitRegister *reg)
Cancels any changes made to the current cursor, reloads the cursor from the engine, reloads the table from the cursor, and updates the GUI.
gboolean use_tran_num_for_num_field
whether to use transaction number or split action for number field in register
void gnc_split_register_void_current_trans(SplitRegister *reg, const char *reason)
Voids the transaction associated with the current cursor, if non-NULL.
gboolean gnc_split_register_get_split_amount_virt_loc(SplitRegister *reg, Split *split, VirtualLocation *virt_loc)
Searches the split register for the given split and determines the location of either its credit (if ...
gboolean gnc_split_register_is_blank_split(SplitRegister *reg, Split *split)
Return TRUE if split is the blank_split.
Split * gnc_split_register_duplicate_current(SplitRegister *reg)
Duplicates either the current transaction or the current split depending on the register mode and cur...
void gnc_split_register_cancel_cursor_trans_changes(SplitRegister *reg)
Cancels any changes made to the current pending transaction, reloads the table from the engine...
void gnc_split_register_paste_current(SplitRegister *reg)
Pastes a previous copied entity onto the current entity, but only if the copied and current entity ha...
gboolean gnc_split_register_get_split_virt_loc(SplitRegister *reg, Split *split, VirtualCellLocation *vcell_loc)
Searches the split register for a given split.
SplitList * unrecn_splits
list of splits to unreconcile after transaction edit
void gnc_split_register_empty_current_trans_except_split(SplitRegister *reg, Split *split)
Deletes the non-transaction splits associated with the current cursor, if both are non-NULL...
void gnc_split_register_set_auto_complete(SplitRegister *reg, gboolean do_auto_complete)
Sets whether a register uses auto-completion.
Declarations for the Table object.
GtkWidget *(* SRGetParentCallback)(gpointer user_data)
Callback function type.
void gnc_split_register_change_blank_split_ref(SplitRegister *reg, Split *split)
Change the blank_split reference from pointing to split to another split of the transaction.
gboolean gnc_split_register_handle_exchange(SplitRegister *reg, gboolean force_dialog)
Pop up the exchange-rate dialog, maybe, for the current split.
void gnc_split_register_show_present_divider(SplitRegister *reg, gboolean show_present)
If TRUE, visually indicate the demarcation between splits with post dates prior to the present...
SplitRegisterType
Register types.
gboolean mismatched_commodities
indicates the register includes transactions in mismatched commodities
API for Transactions and Splits (journal entries)
Split * gnc_split_register_get_current_split(SplitRegister *reg)
Returns the split at which the cursor is currently located.
SplitRegister * gnc_split_register_new(SplitRegisterType type, SplitRegisterStyle style, gboolean use_double_line, gboolean is_template, gboolean mismatched_commodities)
Creates a new split register.
SplitRegisterStyle
Register styles.
void gnc_split_register_copy_current(SplitRegister *reg)
Makes a copy of the current entity, either a split or a transaction, so that it can be pasted later...