1 /*
2  * gncEntryLedger.h -- a ledger widget for manipulating GncEntry's
3  * Copyright (C) 2001, 2003 Derek Atkins
4  * Author: Derek Atkins <warlord@MIT.EDU>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, contact:
18  *
19  * Free Software Foundation           Voice:  +1-617-542-5942
20  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
21  * Boston, MA  02110-1301,  USA       gnu@gnu.org
22  */
23 
24 #ifndef GNC_ENTRY_LEDGER_H
25 #define GNC_ENTRY_LEDGER_H
26 
27 #include "qof.h"
28 #include "gncEntry.h"
29 #include "gncOrder.h"
30 #include "table-allgui.h"
31 /** @ingroup Register
32  * @addtogroup BusinessRegister Business Register
33  * @brief A specialized register for Accounts Payable and Accounts Receivable.
34  * @{
35  */
36 /** @file gncEntryLedger.h
37  */
38 typedef enum
39 {
40     GNC_ENTRY_ORDER_NONE = -1, //Force clang to use int representation of enum.
41     GNCENTRY_ORDER_ENTRY,
42     GNCENTRY_ORDER_VIEWER,
43     GNCENTRY_INVOICE_ENTRY,
44     GNCENTRY_INVOICE_VIEWER,
45     GNCENTRY_CUST_CREDIT_NOTE_ENTRY,
46     GNCENTRY_CUST_CREDIT_NOTE_VIEWER,
47     GNCENTRY_BILL_ENTRY,
48     GNCENTRY_BILL_VIEWER,
49     GNCENTRY_VEND_CREDIT_NOTE_ENTRY,
50     GNCENTRY_VEND_CREDIT_NOTE_VIEWER,
51     GNCENTRY_EXPVOUCHER_ENTRY,
52     GNCENTRY_EXPVOUCHER_VIEWER,
53     GNCENTRY_EMPL_CREDIT_NOTE_ENTRY,
54     GNCENTRY_EMPL_CREDIT_NOTE_VIEWER,
55     GNCENTRY_NUM_REGISTER_TYPES
56 } GncEntryLedgerType;
57 
58 #define ENTRY_IACCT_CELL	"inv-account"
59 #define ENTRY_BACCT_CELL	"bill-account"
60 #define ENTRY_ACTN_CELL		"action"
61 #define ENTRY_DATE_CELL		"date"
62 #define ENTRY_DESC_CELL		"description"
63 #define ENTRY_DISC_CELL		"discount"
64 #define ENTRY_DISTYPE_CELL	"discount-type"
65 #define ENTRY_DISHOW_CELL	"discount-how"
66 #define ENTRY_PRIC_CELL		"price"
67 #define ENTRY_QTY_CELL		"quantity"
68 #define ENTRY_TAXABLE_CELL	"istaxable"
69 #define ENTRY_TAXTABLE_CELL	"taxtable"
70 #define ENTRY_TAXINCLUDED_CELL	"taxincluded"
71 #define ENTRY_BILLABLE_CELL	"isbillable"
72 
73 #define ENTRY_INV_CELL		"isinvoiced"
74 #define ENTRY_VALUE_CELL	"line-value"
75 #define ENTRY_TAXVAL_CELL	"line-tax-val"
76 
77 #define ENTRY_PAYMENT_CELL	"payment"
78 
79 typedef struct GncEntryLedger_s GncEntryLedger;
80 
81 /* Prototypes ***************************************************/
82 
83 /** Create and return a new GncEntry Ledger */
84 GncEntryLedger * gnc_entry_ledger_new (QofBook *book, GncEntryLedgerType type);
85 
86 /** Set the default order for this ledger */
87 void gnc_entry_ledger_set_default_order (GncEntryLedger *ledger,
88         GncOrder *order);
89 
90 /** Set the default invoice for this ledger */
91 void gnc_entry_ledger_set_default_invoice (GncEntryLedger *ledger,
92         GncInvoice *invoice);
93 
94 /** Destroy the GncEntry Ledger */
95 void gnc_entry_ledger_destroy (GncEntryLedger *ledger);
96 
97 /** Returns the Entry where the cursor is currently located. */
98 GncEntry * gnc_entry_ledger_get_current_entry (GncEntryLedger *ledger);
99 
100 /** Copy GncEntry information from the list to the rows of the Ledger. */
101 void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list);
102 
103 void gnc_entry_ledger_display_refresh (GncEntryLedger *ledger);
104 
105 /** Get the Table */
106 Table * gnc_entry_ledger_get_table (GncEntryLedger *ledger);
107 
108 void gnc_entry_ledger_set_parent (GncEntryLedger *ledger, GtkWidget *parent);
109 
110 void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger, gboolean readonly);
111 
112 gboolean gnc_entry_ledger_changed (GncEntryLedger *ledger);
113 
114 void gnc_entry_ledger_cancel_cursor_changes (GncEntryLedger *ledger);
115 
116 /** This will act just like hitting 'return' to record an entry */
117 gboolean gnc_entry_ledger_commit_entry (GncEntryLedger *ledger);
118 
119 /** This will ask the user if they really want to make a change */
120 gboolean gnc_entry_ledger_check_close (GtkWidget *parent, GncEntryLedger *ledger);
121 
122 void gnc_entry_ledger_reset_query (GncEntryLedger *ledger);
123 
124 /** Returns the GncEntry at the given location, or NULL if the
125  * location is not valid. */
126 GncEntry * gnc_entry_ledger_get_entry (GncEntryLedger *ledger,
127                                        VirtualCellLocation vcell_loc);
128 
129 /** Returns the GncEntry that represents the blank new line at the
130  * bottom of the ledger */
131 GncEntry * gnc_entry_ledger_get_blank_entry (GncEntryLedger *ledger);
132 
133 /** Looks up the cell location of the given "entry" and writes the
134  * location into the variable pointed to by vcell_loc (which must be
135  * non-NULL). Returns TRUE if the entry was found, otherwise FALSE. */
136 gboolean gnc_entry_ledger_get_entry_virt_loc (GncEntryLedger *ledger,
137         const GncEntry *entry,
138         VirtualCellLocation *vcell_loc);
139 
140 void gnc_entry_ledger_delete_current_entry (GncEntryLedger *ledger);
141 void gnc_entry_ledger_duplicate_current_entry (GncEntryLedger *ledger);
142 
143 /** This implements the command of moving the current entry (where the
144  * cursor is currently located) one row upwards or downwards,
145  * effectively swapping this row and the other row. If the other row
146  * is empty (or it is the blank entry), nothing will happen.
147  *
148  * \param move_up If TRUE, the current entry is moved upwards,
149  * otherwise downwards. */
150 void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
151         gboolean move_up);
152 
153 QofQuery * gnc_entry_ledger_get_query (GncEntryLedger *ledger);
154 
155 void gnc_entry_ledger_set_prefs_group (GncEntryLedger *ledger, const gchar *string);
156 /** @} */
157 #endif /* GNC_ENTRY_LEDGER_H */
158