GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Budgets

Files

file  gnc-budget.h
 GnuCash Budgets.
 
file  gnc-budget-view.h
 
file  gnc-plugin-page-budget.h
 
file  gnc-tree-model-budget.h
 provides some utilities for working with the list of budgets in a book.
 

Data Structures

struct  GncPluginPageBudget
 
struct  GncPluginPageBudgetClass
 

Macros

#define GNC_TYPE_BUDGET   (gnc_budget_get_type ())
 
#define GNC_BUDGET(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))
 
#define GNC_BUDGET_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))
 
#define GNC_IS_BUDGET(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))
 
#define GNC_IS_BUDGET_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))
 
#define GNC_BUDGET_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))
 
#define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS   3
 
#define gnc_budget_return_guid(X)   (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
 
#define gnc_budget_lookup_direct(g, b)   gnc_budget_lookup(&(g),(b))
 
#define GNC_TYPE_BUDGET_VIEW   (gnc_budget_view_get_type ())
 
#define GNC_BUDGET_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetView))
 
#define GNC_BUDGET_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))
 
#define GNC_IS_BUDGET_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_BUDGET_VIEW))
 
#define GNC_IS_BUDGET_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_BUDGET_VIEW))
 
#define GNC_BUDGET_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))
 
#define GNC_BUDGET_VIEW_NAME   "GncBudgetView"
 
#define GNC_TYPE_PLUGIN_PAGE_BUDGET   (gnc_plugin_page_budget_get_type ())
 
#define GNC_PLUGIN_PAGE_BUDGET(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudget))
 
#define GNC_PLUGIN_PAGE_BUDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))
 
#define GNC_IS_PLUGIN_PAGE_BUDGET(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET))
 
#define GNC_IS_PLUGIN_PAGE_BUDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET))
 
#define GNC_PLUGIN_PAGE_BUDGET_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))
 
#define GNC_PLUGIN_PAGE_BUDGET_NAME   "GncPluginPageBudget"
 

Typedefs

typedef struct budget_s GncBudget
 
typedef struct _GncBudgetClass GncBudgetClass
 
typedef struct _GncBudgetView GncBudgetView
 
typedef struct _GncBudgetViewClass GncBudgetViewClass
 

Enumerations

enum  { BUDGET_GUID_COLUMN, BUDGET_NAME_COLUMN, BUDGET_DESCRIPTION_COLUMN, BUDGET_LIST_NUM_COLS }
 

Functions

GType gnc_budget_get_type (void)
 
gboolean gnc_budget_register (void)
 
GncBudgetgnc_budget_new (QofBook *book)
 
void gnc_budget_destroy (GncBudget *budget)
 
void gnc_budget_begin_edit (GncBudget *bgt)
 
void gnc_budget_commit_edit (GncBudget *bgt)
 
GncBudgetgnc_budget_clone (const GncBudget *budget)
 
const GncGUIDgnc_budget_get_guid (const GncBudget *budget)
 
void gnc_budget_set_name (GncBudget *budget, const gchar *name)
 
const gchar * gnc_budget_get_name (const GncBudget *budget)
 
void gnc_budget_set_description (GncBudget *budget, const gchar *description)
 
const gchar * gnc_budget_get_description (const GncBudget *budget)
 
void gnc_budget_set_num_periods (GncBudget *budget, guint num_periods)
 
guint gnc_budget_get_num_periods (const GncBudget *budget)
 
void gnc_budget_set_recurrence (GncBudget *budget, const Recurrence *r)
 
const Recurrencegnc_budget_get_recurrence (const GncBudget *budget)
 
Timespec gnc_budget_get_period_start_date (const GncBudget *budget, guint period_num)
 
Timespec gnc_budget_get_period_end_date (const GncBudget *budget, guint period_num)
 
void gnc_budget_set_account_period_value (GncBudget *budget, const Account *account, guint period_num, gnc_numeric val)
 
void gnc_budget_unset_account_period_value (GncBudget *budget, const Account *account, guint period_num)
 
gboolean gnc_budget_is_account_period_value_set (const GncBudget *budget, const Account *account, guint period_num)
 
gnc_numeric gnc_budget_get_account_period_value (const GncBudget *budget, const Account *account, guint period_num)
 
gnc_numeric gnc_budget_get_account_period_actual_value (const GncBudget *budget, Account *account, guint period_num)
 
GncBudgetgnc_budget_get_default (QofBook *book)
 
GncBudgetgnc_budget_lookup (const GncGUID *guid, const QofBook *book)
 
GType gnc_budget_view_get_type (void)
 
GncBudgetViewgnc_budget_view_new (GncBudget *budget, AccountFilterDialog *fd)
 
void gnc_budget_view_save (GncBudgetView *view, GKeyFile *key_file, const gchar *group_name)
 
