GnuCash  5.6-150-g038405b370+
gnc-budget.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-budget.h -- Budget public handling routines. *
3  * Copyright (C) 04 sep 2003 Darin Willits <darin@willits.ca> *
4  * Copyright (C) 2005 Chris Shoemaker <c.shoemaker@cox.net> *
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 
64 #ifndef __GNC_BUDGET_H__
65 #define __GNC_BUDGET_H__
66 
67 #include <glib.h>
68 
70 typedef struct budget_s GncBudget;
71 typedef struct _GncBudgetClass GncBudgetClass;
72 
73 #include "qof.h"
74 #include "Account.h"
75 #include "Recurrence.h"
76 
77 #ifdef __cplusplus
78 extern "C"
79 {
80 #endif
81 
82 /* --- type macros --- */
83 #define GNC_TYPE_BUDGET (gnc_budget_get_type ())
84 #define GNC_BUDGET(o) \
85  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))
86 #define GNC_BUDGET_CLASS(k) \
87  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))
88 #define GNC_IS_BUDGET(o) \
89  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))
90 #define GNC_IS_BUDGET_CLASS(k) \
91  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))
92 #define GNC_BUDGET_GET_CLASS(o) \
93  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))
94 GType gnc_budget_get_type(void);
95 
96 #define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS 3 // max num periods == 999
97 
98 #define GNC_BUDGET_NOTES_PATH "notes"
99 
100 gboolean gnc_budget_register(void);
101 
105 /*@ dependent @*/
106 GncBudget *gnc_budget_new(QofBook *book);
107 
109 void gnc_budget_destroy(GncBudget* budget);
110 
111 void gnc_budget_begin_edit(GncBudget *bgt);
112 void gnc_budget_commit_edit(GncBudget *bgt);
113 
115 GncBudget *gnc_budget_clone(const GncBudget* budget);
116 
117 /*@ dependent @*/
118 const GncGUID* gnc_budget_get_guid(const GncBudget* budget);
119 #define gnc_budget_return_guid(X) \
120  (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
121 
123 void gnc_budget_set_name(GncBudget* budget, const gchar* name);
124 /*@ dependent @*/
125 const gchar* gnc_budget_get_name(const GncBudget* budget);
126 
128 void gnc_budget_set_description(GncBudget* budget, const gchar* description);
129 /*@ dependent @*/
130 const gchar* gnc_budget_get_description(const GncBudget* budget);
131 
133 void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods);
134 guint gnc_budget_get_num_periods(const GncBudget* budget);
135 
136 void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
137 /*@ dependent @*/
138 const Recurrence * gnc_budget_get_recurrence(const GncBudget *budget);
139 
141 time64 gnc_budget_get_period_start_date(const GncBudget* budget, guint period_num);
142 
144 time64 gnc_budget_get_period_end_date(const GncBudget* budget, guint period_num);
145 
146 /* Period indices are zero-based. */
147 void gnc_budget_set_account_period_value(
148  GncBudget* budget, const Account* account, guint period_num, gnc_numeric val);
149 void gnc_budget_unset_account_period_value(
150  GncBudget* budget, const Account* account, guint period_num);
151 
152 gboolean gnc_budget_is_account_period_value_set(
153  const GncBudget *budget, const Account *account, guint period_num);
154 
155 /* get the budget account period's budgeted value */
156 gnc_numeric gnc_budget_get_account_period_value(
157  const GncBudget *budget, const Account *account, guint period_num);
158 
159 /* get the budget account period's actual value, including children,
160  excluding closing entries */
161 gnc_numeric gnc_budget_get_account_period_actual_value(
162  const GncBudget *budget, Account *account, guint period_num);
163 
164 /* get/set the budget account period's note */
165 void gnc_budget_set_account_period_note(GncBudget *budget,
166  const Account *account, guint period_num, const gchar *note);
167 const gchar *gnc_budget_get_account_period_note (const GncBudget *budget,
168  const Account *account, guint period_num);
169 
170 /* Returns some budget in the book, or NULL. */
171 GncBudget* gnc_budget_get_default(QofBook *book);
172 
173 /* Get the budget associated with the given GncGUID from the given book. */
174 /*@ dependent @*/
175 GncBudget* gnc_budget_lookup (const GncGUID *guid, const QofBook *book);
176 #define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b))
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 
183 #endif // __BUDGET_H__
184 
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
Set/Get the number of periods in the Budget.
Definition: gnc-budget.cpp:467
void gnc_budget_destroy(GncBudget *budget)
Deletes the given budget object.
Definition: gnc-budget.cpp:321
STRUCTS.
GncBudget * gnc_budget_new(QofBook *book)
Creates and initializes a Budget.
Definition: gnc-budget.cpp:305
Account handling public routines.
The budget data.
Definition: gnc-budget.cpp:51
time64 gnc_budget_get_period_start_date(const GncBudget *budget, guint period_num)
Get the starting date of the Budget period.
Definition: gnc-budget.cpp:648
GncBudget * gnc_budget_clone(const GncBudget *budget)
Clones a budget creating a copy.
Definition: gnc-budget.cpp:355
void gnc_budget_set_name(GncBudget *budget, const gchar *name)
Set/Get the name of the Budget.
Definition: gnc-budget.cpp:386
void gnc_budget_set_description(GncBudget *budget, const gchar *description)
Set/Get the description of the Budget.
Definition: gnc-budget.cpp:411
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
time64 gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
Get the ending date of the Budget period.
Definition: gnc-budget.cpp:655
The type used to store guids in C.
Definition: guid.h:75