GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 <[email protected]> *
4  * Copyright (C) 2005 Chris Shoemaker <[email protected]> *
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 [email protected] *
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 gboolean gnc_budget_register(void);
94 
98 /*@ dependent @*/
100 
102 void gnc_budget_destroy(GncBudget* budget);
103 
104 void gnc_budget_begin_edit(GncBudget *bgt);
105 void gnc_budget_commit_edit(GncBudget *bgt);
106 
108 GncBudget *gnc_budget_clone(const GncBudget* budget);
109 
110 /*@ dependent @*/
111 const GncGUID* gnc_budget_get_guid(const GncBudget* budget);
112 #define gnc_budget_return_guid(X) \
113  (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
114 
116 void gnc_budget_set_name(GncBudget* budget, const gchar* name);
117 /*@ dependent @*/
118 const gchar* gnc_budget_get_name(const GncBudget* budget);
119 
121 void gnc_budget_set_description(GncBudget* budget, const gchar* description);
122 /*@ dependent @*/
123 const gchar* gnc_budget_get_description(const GncBudget* budget);
124 
126 void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods);
127 guint gnc_budget_get_num_periods(const GncBudget* budget);
128 
129 void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
130 /*@ dependent @*/
131 const Recurrence * gnc_budget_get_recurrence(const GncBudget *budget);
132 
134 Timespec gnc_budget_get_period_start_date(const GncBudget* budget, guint period_num);
135 
137 Timespec gnc_budget_get_period_end_date(const GncBudget* budget, guint period_num);
138 
139 /* Period indices are zero-based. */
140 void gnc_budget_set_account_period_value(
141  GncBudget* budget, const Account* account, guint period_num, gnc_numeric val);
142 void gnc_budget_unset_account_period_value(
143  GncBudget* budget, const Account* account, guint period_num);
144 
145 gboolean gnc_budget_is_account_period_value_set(
146  const GncBudget *budget, const Account *account, guint period_num);
147 
148 gnc_numeric gnc_budget_get_account_period_value(
149  const GncBudget *budget, const Account *account, guint period_num);
150 gnc_numeric gnc_budget_get_account_period_actual_value(
151  const GncBudget *budget, Account *account, guint period_num);
152 
153 /* Returns some budget in the book, or NULL. */
154 GncBudget* gnc_budget_get_default(QofBook *book);
155 
156 /* Get the budget associated with the given GncGUID from the given book. */
157 /*@ dependent @*/
158 GncBudget* gnc_budget_lookup (const GncGUID *guid, const QofBook *book);
159 #define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b))
160 
161 #endif // __BUDGET_H__
162 
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
Definition: gnc-budget.c:452
void gnc_budget_destroy(GncBudget *budget)
Definition: gnc-budget.c:306
Timespec gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
Definition: gnc-budget.c:595
GncBudget * gnc_budget_new(QofBook *book)
Definition: gnc-budget.c:289
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
Definition: guid.h:65
Timespec gnc_budget_get_period_start_date(const GncBudget *budget, guint period_num)
Definition: gnc-budget.c:584
Account handling public routines.
GncBudget * gnc_budget_clone(const GncBudget *budget)
Definition: gnc-budget.c:340
void gnc_budget_set_name(GncBudget *budget, const gchar *name)
Definition: gnc-budget.c:371
void gnc_budget_set_description(GncBudget *budget, const gchar *description)
Definition: gnc-budget.c:396