void gnc_budget_view_refresh (GncBudgetView *view)
 
void gnc_budget_view_delete_budget (GncBudgetView *view)
 
gboolean gnc_budget_view_restore (GncBudgetView *view, GKeyFile *key_file, const gchar *group_name)
 
GtkTreeSelection * gnc_budget_view_get_selection (GncBudgetView *view)
 
Accountgnc_budget_view_get_account_from_path (GncBudgetView *view, GtkTreePath *path)
 
GList * gnc_budget_view_get_selected_accounts (GncBudgetView *view)
 
GType gnc_plugin_page_budget_get_type (void)
 
GncPluginPagegnc_plugin_page_budget_new (GncBudget *budget)
 
void gnc_budget_gui_delete_budget (GncBudget *budget)
 
GtkTreeModel * gnc_tree_model_budget_new (QofBook *book)
 
void gnc_tree_view_budget_set_model (GtkTreeView *tv, GtkTreeModel *tm)
 
GncBudgetgnc_tree_model_budget_get_budget (GtkTreeModel *tm, GtkTreeIter *iter)
 
gboolean gnc_tree_model_budget_get_iter_for_budget (GtkTreeModel *tm, GtkTreeIter *iter, GncBudget *bgt)
 

Detailed Description

Typedef Documentation

typedef struct budget_s GncBudget

The budget data.

Definition at line 70 of file gnc-budget.h.

Enumeration Type Documentation

anonymous enum
Todo:
This file is poorly named, since it covers both model and view.

Definition at line 38 of file gnc-tree-model-budget.h.

39 {
40  BUDGET_GUID_COLUMN,
41  BUDGET_NAME_COLUMN,
42  BUDGET_DESCRIPTION_COLUMN,
43  BUDGET_LIST_NUM_COLS
44 };

Function Documentation

GncBudget* gnc_budget_clone ( const GncBudget budget)

Clones a budget creating a copy

Definition at line 340 of file gnc-budget.c.

341 {
342  GncBudget* new_b;
343  Account* root;
344  CloneBudgetData_t clone_data;
345 
346  g_return_val_if_fail(old_b != NULL, NULL);
347 
348  ENTER(" ");
349 
350  new_b = gnc_budget_new(qof_instance_get_book(old_b));
351  gnc_budget_begin_edit(new_b);
352  gnc_budget_set_name(new_b, gnc_budget_get_name(old_b));
353  gnc_budget_set_description(new_b, gnc_budget_get_description(old_b));
354  gnc_budget_set_recurrence(new_b, gnc_budget_get_recurrence(old_b));
355  gnc_budget_set_num_periods(new_b, gnc_budget_get_num_periods(old_b));
356 
357  root = gnc_book_get_root_account(qof_instance_get_book(old_b));
358  clone_data.old_b = old_b;
359  clone_data.new_b = new_b;
360  clone_data.num_periods = gnc_budget_get_num_periods(new_b);
361  gnc_account_foreach_descendant(root, clone_budget_values_cb, &clone_data);
362 
363  gnc_budget_commit_edit(new_b);
364 
365  LEAVE(" ");
366 
367  return new_b;
368 }
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
Definition: gnc-budget.c:452
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
Definition: Account.c:2958
QofBook * qof_instance_get_book(gconstpointer)
GncBudget * gnc_budget_new(QofBook *book)
Definition: gnc-budget.c:289
#define ENTER(format, args...)
Definition: qoflog.h:261
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
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_budget_destroy ( GncBudget budget)

Deletes the given budget object.

Definition at line 306 of file gnc-budget.c.

307 {
308  g_return_if_fail(GNC_IS_BUDGET(budget));
309  gnc_budget_begin_edit(budget);
310  qof_instance_set_dirty(&budget->inst);
311  qof_instance_set_destroying(budget, TRUE);
312  gnc_budget_commit_edit(budget);
313 }
Timespec gnc_budget_get_period_end_date ( const GncBudget budget,
guint  period_num 
)

Get the ending date of the Budget period

Definition at line 595 of file gnc-budget.c.

596 {
597  Timespec ts = {0, 0};
598  g_return_val_if_fail (GNC_IS_BUDGET(budget), ts);
600  &ts, recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, TRUE));
601  return ts;
602 }
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void timespecFromTime64(Timespec *ts, time64 t)
Timespec gnc_budget_get_period_start_date ( const GncBudget budget,
guint  period_num 
)

Get the starting date of the Budget period

Definition at line 584 of file gnc-budget.c.

585 {
586  Timespec ts = {0, 0};
587  g_return_val_if_fail (GNC_IS_BUDGET(budget), ts);
589  &ts, recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence,
590  period_num, FALSE));
591  return ts;
592 }
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void timespecFromTime64(Timespec *ts, time64 t)
GncBudget* gnc_budget_new ( QofBook book)

