QOF  0.8.7
test-book-merge.c
1 /*********************************************************************
2  * test-book-merge.c -- test implementation api for QoFBook merge *
3  * Copyright (C) 2004-2005 Neil Williams <linux@codehelp.co.uk> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22  ********************************************************************/
23  /* Test the qof_book_merge infrastructure. */
24 
25 #include <glib.h>
26 #include "qof.h"
27 #include "qofinstance-p.h"
28 #include "qofevent-p.h"
29 #include "test-stuff.h"
30 
31 #define TEST_MODULE_NAME "book-merge-test"
32 #define TEST_MODULE_DESC "Test Book Merge"
33 #define OBJ_NAME "somename"
34 #define OBJ_AMOUNT "anamount"
35 #define OBJ_DATE "nottoday"
36 #define OBJ_GUID "unique"
37 #define OBJ_DISCOUNT "hefty"
38 #define OBJ_VERSION "early"
39 #define OBJ_MINOR "tiny"
40 #define OBJ_ACTIVE "ofcourse"
41 #define OBJ_FLAG "tiny_flag"
42 
43 static void test_rule_loop (QofBookMergeData *, QofBookMergeRule *,
44  guint);
45 static void test_merge (void);
46 gboolean myobjRegister (void);
47 #ifdef TEST_DEBUG
48 static QofLogModule log_module = QOF_MOD_MERGE;
49 #endif
50 
51 /* simple object structure */
52 typedef struct obj_s
53 {
54  QofInstance inst;
55  gchar *Name;
56  gchar flag;
57  QofNumeric Amount;
58  const GUID *obj_guid;
59  QofTime *date;
60  gdouble discount; /* cheap pun, I know. */
61  gboolean active;
62  gint32 version;
63  gint64 minor;
64 } myobj;
65 
66 static void
67 obj_setGUID (myobj * g, const GUID * h)
68 {
69  if (!g)
70  return;
71  g->obj_guid = h;
72 }
73 
74 static myobj *
75 obj_create (QofBook * book)
76 {
77  myobj *g;
78  g_return_val_if_fail (book, NULL);
79  g = g_new (myobj, 1);
80  qof_instance_init (&g->inst, TEST_MODULE_NAME, book);
81  obj_setGUID (g, qof_instance_get_guid (&g->inst));
82  g->discount = 0;
83  g->active = TRUE;
84  g->version = 1;
85  g->minor = 1;
86  g->flag = 'n';
87  qof_event_gen (&g->inst.entity, QOF_EVENT_CREATE, NULL);
88  return g;
89 }
90 
91 static void
92 obj_setFlag (myobj * g, char f)
93 {
94  g_return_if_fail (g);
95  g->flag = f;
96 }
97 
98 static gchar
99 obj_getFlag (myobj * g)
100 {
101  g_return_val_if_fail (g, 'n');
102  return g->flag;
103 }
104 
105 static void
106 obj_setMinor (myobj * g, gint64 h)
107 {
108  g_return_if_fail (g != NULL);
109  g->minor = h;
110 }
111 
112 static gint64
113 obj_getMinor (myobj * g)
114 {
115  g_return_val_if_fail ((g != NULL), 0);
116  return g->minor;
117 }
118 
119 static void
120 obj_setVersion (myobj * g, gint32 h)
121 {
122  g_return_if_fail (g != NULL);
123  g->version = h;
124 }
125 
126 static gint32
127 obj_getVersion (myobj * g)
128 {
129  if (!g)
130  return 0;
131  return g->version;
132 }
133 
134 static void
135 obj_setActive (myobj * g, gboolean h)
136 {
137  if (!g)
138  return;
139  g->active = h;
140 }
141 
142 static gboolean
143 obj_getActive (myobj * g)
144 {
145  if (!g)
146  return FALSE;
147  return g->active;
148 }
149 
150 static void
151 obj_setDiscount (myobj * g, gdouble h)
152 {
153  if (!g)
154  return;
155  g->discount = h;
156 }
157 
158 static gdouble
159 obj_getDiscount (myobj * g)
160 {
161  if (!g)
162  return 0;
163  return g->discount;
164 }
165 
166 static void
167 obj_setDate (myobj * g, QofTime *h)
168 {
169  if (!g)
170  return;
171  do_test ((h != NULL), "passed a NULL time");
172  do_test ((qof_time_is_valid (h) == TRUE),
173  "passed an invalid time");
174  g->date = h;
175 }
176 
177 static QofTime *
178 obj_getDate (myobj * g)
179 {
180  if (!g)
181  return NULL;
182  do_test ((g->date != NULL), "stored time is NULL");
183  do_test ((qof_time_is_valid (g->date) == TRUE),
184  "stored time is invalid");
185  return g->date;
186 }
187 
188 static const GUID *
189 obj_getGUID (myobj * g)
190 {
191  if (!g)
192  return NULL;
193  return g->obj_guid;
194 }
195 
196 static void
197 obj_setName (myobj * g, char *h)
198 {
199  if (!g || !h)
200  return;
201  g->Name = strdup (h);
202 }
203 
204 static gchar *
205 obj_getName (myobj * g)
206 {
207  if (!g)
208  return NULL;
209  return g->Name;
210 }
211 
212 static void
213 obj_setAmount (myobj * g, QofNumeric h)
214 {
215  if (!g)
216  return;
217  g->Amount = h;
218 }
219 
220 static QofNumeric
221 obj_getAmount (myobj * g)
222 {
223  if (!g)
224  return qof_numeric_zero ();
225  return g->Amount;
226 }
227 
228 static QofObject obj_object_def = {
229  .interface_version = QOF_OBJECT_VERSION,
230  .e_type = TEST_MODULE_NAME,
231  .type_label = TEST_MODULE_DESC,
232  .create = (gpointer) obj_create,
233  .book_begin = NULL,
234  .book_end = NULL,
235  .is_dirty = NULL,
236  .mark_clean = NULL,
237  .foreach = qof_collection_foreach,
238  .printable = NULL,
239  .version_cmp = (gint (*)(gpointer, gpointer))
241 };
242 
243 gboolean
244 myobjRegister (void)
245 {
246  static QofParam params[] = {
247  {OBJ_NAME, QOF_TYPE_STRING, (QofAccessFunc) obj_getName,
248  (QofSetterFunc) obj_setName, NULL},
249  {OBJ_AMOUNT, QOF_TYPE_NUMERIC, (QofAccessFunc) obj_getAmount,
250  (QofSetterFunc) obj_setAmount, NULL},
251  {OBJ_GUID, QOF_TYPE_GUID, (QofAccessFunc) obj_getGUID,
252  (QofSetterFunc) obj_setGUID, NULL},
253  {OBJ_DATE, QOF_TYPE_TIME, (QofAccessFunc) obj_getDate,
254  (QofSetterFunc) obj_setDate, NULL},
255  {OBJ_DISCOUNT, QOF_TYPE_DOUBLE, (QofAccessFunc) obj_getDiscount,
256  (QofSetterFunc) obj_setDiscount, NULL},
257  {OBJ_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc) obj_getActive,
258  (QofSetterFunc) obj_setActive, NULL},
259  {OBJ_VERSION, QOF_TYPE_INT32, (QofAccessFunc) obj_getVersion,
260  (QofSetterFunc) obj_setVersion, NULL},
261  {OBJ_MINOR, QOF_TYPE_INT64, (QofAccessFunc) obj_getMinor,
262  (QofSetterFunc) obj_setMinor, NULL},
263  {OBJ_FLAG, QOF_TYPE_CHAR, (QofAccessFunc) obj_getFlag,
264  (QofSetterFunc) obj_setFlag, NULL},
266  NULL, NULL},
267  {QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc) qof_instance_get_guid,
268  NULL, NULL},
269  {NULL, NULL, NULL, NULL, NULL},
270  };
271 
272  qof_class_register (TEST_MODULE_NAME, NULL, params);
273 
274  return qof_object_register (&obj_object_def);
275 }
276 
277 static void
278 test_merge (void)
279 {
280  QofBook *target, *import;
281  gdouble init_value, discount;
282  myobj *import_obj, *target_obj, *new_obj;
283  QofTime *base_time, *temp_time;
284  gboolean active;
285  gint32 version;
286  gint64 minor;
287  gchar *import_init, *target_init;
288  gchar flag, flag_check;
289  QofNumeric obj_amount;
290  QofBookMergeData *mergeData;
291 
292  target = qof_book_new ();
293  import = qof_book_new ();
294  init_value = 1.00;
295  flag = get_random_character ();
296  discount = 0.175;
297  active = TRUE;
298  version = get_random_int_in_range (0, 10000);
299  minor = get_random_int_in_range (1000001, 2000000);
300  import_init = "test";
301  target_init = "testing";
302  base_time = qof_time_set (1153309194, 568714241);
303  do_test ((TRUE == qof_time_is_valid (base_time)),
304  "invalid init time");
305  {
306  gchar *str;
307  QofDate *qd;
308 
309  qd = qof_date_from_qtime (base_time);
311  do_test ((0 == safe_strcmp (
312  "2006-07-19 11:39:54.568714241 +0000", str)),
313  "failed to compare base_time correctly.");
314  g_free (str);
315  qof_date_free (qd);
316  }
317 
318  do_test ((NULL != target), "#1 target book is NULL");
319  do_test ((NULL != import), "#2 import book is NULL");
320 
321  /* import book objects - tests used */
322  import_obj = g_new (myobj, 1);
323  do_test ((NULL != import_obj), "#3 new object create");
324  qof_instance_init (&import_obj->inst, TEST_MODULE_NAME, import);
325  do_test ((NULL != &import_obj->inst), "#4 instance init");
326  obj_setGUID (import_obj, qof_instance_get_guid (&import_obj->inst));
327  do_test ((NULL != &import_obj->obj_guid), "#5 guid set");
328  qof_event_gen (&import_obj->inst.entity, QOF_EVENT_CREATE, NULL);
329  do_test ((NULL != &import_obj->inst.entity), "#6 gnc event create");
330  obj_setName (import_obj, import_init);
331  do_test ((NULL != &import_obj->Name), "#7 string set");
332  obj_amount = qof_numeric_from_double (init_value, 1, QOF_HOW_DENOM_EXACT);
333  obj_setAmount (import_obj, obj_amount);
334  do_test ((qof_numeric_check (obj_getAmount (import_obj)) == QOF_ERROR_OK),
335  "#8 gnc_numeric set");
336  obj_setActive (import_obj, active);
337  do_test ((FALSE != &import_obj->active), "#9 gboolean set");
338  obj_setDiscount (import_obj, discount);
339  obj_setVersion (import_obj, version);
340  do_test ((version == import_obj->version), "#11 gint32 set");
341  obj_setMinor (import_obj, minor);
342  do_test ((minor == import_obj->minor), "#12 gint64 set");
343  do_test ((TRUE == qof_time_is_valid (base_time)),
344  "invalid import time ts");
345  {
346  gchar *str;
347  QofDate *qd;
348 
349  qd = qof_date_from_qtime (base_time);
351  do_test ((0 == safe_strcmp (
352  "2006-07-19 11:39:54.568714241 +0000", str)),
353  "failed to compare base_time correctly.");
354  g_free (str);
355  qof_date_free (qd);
356  }
357  obj_setDate (import_obj, base_time);
358  do_test ((TRUE == qof_time_is_valid (import_obj->date)),
359  "invalid import time");
360  do_test ((qof_time_cmp (base_time, import_obj->date) == 0),
361  "test #13 date set");
362  obj_setFlag (import_obj, flag);
363  do_test ((flag == obj_getFlag (import_obj)), "#14 flag set");
364 
365  obj_amount =
366  qof_numeric_add (obj_amount, obj_amount, 1, QOF_HOW_DENOM_EXACT);
367  discount = get_random_double ();
368  version = 2;
369  minor = 3;
370 
371  /* second import object - test results would be the same, so not tested. */
372  new_obj = g_new (myobj, 1);
373  qof_instance_init (&new_obj->inst, TEST_MODULE_NAME, import);
374  obj_setGUID (new_obj, qof_instance_get_guid (&new_obj->inst));
375  qof_event_gen (&new_obj->inst.entity, QOF_EVENT_CREATE, NULL);
376  obj_setName (new_obj, import_init);
377  obj_setAmount (new_obj, obj_amount);
378  obj_setActive (new_obj, active);
379  obj_setDiscount (new_obj, discount);
380  obj_setVersion (new_obj, version);
381  obj_setMinor (new_obj, minor);
382  do_test ((TRUE == qof_time_is_valid (base_time)),
383  "second import time invalid");
384  {
385  gchar *str;
386  QofDate *qd;
387 
388  qd = qof_date_from_qtime (base_time);
390  do_test ((0 == safe_strcmp (
391  "2006-07-19 11:39:54.568714241 +0000", str)),
392  "failed to compare base_time correctly.");
393  g_free (str);
394  qof_date_free (qd);
395  }
396  obj_setDate (new_obj, base_time);
397  obj_setFlag (new_obj, flag);
398 
399  obj_amount =
400  qof_numeric_add (obj_amount, obj_amount, 1, QOF_HOW_DENOM_EXACT);
401  discount = get_random_double ();
402  version = 2;
403  minor = 3;
404  flag = 'z';
405 
406  /* target object - test results would be the same, so not tested. */
407  target_obj = g_new (myobj, 1);
408  qof_instance_init (&target_obj->inst, TEST_MODULE_NAME, target);
409  obj_setGUID (target_obj, qof_instance_get_guid (&target_obj->inst));
410  qof_event_gen (&target_obj->inst.entity, QOF_EVENT_CREATE, NULL);
411  obj_setName (target_obj, target_init);
412  obj_setAmount (target_obj, obj_amount);
413  obj_setActive (target_obj, active);
414  obj_setDiscount (target_obj, discount);
415  obj_setVersion (target_obj, version);
416  obj_setMinor (target_obj, minor);
417  {
418  gchar *str;
419  QofDate *qd;
420 
421  qd = qof_date_from_qtime (base_time);
423  do_test ((0 == safe_strcmp (
424  "2006-07-19 11:39:54.568714241 +0000", str)),
425  "failed to compare base_time correctly.");
426  g_free (str);
427  qof_date_free (qd);
428  }
429  temp_time = qof_time_add_secs_copy (base_time, 65);
430  do_test ((TRUE == qof_time_is_valid (temp_time)),
431  "time add secs returned invalid");
432  obj_setDate (target_obj, temp_time);
433  obj_setFlag (target_obj, flag);
434  do_test ((flag == obj_getFlag (target_obj)), "#15 flag set");
435 
436  mergeData = qof_book_merge_init (import, target);
437  do_test (mergeData != NULL,
438  "FATAL: Merge could not be initialised!\t aborting . . ");
439  g_return_if_fail (mergeData != NULL);
440  qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_REPORT);
441  qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_UPDATE);
442  qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_NEW);
443  /* reserved calls - test only */
444  qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_ABSOLUTE);
445  qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_DUPLICATE);
446 
447  /* import should not be in the target - pass if import_init fails match with target */
448  do_test (((safe_strcmp (obj_getName (import_obj),
449  obj_getName (target_obj))) != 0),
450  "Init value test #1");
451 
452  /* a good commit returns zero */
453  do_test (qof_book_merge_commit (mergeData) == 0, "Commit failed");
454 
455  /* import should be in the target - pass if import_init matches target */
456  do_test (((safe_strcmp (import_init, obj_getName (target_obj))) == 0),
457  "Merged value test #1");
458 
459  /* import should be the same as target - pass if values are the same */
460  do_test (((safe_strcmp
461  (obj_getName (target_obj), obj_getName (import_obj))) == 0),
462  "Merged value test #2");
463 
464  /* check that the Amount really is a gnc_numeric */
465  do_test ((qof_numeric_check (obj_getAmount (import_obj)) == QOF_ERROR_OK),
466  "import gnc_numeric check");
467  do_test ((qof_numeric_check (obj_getAmount (target_obj)) == QOF_ERROR_OK),
468  "target gnc_numeric check");
469 
470  /* obj_amount was changed after the import object was set, so expect a difference. */
471  do_test ((qof_numeric_compare (obj_getAmount (import_obj), obj_amount) !=
472  QOF_ERROR_OK), "gnc_numeric value check #1");
473 
474  /* obj_amount is in the target object with the import value, expect a difference/ */
475  do_test ((qof_numeric_compare (obj_getAmount (target_obj), obj_amount) !=
476  QOF_ERROR_OK), "gnc_numeric value check #2");
477 
478  /* target had a different date, so import date should now be set */
479  qof_time_free (temp_time);
480  temp_time = target_obj->date;
481  {
482  gchar *str;
483  QofDate *qd;
484 
485  qd = qof_date_from_qtime (base_time);
487  do_test ((0 == safe_strcmp (
488  "2006-07-19 11:39:54.568714241 +0000", str)),
489  "failed to compare base_time after merge.");
490  g_free (str);
491  qof_date_free (qd);
492  }
493  {
494  gchar *str;
495  QofDate *qd;
496 
497  qd = qof_date_from_qtime (temp_time);
499  do_test ((0 == safe_strcmp (
500  "2006-07-19 11:39:54.568714241 +0000", str)),
501  "failed to compare target time after merge.");
502  g_free (str);
503  qof_date_free (qd);
504  }
505  do_test ((qof_time_cmp (base_time, temp_time) == 0),
506  "date value check: 1");
507 #ifdef TEST_DEBUG
508  DEBUG (" import<->target=%d\n",
509  (qof_time_cmp (base_time, target_obj->date)));
510  {
511  QofDate *qd;
512  gchar *check;
513 
514  qd = qof_date_from_qtime (base_time);
515  DEBUG (" base_time=%" G_GINT64_FORMAT
516  " nsecs=%ld", qof_time_get_secs (base_time),
517  qof_time_get_nanosecs (base_time));
518  DEBUG (" import:\nyear=%" G_GINT64_FORMAT
519  " month=%ld day=%ld hour=%ld min=%ld sec=%"
520  G_GINT64_FORMAT "nsecs=%ld\n",
521  qd->qd_year, qd->qd_mon, qd->qd_mday, qd->qd_hour,
522  qd->qd_min, qd->qd_sec, qd->qd_nanosecs);
524  DEBUG (" import=%s\n", check);
525  qof_date_free (qd);
526  qd = qof_date_from_qtime (target_obj->date);
527  if (!qd)
528  PERR ("qd failed");
529  DEBUG (" target:\nyear=%" G_GINT64_FORMAT
530  " month=%ld day=%ld hour=%ld min=%ld sec=%"
531  G_GINT64_FORMAT "nsecs=%ld\n",
532  qd->qd_year, qd->qd_mon, qd->qd_mday, qd->qd_hour,
533  qd->qd_min, qd->qd_sec, qd->qd_nanosecs);
535  DEBUG (" target=%s\n", check);
536  g_free (check);
537  qof_date_free (qd);
538  }
539 #endif
540  qof_time_free (base_time);
541  /* import should be the same as target - pass if values are the same */
542  flag_check = obj_getFlag (target_obj);
543  do_test ((flag_check == obj_getFlag (import_obj)), "flag value check: 1");
544  do_test ((obj_getFlag (import_obj) == obj_getFlag (target_obj)),
545  "flag value check: 2");
546 }
547 
548 static void
549 test_rule_loop (QofBookMergeData * mergeData, QofBookMergeRule * rule,
550  guint remainder)
551 {
552  GSList *testing;
553  QofParam *eachParam;
554  gchar *importstring;
555  gchar *targetstring;
556  gboolean skip_target;
557 
558  importstring = NULL;
559  targetstring = NULL;
560  skip_target = FALSE;
561  mergeData->currentRule = rule;
562  do_test ((rule != NULL), "loop:#1 Rule is NULL");
563  do_test (remainder > 0, "loop:#2 remainder error.");
564  do_test ((safe_strcmp (NULL, rule->mergeLabel) != 0),
565  "loop:#3 object label\n");
566  do_test ((rule->importEnt != NULL),
567  "loop:#4 empty import entity");
568  /* targetEnt is always NULL at this stage if MERGE_NEW is set */
569  if (rule->targetEnt == NULL)
570  {
571  skip_target = TRUE;
572  }
573  if (!skip_target)
574  {
575  do_test ((safe_strcmp
576  (rule->importEnt->e_type, rule->targetEnt->e_type) == 0),
577  "loop: entity type mismatch");
578  }
579  do_test ((rule->mergeParam != NULL),
580  "loop: empty parameter list");
581  testing = rule->mergeParam;
582 
583  while (testing != NULL)
584  { // start of param loop
585  eachParam = testing->data;
586  do_test ((eachParam != NULL), "loop:#8 no QofParam data");
587  do_test ((eachParam->param_name != NULL),
588  "loop:#9 no parameter name");
589  do_test ((eachParam->param_getfcn != NULL),
590  "loop:#10 no get function");
591  do_test ((eachParam->param_setfcn != NULL),
592  "loop:#11 no set function");
593  /* non-generic - test routines only! */
594  if (safe_strcmp (eachParam->param_type, QOF_TYPE_STRING) == 0)
595  {
596  importstring =
597  g_strdup (eachParam->
598  param_getfcn (rule->importEnt, eachParam));
599  do_test ((importstring != NULL),
600  "loop:#12 direct get_fcn import");
601  do_test ((safe_strcmp (importstring, "test") == 0),
602  "loop:#13 direct import comparison");
603  if (!skip_target)
604  {
605  targetstring =
606  eachParam->param_getfcn (rule->targetEnt, eachParam);
607  do_test ((targetstring != NULL),
608  "loop:#14 direct get_fcn target");
609  do_test ((safe_strcmp (targetstring, "testing") == 0),
610  "loop:#15 direct target comparison");
611  }
612  }
613  /* param_as_string does the conversion for display purposes only */
614  /* do NOT use as_string for calculations or set_fcn */
615  importstring = qof_util_param_to_string (rule->importEnt, eachParam);
616  do_test ((importstring != NULL),
617  "loop:#16 import param_as_string is null");
618  if (!skip_target)
619  {
620  targetstring = qof_util_param_to_string (rule->targetEnt, eachParam);
621  do_test ((targetstring != NULL),
622  "loop:#17 target param_as_string is null");
623  }
624  testing = g_slist_next (testing);
625  } // end param loop
626  /* set each rule dependent on the user involvement response above. */
627  /* test routine just sets all MERGE_REPORT to MERGE_UPDATE */
628  mergeData = qof_book_merge_update_result (mergeData, MERGE_UPDATE);
629  do_test ((rule->mergeResult != MERGE_REPORT),
630  "update result fail");
631 }
632 
633 int
634 main (void)
635 {
636  qof_init ();
637  myobjRegister ();
638  test_merge ();
639  print_test_results ();
640  qof_close ();
641  return get_rv();
642 }
const gchar * mergeLabel
Definition: qofbookmerge.h:176
QofNumericErrorCode qof_numeric_check(QofNumeric in)
Definition: qofnumeric.c:39
gint64 qd_year
Extended version to cope with full range of dates.
Definition: qofdate.h:181
#define PERR(format, args...)
Definition: qoflog.h:183
gint qof_numeric_compare(QofNumeric a, QofNumeric b)
Definition: qofnumeric.c:169
void qof_date_free(QofDate *date)
Definition: qofdate.c:642
QofDate * qof_date_from_qtime(const QofTime *qt)
Definition: qofdate.c:884
#define QOF_OBJECT_VERSION
Definition: qofobject.h:57
gint qof_book_merge_commit(QofBookMergeData *mergeData)
Commits the import data to the target book.
Definition: qofbookmerge.c:998
QofTime * qof_time_add_secs_copy(QofTime *qt, QofTimeSecs secs)
Create a new QofTime, secs different to an original.
Definition: qoftime.c:73
QofTimeSecs qof_time_get_secs(const QofTime *qt)
Get the number of seconds.
Definition: qoftime.c:133
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
registers a new object class with the Qof subsystem.
Definition: qofclass.c:94
QofBook * qof_book_new(void)
Definition: qofbook.c:75
gchar * qof_date_print(const QofDate *date, QofDateFormat df)
Convert a QofDate to a timestamp according to the specified date format.
Definition: qofdate.c:581
glong qof_time_get_nanosecs(const QofTime *qt)
Get the number of seconds.
Definition: qoftime.c:141
QofBook * qof_instance_get_book(QofInstance *inst)
Definition: qofinstance.c:87
#define QOF_PARAM_BOOK
Definition: qofquery.h:104
GSList * mergeParam
Definition: qofbookmerge.h:178
Full range replacement for struct tm.
Definition: qofdate.h:138
void qof_event_gen(QofEntity *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition: qofevent.c:235
QofEntity * importEnt
Definition: qofbookmerge.h:189
void(* QofSetterFunc)(gpointer, gpointer)
Definition: qofclass.h:151
#define QOF_EVENT_CREATE
Definition: qofevent.h:71
const GUID * qof_instance_get_guid(QofInstance *inst)
Definition: qofinstance.c:79
glong qd_hour
Signed replacement of struct tm.tm_hour.
Definition: qofdate.h:157
QofBookMergeResult mergeResult
Definition: qofbookmerge.h:188
void qof_time_free(QofTime *qt)
Free a QofTime when no longer required.
Definition: qoftime.c:56
glong qd_min
Signed replacement of struct tm.tm_min.
Definition: qofdate.h:150
void qof_collection_foreach(QofCollection *col, QofEntityForeachCB cb_func, gpointer user_data)
Definition: qofid.c:392
gint qof_time_cmp(const QofTime *ta, const QofTime *tb)
Definition: qoftime.c:165
glong qd_mon
Signed replacement of struct tm.tm_mon.
Definition: qofdate.h:171
void qof_book_merge_rule_foreach(QofBookMergeData *mergeData, QofBookMergeRuleForeachCB cb, QofBookMergeResult mergeResult)
Dialogue Control Callback.
#define DEBUG(format, args...)
Definition: qoflog.h:208
gchar * qof_util_param_to_string(QofEntity *ent, const QofParam *param)
Converts a parameter to a string for storage or display.
Definition: qofutil.c:464
#define QOF_DATE_FORMAT_ISO8601
Definition: qofdate.h:287
One rule per entity, built into a single GList for the entire merge.
Definition: qofbookmerge.h:164
gint64 qd_sec
Definition: qofdate.h:143
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
Definition: qofclass.h:144
QofTime * qof_time_set(QofTimeSecs t, glong nanosecs)
Definition: qoftime.c:210
QofBookMergeData * qof_book_merge_init(QofBook *importBook, QofBook *targetBook)
Initialise the QofBookMerge process.
Definition: qofbookmerge.c:900
Definition: guid.h:53
QofBookMergeRule * currentRule
Definition: qofbookmerge.h:222
glong qd_nanosecs
Definition: qofdate.h:141
gboolean qof_object_register(const QofObject *object)
Definition: qofobject.c:278
void qof_close(void)
Safely close down the Query Object Framework.
Definition: qofutil.c:840
QofNumeric qof_numeric_add(QofNumeric a, QofNumeric b, gint64 denom, gint how)
Definition: qofnumeric.c:295
struct QofTime64 QofTime
Use a 64-bit signed int QofTime.
Definition: qoftime.h:112
QofNumeric qof_numeric_from_double(gdouble in, gint64 denom, gint how)
Definition: qofnumeric.c:914
static QofNumeric qof_numeric_zero(void)
Definition: qofnumeric.h:253
gint safe_strcmp(const gchar *da, const gchar *db)
Definition: qofutil.c:75
QofBookMergeData * qof_book_merge_update_result(QofBookMergeData *mergeData, QofBookMergeResult tag)
called by dialogue callback to set the result of user intervention
Definition: qofbookmerge.c:966
int qof_instance_version_cmp(QofInstance *left, QofInstance *right)
Definition: qofinstance.c:116
void qof_instance_init(QofInstance *inst, QofIdType type, QofBook *book)
Definition: qofinstance.c:53
glong qd_mday
Signed replacement of struct tm.tm_mday.
Definition: qofdate.h:164
QofEntity * targetEnt
Definition: qofbookmerge.h:190
void qof_init(void)
Initialise the Query Object Framework.
Definition: qofutil.c:829
const gchar * QofLogModule
Definition: qofid.h:85
mergeData contains the essential context data for any merge.
Definition: qofbookmerge.h:209