GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
assistant-acct-period.c
1 /********************************************************************\
2  * assistant-acct-period.c - accouting period assistant for GnuCash *
3  * Copyright (C) 2001 Gnumatic, Inc. *
4  * Copyright (C) 2001 Dave Peticolas <[email protected]> *
5  * Copyright (C) 2003 Linas Vepstas <[email protected]> *
6  * Copyright (C) 2011 Robert Fewell *
7  * *
8  * This program is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License as *
10  * published by the Free Software Foundation; either version 2 of *
11  * the License, or (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License*
19  * along with this program; if not, contact: *
20  * *
21  * Free Software Foundation Voice: +1-617-542-5942 *
22  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
23  * Boston, MA 02110-1301, USA [email protected] *
24 \********************************************************************/
25 /*************************************************************************\
26  * This is still a work in progress so may damage your data, to enable *
27  * for testing do the following :- *
28  * Add a define entry to gnc-plugin-basic-commands.c as below *
29  * #define CLOSE_BOOKS_ACTUALLY_WORKS *
30  * *
31  * Add the following to gnc-plugin-basic-commands-ui.xml on line 43 *
32  * <menuitem name="ActionsCloseBooks" action="ActionsCloseBooksAction"/> *
33 \*************************************************************************/
34 
35 #include "config.h"
36 
37 #include <gtk/gtk.h>
38 #include <glib/gi18n.h>
39 
40 #include "Recurrence.h"
41 #include "Query.h"
42 #include "Scrub.h"
43 #include "Transaction.h"
44 #include "dialog-utils.h"
45 #include "assistant-acct-period.h"
46 #include "assistant-utils.h"
47 #include "gnc-component-manager.h"
48 #include "qof.h"
49 #include "gnc-file.h"
50 #include "gnc-frequency.h"
51 #include "gnc-gdate-utils.h"
52 #include "gnc-gui-query.h"
53 #include "gnc-ui-util.h"
54 #include "misc-gnome-utils.h"
55 #include "gnc-session.h"
56 
57 #define ASSISTANT_ACCT_PERIOD_CM_CLASS "assistant-acct-period"
58 
59 static QofLogModule log_module = GNC_MOD_ASSISTANT;
60 
62 typedef struct
63 {
64  GtkWidget * window;
65  GtkWidget * assistant;
66  GncFrequency *period_menu;
67  GtkWidget * period_remarks;
68  GtkWidget * close_results;
69  GtkWidget * book_details;
70  GtkWidget * book_title;
71  GtkTextView * book_notes;
72  GtkWidget * apply_label;
73  GtkWidget * summary;
74 
75  time64 earliest;
76  char * earliest_str;
77  GDate closing_date;
78  GDate prev_closing_date;
79  GList *period;
80  int close_status;
81 
83 
84 /* =============================================================== */
85 
86 void ap_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
87  gpointer user_data);
88 void ap_assistant_menu_prepare (GtkAssistant *assistant, gpointer user_data);
89 void ap_assistant_book_prepare (GtkAssistant *assistant, gpointer user_data);
90 void ap_assistant_apply_prepare (GtkAssistant *assistant, gpointer user_data);
91 void ap_assistant_summary_prepare (GtkAssistant *assistant, gpointer user_data);
92 
93 gboolean ap_validate_menu (GtkAssistant *assistant, gpointer user_data);
94 
95 void ap_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
96 void ap_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
97 void ap_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
98 
99 /* =============================================================== */
100 /* Find the earliest date occuring in the book. Do this by making
101  * a query and sorting by date. Since the truncated sort returns
102  * only the *last* search results, sort in decreasing order.
103  */
104 static time64
105 get_earliest_in_book (QofBook *book)
106 {
107  QofQuery *q;
108  GSList *p1, *p2;
109  GList *res;
110  time64 earliest;
111 
112  q = qof_query_create_for(GNC_ID_SPLIT);
114  qof_query_set_book (q, book);
115 
116  /* Sort by transaction date */
117  p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
118  p1 = g_slist_prepend (p1, SPLIT_TRANS);
119  p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
120  qof_query_set_sort_order (q, p1, p2, NULL);
121 
122  /* Reverse the sort order */
123  qof_query_set_sort_increasing (q, FALSE, FALSE, FALSE);
124 
125  /* Run the query, find the earliest transaction date */
126  res = qof_query_run (q);
127 
128  if (res)
129  {
130  earliest = xaccQueryGetEarliestDateFound (q);
131  }
132  else
133  {
134  /* If no results, we don't want to bomb totally */
135  earliest = gnc_time (NULL);
136  }
137 
138  qof_query_destroy (q);
139  return earliest;
140 }
141 
142 /* =============================================================== */
143 /* Find the number of transactions occuring before the indicated date.
144  * Do this by making a query and counting the results.
145  */
146 
147 static int
148 get_num_xactions_before_date(QofBook *book, time64 close_date)
149 {
150  QofQuery *q;
151  GSList *param;
152  QofQueryPredData *pred;
153  Timespec ts;
154  GList *res, *n;
155  int cnt = 0;
156 
157  q = qof_query_create_for(GNC_ID_TRANS);
159  qof_query_set_book (q, book);
160 
161  /* Look for transactions earlier than the closing date */
162  param = g_slist_prepend (NULL, TRANS_DATE_POSTED);
163  timespecFromTime64 (&ts, close_date);
164  pred = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ts);
165  qof_query_add_term (q, param, pred, QOF_QUERY_FIRST_TERM);
166 
167  /* Run the query, find how many transactions there are */
168  res = qof_query_run (q);
169 
170  cnt = 0;
171  for (n = res; n; n = n->next) cnt ++;
172 
173  qof_query_destroy (q);
174  return cnt;
175 }
176 
177 /* =============================================================== */
178 
179 static const char *
180 get_close_status_str (AcctPeriodInfo *info)
181 {
182  const char * str;
183 
184  /* Tell user about how the previous book closing went. */
185  switch (info->close_status)
186  {
187  case -1:
188  str = "";
189  break;
190  case 0:
191  str = _("The book was closed successfully.");
192  break;
193  default:
194  str = "";
195  break;
196  }
197  return str;
198 }
199 
200 /* =============================================================== */
201 
202 static void
203 ap_assistant_destroy_cb (GtkObject *object, gpointer data)
204 {
205  AcctPeriodInfo *info = data;
206 
207  gnc_unregister_gui_component_by_data (ASSISTANT_ACCT_PERIOD_CM_CLASS, info);
208 
209  // do we need gnc_frequency_destroy or is this automatic ??
210  recurrenceListFree(&info->period);
211  g_free (info->earliest_str);
212  g_free (info);
213 }
214 
215 /* =============================================================== */
216 
217 void
218 ap_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
219 {
220  AcctPeriodInfo *info = user_data;
221  gnc_close_gui_component_by_data (ASSISTANT_ACCT_PERIOD_CM_CLASS, info);
222 }
223 
224 /* =============================================================== */
225 
226 void
227 ap_assistant_close (GtkAssistant *assistant, gpointer user_data)
228 {
229  AcctPeriodInfo *info = user_data;
230  gnc_close_gui_component_by_data (ASSISTANT_ACCT_PERIOD_CM_CLASS, info);
231 }
232 
233 /* =============================================================== */
234 
235 void
236 ap_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
237  gpointer user_data)
238 {
239  gint currentpage = gtk_assistant_get_current_page(assistant);
240 
241  switch (currentpage)
242  {
243  case 1:
244  /* Current page is Menu page */
245  ap_assistant_menu_prepare(assistant, user_data);
246  break;
247  case 2:
248  /* Current page is Book page */
249  ap_assistant_book_prepare (assistant, user_data);
250  break;
251  case 3:
252  /* Current page is Apply page */
253  ap_assistant_apply_prepare (assistant, user_data);
254  break;
255  case 4:
256  /* Current page is Summary page */
257  ap_assistant_summary_prepare (assistant, user_data);
258  break;
259  }
260 }
261 
262 /* =============================================================== */
263 
264 void
265 ap_assistant_menu_prepare (GtkAssistant *assistant, gpointer user_data)
266 {
267  int nperiods;
268  GDate period_begin, period_end, date_now;
269  char * str;
270 
271  AcctPeriodInfo *info = user_data;
272 
273  ENTER ("info=%p", info);
274 
275  /* Pull info from widget, push into freq spec */
276  //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date);
277  recurrenceListFree(&info->period);
278  gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date);
279 
280  /* Count the number of periods that would be generated. */
281  g_date_clear (&period_begin, 1);
282  g_date_clear (&period_end, 1);
283  g_date_clear (&date_now, 1);
284  nperiods = 0;
285  period_end = info->closing_date;
286  gnc_gdate_set_time64 (&date_now, gnc_time (NULL));
287 
288  while (0 > g_date_compare(&period_end, &date_now ))
289  {
290  nperiods ++;
291  PINFO ("Period = %d and End date is %d/%d/%d", nperiods,
292  g_date_get_month(&period_end),
293  g_date_get_day(&period_end),
294  g_date_get_year(&period_end));
295  period_begin = period_end;
296  recurrenceListNextInstance(info->period, &period_begin, &period_end);
297 
298  /* FIXME Check for valid period_end, not sure why it wont be!!! */
299  if (g_date_valid (&period_end) != TRUE)
300  break;
301  }
302 
303  /* Find the date of the earliest transaction in the current book.
304  * Note that this could have changed since last time, since
305  * we may have closed books since last time. */
306  info->earliest = get_earliest_in_book (gnc_get_current_book());
307  info->earliest_str = qof_print_date(info->earliest);
308  PINFO ("Date of earliest transaction is %" G_GINT64_FORMAT " %s",
309  info->earliest, gnc_ctime (&info->earliest));
310 
311  /* Display the results */
312  str = g_strdup_printf (
313  /* Translators: %s is a date string. %d is the number of books
314  * that will be created. This is a ngettext(3) message (but
315  * only for the %d part). */
316  ngettext("The earliest transaction date found in this book is %s. "
317  "Based on the selection made above, this book will be split "
318  "into %d book.",
319  "The earliest transaction date found in this book is %s. "
320  "Based on the selection made above, this book will be split "
321  "into %d books.",
322  nperiods),
323  info->earliest_str,
324  nperiods);
325  gtk_label_set_text (GTK_LABEL(info->period_remarks), str);
326  g_free (str);
327 }
328 
329 /* =============================================================== */
330 
331 void
332 ap_assistant_book_prepare (GtkAssistant *assistant, gpointer user_data)
333 {
334  QofBook *currbook;
335  char close_date_str[MAX_DATE_LENGTH];
336  char prev_close_date_str[MAX_DATE_LENGTH];
337  const char *period_text;
338  char *str;
339  const char *cstr;
340  int ntrans, nacc;
341  GtkTextBuffer *buffer;
342 
343  AcctPeriodInfo *info = user_data;
344 
345  ENTER ("info=%p", info);
346 
347  /* Tell user about how the previous book closing went. */
348  cstr = get_close_status_str (info);
349  gtk_label_set_text (GTK_LABEL(info->close_results), cstr);
350  info->close_status = -1;
351 
352  /* Pull info from widget, push into freq spec */
353  //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date);
354  recurrenceListFree(&info->period);
355  gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date);
356 
357  qof_print_date_dmy_buff (close_date_str, MAX_DATE_LENGTH,
358  g_date_get_day(&info->closing_date),
359  g_date_get_month(&info->closing_date),
360  g_date_get_year(&info->closing_date));
361 
362  currbook = gnc_get_current_book();
363  ntrans = get_num_xactions_before_date(currbook,
364  gnc_time64_get_day_end_gdate (&info->closing_date));
365 
366  nacc = gnc_account_n_descendants (gnc_book_get_root_account (currbook));
367 
368  /* Display the book info */
369  period_text =
370  _("You have asked for a book to be created. This book "
371  "will contain all transactions up to midnight %s "
372  "(for a total of %d transactions spread over %d accounts).\n\n "
373  "Amend the Title and Notes or Click on 'Forward' to proceed.\n "
374  "Click on 'Back' to adjust the dates or 'Cancel'.");
375  str = g_strdup_printf (period_text, close_date_str, ntrans, nacc);
376  gtk_label_set_text (GTK_LABEL(info->book_details), str);
377  g_free (str);
378 
379  gtk_widget_show (GTK_WIDGET (info->book_details));
380 
381  /* Create default settings for the title, notes fields */
382  qof_print_date_dmy_buff (prev_close_date_str, MAX_DATE_LENGTH,
383  g_date_get_day(&info->prev_closing_date),
384  g_date_get_month(&info->prev_closing_date),
385  g_date_get_year(&info->prev_closing_date));
386 
387  str = g_strdup_printf (_("Period %s - %s"), prev_close_date_str, close_date_str);
388  gtk_entry_set_text (GTK_ENTRY(info->book_title), str);
389 
390  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(info->book_notes));
391  gtk_text_buffer_set_text(buffer, str, -1);
392 
393  g_free (str);
394 }
395 
396 /* =============================================================== */
397 
398 void
399 ap_assistant_apply_prepare (GtkAssistant *assistant, gpointer user_data)
400 {
401  AcctPeriodInfo *info = user_data;
402  const char *btitle;
403  char *str;
404  const char *apply_text =
405  _("The book will be created with the title %s when you "
406  "click on 'Apply'. Click on 'Back' to adjust, "
407  "or 'Cancel' to not create any book.");
408 
409  btitle = gtk_entry_get_text (GTK_ENTRY(info->book_title));
410  str = g_strdup_printf (apply_text, btitle);
411  gtk_label_set_text (GTK_LABEL(info->apply_label), str);
412  g_free (str);
413 }
414 
415 /* =============================================================== */
416 
417 static void
418 ap_assistant_menu_changed_cb (GtkWidget *widget, gpointer user_data)
419 {
420  AcctPeriodInfo *info = user_data;
421  GtkAssistant *assistant = GTK_ASSISTANT(info->window);
422  gint num = gtk_assistant_get_current_page (assistant);
423  GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
424 
425  ENTER ("info=%p", info);
426  ap_assistant_menu_prepare (assistant, info);
427  gtk_assistant_set_page_complete (assistant, page, ap_validate_menu (assistant, user_data));
428 }
429 
430 /* =============================================================== */
431 
432 gboolean
433 ap_validate_menu (GtkAssistant *assistant, gpointer user_data)
434 {
435  GDate date_now;
436  AcctPeriodInfo *info = user_data;
437  ENTER("info=%p", info);
438 
439  /* Pull info from widget, push into freq spec */
440  //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date);
441  recurrenceListFree(&info->period);
442  gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date);
443 
444  if (0 <= g_date_compare(&info->prev_closing_date, &info->closing_date))
445  {
446  /* Closing date must be greater than closing date of previous book */
447  return FALSE;
448  }
449 
450  g_date_clear (&date_now, 1);
451  gnc_gdate_set_today (&date_now);
452  if (0 < g_date_compare(&info->closing_date, &date_now))
453  {
454  /* Closing date must be in the future */
455  return FALSE;
456  }
457  return TRUE;
458 }
459 
460 /* =============================================================== */
461 
462 void
463 ap_assistant_finish (GtkAssistant *assistant, gpointer user_data)
464 {
465  AcctPeriodInfo *info = user_data;
466  GtkTextBuffer * buffer;
467  GtkTextIter startiter, enditer;
468  gint len;
469  const char *btitle;
470  char *bnotes;
471  Timespec closing_date;
472 
473  ENTER("info=%p", info);
474 
475  btitle = gtk_entry_get_text (GTK_ENTRY(info->book_title));
476  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(info->book_notes));
477  len = gtk_text_buffer_get_char_count (buffer);
478  gtk_text_buffer_get_iter_at_offset(buffer, &startiter, 0);
479  gtk_text_buffer_get_iter_at_offset(buffer, &enditer, len);
480 
481  bnotes = gtk_text_buffer_get_text(buffer, &startiter, &enditer , 0);
482  PINFO("Book title is - %s\n", btitle);
483 
484  timespecFromTime64 (&closing_date,
485  gnc_time64_get_day_end_gdate (&info->closing_date));
486  g_free(bnotes);
487 
488  /* Report the status back to the user. */
489  info->close_status = 0; /* XXX fixme success or failure? */
490 
491  /* Find the next closing date ... */
492  info->prev_closing_date = info->closing_date;
493  recurrenceListNextInstance (info->period, &info->prev_closing_date,
494  &info->closing_date);
495 
496 
497  /* FIXME Test for valid closing date, not sure why it wont be!!! */
498  if (g_date_valid(&info->closing_date) == TRUE)
499  {
500  /* If the next closing date is in the future, then we are done. */
501  if (gnc_time (NULL) >
502  gnc_time64_get_day_end_gdate (&info->closing_date))
503  {
504  /* Load up the GUI for the next closing period. */
505  gnc_frequency_setup_recurrence (info->period_menu, NULL,
506  &info->closing_date);
507  /* Jump back to the Close Book page. */
508  gtk_assistant_set_current_page (GTK_ASSISTANT(info->window), 1);
509  }
510  }
511 }
512 
513 /* =============================================================== */
514 
515 void
516 ap_assistant_summary_prepare (GtkAssistant *assistant, gpointer user_data)
517 {
518  const char *msg;
519  char *str;
520  AcctPeriodInfo *info = user_data;
521  ENTER ("info=%p", info);
522 
523  /* Translation FIXME: Can this %s-containing message please be
524  replaced by one single message? Either this closing went
525  successfully ("success", "congratulations") or something else
526  should be displayed anyway. */
527  msg = _("%s\nCongratulations! You are done closing books!\n");
528 
529  str = g_strdup_printf (msg, get_close_status_str (info));
530  gtk_label_set_text (GTK_LABEL(info->summary), str);
531  g_free (str);
532 
533 }
534 
535 /* =============================================================== */
536 
537 static GtkWidget *
538 ap_assistant_create (AcctPeriodInfo *info)
539 {
540  GtkBuilder *builder;
541  GtkWidget *window;
542  GtkWidget *box;
543 
544  builder = gtk_builder_new();
545  gnc_builder_add_from_file (builder , "assistant-acct-period.glade", "Account Period Assistant");
546  window = GTK_WIDGET(gtk_builder_get_object (builder, "Account Period Assistant"));
547  info->window = window;
548 
549  /* Set the assistant colors */
550  gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
551 
552  /* Enable all pages except menu page. */
553  gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
554  GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
555  TRUE);
556  gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
557  GTK_WIDGET(gtk_builder_get_object(builder, "book_page")),
558  TRUE);
559  gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
560  GTK_WIDGET(gtk_builder_get_object(builder, "finish_page")),
561  TRUE);
562  gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
563  GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
564  TRUE);
565 
566  info->close_status = -1;
567 
568  /* Find the date of the earliest transaction in the book.
569  * Add a year minus a day as the first guess for book closing,
570  * and use that to set up the freq spec widget. */
571  info->earliest = get_earliest_in_book (gnc_get_current_book());
572  info->earliest_str = qof_print_date(info->earliest);
573  PINFO ("date of earliest transaction is %" G_GINT64_FORMAT " %s",
574  info->earliest, gnc_ctime (&info->earliest));
575 
576  g_date_clear (&info->closing_date, 1);
577  gnc_gdate_set_time64 (&info->closing_date, info->earliest);
578  g_date_clear (&info->prev_closing_date, 1);
579  info->prev_closing_date = info->closing_date;
580  g_date_add_years (&info->closing_date, 1);
581 
582  {
583  Recurrence *r = g_new0(Recurrence, 1);
584  recurrenceSet(r, 1, PERIOD_MONTH, &info->closing_date, WEEKEND_ADJ_NONE);
585  info->period = NULL;
586  info->period = g_list_append(info->period, r);
587  }
588 
589  info->period_menu = GNC_FREQUENCY(
590  gnc_frequency_new_from_recurrence(info->period, &info->closing_date));
591 
592  /* Change the text so that its more mainingful for this assistant */
593  gnc_frequency_set_frequency_label_text(info->period_menu, _("Period:"));
594  gnc_frequency_set_date_label_text(info->period_menu, _("Closing Date:"));
595 
596  /* Reparent to the correct location */
597 
598  box = GTK_WIDGET(gtk_builder_get_object(builder, "period_hbox"));
599  gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (info->period_menu), TRUE, TRUE, 0);
600  g_signal_connect (info->period_menu, "changed",
601  G_CALLBACK (ap_assistant_menu_changed_cb), info);
602 
603  /* Get handles to all of the other widgets we'll need */
604  info->period_remarks = GTK_WIDGET(gtk_builder_get_object(builder, "remarks_label"));
605 
606  info->close_results = GTK_WIDGET(gtk_builder_get_object(builder, "results_label"));
607 
608  info->book_details = GTK_WIDGET(gtk_builder_get_object(builder, "book_label"));
609 
610  info->book_title = GTK_WIDGET(gtk_builder_get_object(builder, "book_title_entry"));
611 
612  info->book_notes = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "book_notes_view"));
613 
614  info->apply_label = GTK_WIDGET(gtk_builder_get_object(builder, "finish_page"));
615 
616  info->summary = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
617 
618  g_signal_connect (G_OBJECT(window), "destroy",
619  G_CALLBACK (ap_assistant_destroy_cb), info);
620 
621  gtk_builder_connect_signals(builder, info);
622  g_object_unref(G_OBJECT(builder));
623  return window;
624 }
625 
626 /* =============================================================== */
627 
628 static void
629 ap_close_handler (gpointer user_data)
630 {
631  AcctPeriodInfo *info = user_data;
632 
633  gtk_widget_destroy (info->window);
634 }
635 
636 /********************************************************************\
637  * gnc_acct_period_dialog *
638  * opens up a assistant to configure accounting periods *
639  * *
640  * Args: none *
641  * Return: nothing *
642 \********************************************************************/
643 
644 void
645 gnc_acct_period_dialog (void)
646 {
647  AcctPeriodInfo *info;
648 
649  info = g_new0 (AcctPeriodInfo, 1);
650 
651  ap_assistant_create (info);
652 
653  gnc_register_gui_component (ASSISTANT_ACCT_PERIOD_CM_CLASS,
654  NULL, ap_close_handler, info);
655 
656  gtk_widget_show_all (info->window);
657 
658  gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
659 }
void gnc_gdate_set_today(GDate *gd)
void qof_query_add_term(QofQuery *query, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
gint gnc_account_n_descendants(const Account *account)
Definition: Account.c:2698
utility functions for the GnuCash UI
#define PINFO(format, args...)
Definition: qoflog.h:249
void qof_query_set_sort_order(QofQuery *q, QofQueryParamList *primary_sort_params, QofQueryParamList *secondary_sort_params, QofQueryParamList *tertiary_sort_params)
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void qof_query_set_sort_increasing(QofQuery *q, gboolean prim_inc, gboolean sec_inc, gboolean tert_inc)
#define ENTER(format, args...)
Definition: qoflog.h:261
struct _QofQuery QofQuery
Definition: qofquery.h:90
time64 gnc_time64_get_day_end_gdate(const GDate *date)
void qof_query_set_max_results(QofQuery *q, int n)
char * qof_print_date(time64 secs)
convert single-entry accounts to clean double-entry
void qof_query_destroy(QofQuery *q)
void qof_query_set_book(QofQuery *q, QofBook *book)
#define MAX_DATE_LENGTH
Definition: gnc-date.h:106
GList * qof_query_run(QofQuery *query)
GDate helper routines.
size_t qof_print_date_dmy_buff(gchar *buff, size_t buflen, int day, int month, int year)
#define QUERY_DEFAULT_SORT
Definition: qofquery.h:106
time64 gnc_time(time64 *tbuf)
get the current local time
gint64 time64
Definition: gnc-date.h:83
gchar * gnc_ctime(const time64 *secs)
Return a string representation of a date from a 64-bit time value.
API for Transactions and Splits (journal entries)
#define QOF_QUERY_FIRST_TERM
Definition: qofquery.h:103
const gchar * QofLogModule
Definition: qofid.h:89
void gnc_gdate_set_time64(GDate *gd, time64 time)
void timespecFromTime64(Timespec *ts, time64 t)