Creates and initializes a Budget.

Definition at line 289 of file gnc-budget.c.

290 {
291  GncBudget* budget;
292 
293  g_return_val_if_fail(book, NULL);
294 
295  ENTER(" ");
296  budget = g_object_new(GNC_TYPE_BUDGET, NULL);
297  qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book);
298 
299  qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL);
300 
301  LEAVE(" ");
302  return budget;
303 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void qof_instance_init_data(QofInstance *, QofIdType, QofBook *)
#define LEAVE(format, args...)
Definition: qoflog.h:271
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
void gnc_budget_set_description ( GncBudget budget,
const gchar *  description 
)

Set/Get the description of the Budget

Definition at line 396 of file gnc-budget.c.

397 {
398  BudgetPrivate* priv;
399 
400  g_return_if_fail(GNC_IS_BUDGET(budget));
401  g_return_if_fail(description);
402 
403  priv = GET_PRIVATE(budget);
404  if ( description == priv->description ) return;
405  gnc_budget_begin_edit(budget);
406  CACHE_REPLACE(priv->description, description);
407  qof_instance_set_dirty(&budget->inst);
408  gnc_budget_commit_edit(budget);
409 
410  qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL);
411 }
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
void gnc_budget_set_name ( GncBudget budget,
const gchar *  name 
)

Set/Get the name of the Budget

Definition at line 371 of file gnc-budget.c.

372 {
373  BudgetPrivate* priv;
374 
375  g_return_if_fail(GNC_IS_BUDGET(budget) && name);
376 
377  priv = GET_PRIVATE(budget);
378  if ( name == priv->name ) return;
379 
380  gnc_budget_begin_edit(budget);
381  CACHE_REPLACE(priv->name, name);
382  qof_instance_set_dirty(&budget->inst);
383  gnc_budget_commit_edit(budget);
384 
385  qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL);
386 }
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
void gnc_budget_set_num_periods ( GncBudget budget,
guint  num_periods 
)

Set/Get the number of periods in the Budget

Definition at line 452 of file gnc-budget.c.

453 {
454  BudgetPrivate* priv;
455 
456  g_return_if_fail(GNC_IS_BUDGET(budget));
457 
458  priv = GET_PRIVATE(budget);
459  if ( priv->num_periods == num_periods ) return;
460 
461  gnc_budget_begin_edit(budget);
462  priv->num_periods = num_periods;
463  qof_instance_set_dirty(&budget->inst);
464  gnc_budget_commit_edit(budget);
465 
466  qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL);
467 }
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
GncBudgetView* gnc_budget_view_new ( GncBudget budget,
AccountFilterDialog fd 
)

Create a new "budget" display widget.

Returns
The newly created widget

Definition at line 144 of file gnc-budget-view.c.

145 {
146  GncBudgetView *budget_view;
147  GncBudgetViewPrivate *priv;
148  gchar* label;
149  const GList *item;
150 
151  g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
152  ENTER(" ");
153 
154  budget_view = g_object_new(GNC_TYPE_BUDGET_VIEW, NULL);
155 
156  priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
157  priv->budget = budget;
158  priv->key = *gnc_budget_get_guid(budget);
159  priv->fd = fd;
160  priv->total_col = NULL;
161  gbv_create_widget(budget_view);
162 
163  LEAVE("new budget view %p", budget_view);
164  return budget_view;
165 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
GncPluginPage* gnc_plugin_page_budget_new ( GncBudget budget)

Create a new "budget" plugin page.

Returns
The newly created plugin page.

Definition at line 243 of file gnc-plugin-page-budget.c.

244 {
245  GncPluginPageBudget *plugin_page;
247  gchar* label;
248  const GList *item;
249 
250  g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
251  ENTER(" ");
252 
253  /* Is there an existing page? */
254  item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_BUDGET_NAME);
255  for ( ; item; item = g_list_next(item))
256  {
257  plugin_page = (GncPluginPageBudget *)item->data;
258  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
259  if (priv->budget == budget)
260  {
261  LEAVE("existing budget page %p", plugin_page);
262  return GNC_PLUGIN_PAGE(plugin_page);
263  }
264  }
265 
266  plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_BUDGET, NULL);
267 
268  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
269  priv->budget = budget;
270  priv->delete_budget = FALSE;
271  priv->key = *gnc_budget_get_guid(budget);
272  label = g_strdup_printf("%s: %s", _("Budget"), gnc_budget_get_name(budget));
273  g_object_set(G_OBJECT(plugin_page), "page-name", label, NULL);
274  g_free(label);
275  LEAVE("new budget page %p", plugin_page);
276  return GNC_PLUGIN_PAGE(plugin_page);
277 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271