GnuCash  4.8a-80-g9825132ea+
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 /* --- type macros --- */
78 #define GNC_TYPE_BUDGET (gnc_budget_get_type ())
79 #define GNC_BUDGET(o) \
80  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))
81 #define GNC_BUDGET_CLASS(k) \
82  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))
83 #define GNC_IS_BUDGET(o) \
84  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))
85 #define GNC_IS_BUDGET_CLASS(k) \
86  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))
87 #define GNC_BUDGET_GET_CLASS(o) \
88  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))
89 GType gnc_budget_get_type(void);
90 
91 #define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS 3 // max num periods == 999
92 
93 #define GNC_BUDGET_NOTES_PATH "notes"
94 
95 gboolean gnc_budget_register(void);
96 
100 /*@ dependent @*/
101 GncBudget *gnc_budget_new(QofBook *book);
102 
104 void gnc_budget_destroy(GncBudget* budget);
105 
106 void gnc_budget_begin_edit(GncBudget *bgt);
107 void gnc_budget_commit_edit(GncBudget *bgt);
108 
110 GncBudget *gnc_budget_clone(const GncBudget* budget);
111 
112 /*@ dependent @*/
113 const GncGUID* gnc_budget_get_guid(const GncBudget* budget);
114 #define gnc_budget_return_guid(X) \
115  (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
116 
118 void gnc_budget_set_name(GncBudget* budget, const gchar* name);
119 /*@ dependent @*/
120 const gchar* gnc_budget_get_name(const GncBudget* budget);
121 
123 void gnc_budget_set_description(GncBudget* budget, const gchar* description);
124 /*@ dependent @*/
125 const gchar* gnc_budget_get_description(const GncBudget* budget);
126 
128 void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods);
129 guint gnc_budget_get_num_periods(const GncBudget* budget);
130 
131 void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
132 /*@ dependent @*/
133 const Recurrence * gnc_budget_get_recurrence(const GncBudget *budget);
134 
136 time64 gnc_budget_get_period_start_date(const GncBudget* budget, guint period_num);
137 
139 time64 gnc_budget_get_period_end_date(const GncBudget* budget, guint period_num);
140 
141 /* Period indices are zero-based. */
142 void gnc_budget_set_account_period_value(
143  GncBudget* budget, const Account* account, guint period_num, gnc_numeric val);
144 void gnc_budget_unset_account_period_value(
145  GncBudget* budget, const Account* account, guint period_num);
146 
147 gboolean gnc_budget_is_account_period_value_set(
148  const GncBudget *budget, const Account *account, guint period_num);
149 
150 /* get the budget account period's budgeted value */
151 gnc_numeric gnc_budget_get_account_period_value(
152  const GncBudget *budget, const Account *account, guint period_num);
153 
154 /* get the budget account period's actual value, including children,
155  excluding closing entries */
156 gnc_numeric gnc_budget_get_account_period_actual_value(
157  const GncBudget *budget, Account *account, guint period_num);
158 
159 /* get/set the budget account period's note, beware when retrieving
160  the period note, the latter must be g_freed by the caller */
161 void gnc_budget_set_account_period_note(GncBudget *budget,
162  const Account *account, guint period_num, const gchar *note);
163 gchar *gnc_budget_get_account_period_note (const GncBudget *budget,
164  const Account *account, guint period_num);
165 
166 /* Returns some budget in the book, or NULL. */
167 GncBudget* gnc_budget_get_default(QofBook *book);
168 
169 /* Get the budget associated with the given GncGUID from the given book. */
170 /*@ dependent @*/
171 GncBudget* gnc_budget_lookup (const GncGUID *guid, const QofBook *book);
172 #define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b))
173 
174 #endif // __BUDGET_H__
175 
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
Set/Get the number of periods in the Budget.
Definition: gnc-budget.c:450
void gnc_budget_destroy(GncBudget *budget)
Deletes the given budget object.
Definition: gnc-budget.c:304
GncBudget * gnc_budget_new(QofBook *book)
Creates and initializes a Budget.
Definition: gnc-budget.c:287
Account handling public routines.
The budget data.
Definition: gnc-budget.c: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.c:654
GncBudget * gnc_budget_clone(const GncBudget *budget)
Clones a budget creating a copy.
Definition: gnc-budget.c:338
void gnc_budget_set_name(GncBudget *budget, const gchar *name)
Set/Get the name of the Budget.
Definition: gnc-budget.c:369
void gnc_budget_set_description(GncBudget *budget, const gchar *description)
Set/Get the description of the Budget.
Definition: gnc-budget.c:394
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93
time64 gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
Get the ending date of the Budget period.
Definition: gnc-budget.c:661
The type used to store guids in C.
Definition: guid.h:75