GnuCash  5.6-150-g038405b370+
gnc-tax-table-xml-v2.cpp
1 /********************************************************************\
2  * gnc-tax-table-xml-v2.c -- tax table xml i/o implementation *
3  * *
4  * Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
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 #include <glib.h>
25 
26 #include <config.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include "gncEntry.h"
30 #include "gncTaxTableP.h"
31 
32 #include "gnc-xml-helper.h"
33 #include "sixtp.h"
34 #include "sixtp-utils.h"
35 #include "sixtp-parsers.h"
36 #include "sixtp-utils.h"
37 #include "sixtp-dom-parsers.h"
38 #include "sixtp-dom-generators.h"
39 
40 #include "gnc-xml.h"
41 #include "io-gncxml-gen.h"
42 #include "io-gncxml-v2.h"
43 
44 #include "gnc-tax-table-xml-v2.h"
45 
46 #define _GNC_MOD_NAME GNC_ID_TAXTABLE
47 
48 static QofLogModule log_module = GNC_MOD_IO;
49 
50 const gchar* taxtable_version_string = "2.0.0";
51 
52 /* ids */
53 #define gnc_taxtable_string "gnc:GncTaxTable"
54 #define taxtable_guid_string "taxtable:guid"
55 #define taxtable_name_string "taxtable:name"
56 #define taxtable_refcount_string "taxtable:refcount"
57 #define taxtable_invisible_string "taxtable:invisible"
58 #define taxtable_parent_string "taxtable:parent"
59 #define taxtable_child_string "taxtable:child"
60 #define taxtable_entries_string "taxtable:entries"
61 #define taxtable_slots_string "taxtable:slots"
62 
63 #define gnc_taxtableentry_string "gnc:GncTaxTableEntry"
64 #define ttentry_account_string "tte:acct"
65 #define ttentry_type_string "tte:type"
66 #define ttentry_amount_string "tte:amount"
67 
68 static void
69 maybe_add_guid (xmlNodePtr ptr, const char* tag, GncTaxTable* table)
70 {
71  if (table)
72  xmlAddChild (ptr, guid_to_dom_tree (tag,
73  qof_instance_get_guid (QOF_INSTANCE (table))));
74 }
75 
76 static xmlNodePtr
77 ttentry_dom_tree_create (GncTaxTableEntry* entry)
78 {
79  xmlNodePtr ret;
80  Account* account;
81  gnc_numeric amount;
82 
83  ret = xmlNewNode (NULL, BAD_CAST gnc_taxtableentry_string);
84 
85  account = gncTaxTableEntryGetAccount (entry);
86  if (account)
87  xmlAddChild (ret, guid_to_dom_tree (ttentry_account_string,
88  qof_instance_get_guid (QOF_INSTANCE (account))));
89 
90  amount = gncTaxTableEntryGetAmount (entry);
91  xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount));
92 
93  xmlAddChild (ret, text_to_dom_tree (ttentry_type_string,
94  gncAmountTypeToString (
95  gncTaxTableEntryGetType (entry))));
96 
97  return ret;
98 }
99 
100 static xmlNodePtr
101 taxtable_dom_tree_create (GncTaxTable* table)
102 {
103  xmlNodePtr ret, entries;
104  GList* list;
105 
106  ret = xmlNewNode (NULL, BAD_CAST gnc_taxtable_string);
107  xmlSetProp (ret, BAD_CAST "version", BAD_CAST taxtable_version_string);
108 
109  maybe_add_guid (ret, taxtable_guid_string, table);
110  xmlAddChild (ret, text_to_dom_tree (taxtable_name_string,
111  gncTaxTableGetName (table)));
112 
113  xmlAddChild (ret, int_to_dom_tree (taxtable_refcount_string,
114  gncTaxTableGetRefcount (table)));
115  xmlAddChild (ret, int_to_dom_tree (taxtable_invisible_string,
116  gncTaxTableGetInvisible (table)));
117 
118  /* We should not be our own child */
119  if (gncTaxTableGetChild (table) != table)
120  maybe_add_guid (ret, taxtable_child_string, gncTaxTableGetChild (table));
121 
122  maybe_add_guid (ret, taxtable_parent_string, gncTaxTableGetParent (table));
123 
124  entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL);
125  for (list = gncTaxTableGetEntries (table); list; list = list->next)
126  {
127  GncTaxTableEntry* entry = static_cast<decltype (entry)> (list->data);
128  xmlAddChild (entries, ttentry_dom_tree_create (entry));
129  }
130 
131  /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */
132  xmlAddChild (ret, qof_instance_slots_to_dom_tree (taxtable_slots_string,
133  QOF_INSTANCE (table)));
134  return ret;
135 }
136 
137 /***********************************************************************/
138 
140 {
141  GncTaxTableEntry* ttentry;
142  QofBook* book;
143 };
144 
145 static gboolean
146 ttentry_acct_handler (xmlNodePtr node, gpointer ttentry_pdata)
147 {
148  struct ttentry_pdata* pdata = static_cast<decltype (pdata)> (ttentry_pdata);
149  Account* acc;
150 
151  auto guid = dom_tree_to_guid (node);
152  g_return_val_if_fail (guid, FALSE);
153  acc = xaccAccountLookup (&*guid, pdata->book);
154  g_return_val_if_fail (acc, FALSE);
155 
156  gncTaxTableEntrySetAccount (pdata->ttentry, acc);
157  return TRUE;
158 }
159 
160 static gboolean
161 ttentry_type_handler (xmlNodePtr node, gpointer ttentry_pdata)
162 {
163  struct ttentry_pdata* pdata = static_cast<decltype (pdata)> (ttentry_pdata);
164  auto tte_settype = [](GncTaxTableEntry* tt, const char *str)
165  {
166  GncAmountType type;
167  if (gncAmountStringToType (str, &type))
168  gncTaxTableEntrySetType (tt, type);
169  };
170  return apply_xmlnode_text (tte_settype, pdata->ttentry, node);
171 }
172 
173 static gboolean
174 ttentry_amount_handler (xmlNodePtr node, gpointer ttentry_pdata)
175 {
176  struct ttentry_pdata* pdata = static_cast<decltype (pdata)> (ttentry_pdata);
177 
178  gncTaxTableEntrySetAmount (pdata->ttentry, dom_tree_to_gnc_numeric (node));
179  return TRUE;
180 }
181 
182 static struct dom_tree_handler ttentry_handlers_v2[] =
183 {
184  { ttentry_account_string, ttentry_acct_handler, 0, 0 },
185  { ttentry_type_string, ttentry_type_handler, 1, 0 },
186  { ttentry_amount_string, ttentry_amount_handler, 1, 0 },
187  { NULL, 0, 0, 0 }
188 };
189 
190 static GncTaxTableEntry*
191 dom_tree_to_ttentry (xmlNodePtr node, QofBook* book)
192 {
194  gboolean successful;
195 
196  ttentry_pdata.ttentry = gncTaxTableEntryCreate ();
197  ttentry_pdata.book = book;
198 
199  successful = dom_tree_generic_parse (node, ttentry_handlers_v2,
200  &ttentry_pdata);
201 
202  if (!successful)
203  {
204  PERR ("failed to parse tax table entry tree");
205  gncTaxTableEntryDestroy (ttentry_pdata.ttentry);
206  ttentry_pdata.ttentry = NULL;
207  }
208 
209  return ttentry_pdata.ttentry;
210 }
211 
212 /***********************************************************************/
213 
215 {
217  QofBook* book;
218 };
219 
220 static gboolean
221 set_parent_child (xmlNodePtr node, struct taxtable_pdata* pdata,
222  void (*func) (GncTaxTable*, GncTaxTable*))
223 {
225 
226  auto guid = dom_tree_to_guid (node);
227  g_return_val_if_fail (guid, FALSE);
228  table = gncTaxTableLookup (pdata->book, &*guid);
229 
230  /* Ignore pointers to self */
231  if (table == pdata->table)
232  {
233  PINFO ("found a self-referential parent/child; ignoring.\n");
234  return TRUE;
235  }
236 
237  if (!table)
238  {
239  table = gncTaxTableCreate (pdata->book);
240  gncTaxTableBeginEdit (table);
241  gncTaxTableSetGUID (table, &*guid);
242  gncTaxTableCommitEdit (table);
243  }
244  g_return_val_if_fail (table, FALSE);
245  func (pdata->table, table);
246 
247  return TRUE;
248 }
249 
250 static gboolean
251 taxtable_guid_handler (xmlNodePtr node, gpointer taxtable_pdata)
252 {
253  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
255 
256  auto guid = dom_tree_to_guid (node);
257  g_return_val_if_fail (guid, FALSE);
258  table = gncTaxTableLookup (pdata->book, &*guid);
259  if (table)
260  {
261  gncTaxTableDestroy (pdata->table);
262  pdata->table = table;
263  gncTaxTableBeginEdit (table);
264  }
265  else
266  {
267  gncTaxTableSetGUID (pdata->table, &*guid);
268  }
269 
270  return TRUE;
271 }
272 
273 static gboolean
274 taxtable_name_handler (xmlNodePtr node, gpointer taxtable_pdata)
275 {
276  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
277  return apply_xmlnode_text (gncTaxTableSetName, pdata->table, node);
278 }
279 
280 static gboolean
281 taxtable_refcount_handler (xmlNodePtr node, gpointer taxtable_pdata)
282 {
283  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
284  gint64 val;
285 
286  dom_tree_to_integer (node, &val);
287  gncTaxTableSetRefcount (pdata->table, val);
288  return TRUE;
289 }
290 
291 static gboolean
292 taxtable_invisible_handler (xmlNodePtr node, gpointer taxtable_pdata)
293 {
294  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
295  gint64 val;
296 
297  dom_tree_to_integer (node, &val);
298  if (val)
299  gncTaxTableMakeInvisible (pdata->table);
300  return TRUE;
301 }
302 
303 static gboolean
304 taxtable_parent_handler (xmlNodePtr node, gpointer taxtable_pdata)
305 {
306  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
307  return set_parent_child (node, pdata, gncTaxTableSetParent);
308 }
309 
310 static gboolean
311 taxtable_child_handler (xmlNodePtr node, gpointer taxtable_pdata)
312 {
313  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
314  return set_parent_child (node, pdata, gncTaxTableSetChild);
315 }
316 
317 static gboolean
318 taxtable_entries_handler (xmlNodePtr node, gpointer taxtable_pdata)
319 {
320  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
321  xmlNodePtr mark;
322 
323  g_return_val_if_fail (node, FALSE);
324  g_return_val_if_fail (node->xmlChildrenNode, FALSE);
325 
326  for (mark = node->xmlChildrenNode; mark; mark = mark->next)
327  {
328  GncTaxTableEntry* entry;
329 
330  if (g_strcmp0 ("text", (char*)mark->name) == 0)
331  continue;
332 
333  if (g_strcmp0 (gnc_taxtableentry_string, (char*)mark->name))
334  return FALSE;
335 
336  entry = dom_tree_to_ttentry (mark, pdata->book);
337 
338  if (entry)
339  gncTaxTableAddEntry (pdata->table, entry);
340  else
341  return FALSE;
342 
343  }
344  return TRUE;
345 }
346 
347 static gboolean
348 taxtable_slots_handler (xmlNodePtr node, gpointer taxtable_pdata)
349 {
350  struct taxtable_pdata* pdata = static_cast<decltype (pdata)> (taxtable_pdata);
351 
352  return dom_tree_create_instance_slots (node, QOF_INSTANCE (pdata->table));
353 }
354 
355 static struct dom_tree_handler taxtable_handlers_v2[] =
356 {
357  { taxtable_guid_string, taxtable_guid_handler, 1, 0 },
358  { taxtable_name_string, taxtable_name_handler, 1, 0 },
359  { taxtable_refcount_string, taxtable_refcount_handler, 1, 0 },
360  { taxtable_invisible_string, taxtable_invisible_handler, 1, 0 },
361  { taxtable_parent_string, taxtable_parent_handler, 0, 0 },
362  { taxtable_child_string, taxtable_child_handler, 0, 0 },
363  { taxtable_entries_string, taxtable_entries_handler, 1, 0 },
364  { taxtable_slots_string, taxtable_slots_handler, 0, 0 },
365  { NULL, 0, 0, 0 }
366 };
367 
368 static GncTaxTable*
369 dom_tree_to_taxtable (xmlNodePtr node, QofBook* book)
370 {
372  gboolean successful;
373 
374  taxtable_pdata.table = gncTaxTableCreate (book);
375  taxtable_pdata.book = book;
376  gncTaxTableBeginEdit (taxtable_pdata.table);
377 
378  successful = dom_tree_generic_parse (node, taxtable_handlers_v2,
379  &taxtable_pdata);
380 
381  if (successful)
382  gncTaxTableCommitEdit (taxtable_pdata.table);
383  else
384  {
385  PERR ("failed to parse tax table tree");
386  gncTaxTableDestroy (taxtable_pdata.table);
387  taxtable_pdata.table = NULL;
388  }
389 
390  return taxtable_pdata.table;
391 }
392 
393 static gboolean
394 gnc_taxtable_end_handler (gpointer data_for_children,
395  GSList* data_from_children, GSList* sibling_data,
396  gpointer parent_data, gpointer global_data,
397  gpointer* result, const gchar* tag)
398 {
400  xmlNodePtr tree = (xmlNodePtr)data_for_children;
401  gxpf_data* gdata = (gxpf_data*)global_data;
402  QofBook* book = static_cast<decltype (book)> (gdata->bookdata);
403 
404  if (parent_data)
405  {
406  return TRUE;
407  }
408 
409  /* OK. For some messed up reason this is getting called again with a
410  NULL tag. So we ignore those cases */
411  if (!tag)
412  {
413  return TRUE;
414  }
415 
416  g_return_val_if_fail (tree, FALSE);
417 
418  table = dom_tree_to_taxtable (tree, book);
419  if (table != NULL)
420  {
421  gdata->cb (tag, gdata->parsedata, table);
422  }
423 
424  xmlFreeNode (tree);
425 
426  return table != NULL;
427 }
428 
429 static sixtp*
430 taxtable_sixtp_parser_create (void)
431 {
432  return sixtp_dom_parser_new (gnc_taxtable_end_handler, NULL, NULL);
433 }
434 
435 static void
436 do_count (QofInstance* table_p, gpointer count_p)
437 {
438  int* count = static_cast<decltype (count)> (count_p);
439  (*count)++;
440 }
441 
442 static int
443 taxtable_get_count (QofBook* book)
444 {
445  int count = 0;
446  qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
447  return count;
448 }
449 
450 static void
451 xml_add_taxtable (QofInstance* table_p, gpointer out_p)
452 {
453  xmlNodePtr node;
454  GncTaxTable* table = (GncTaxTable*) table_p;
455  FILE* out = static_cast<decltype (out)> (out_p);
456 
457  if (ferror (out))
458  return;
459 
460  node = taxtable_dom_tree_create (table);
461  xmlElemDump (out, NULL, node);
462  xmlFreeNode (node);
463  if (ferror (out) || fprintf (out, "\n") < 0)
464  return;
465 }
466 
467 static gboolean
468 taxtable_write (FILE* out, QofBook* book)
469 {
470  qof_object_foreach_sorted (_GNC_MOD_NAME, book, xml_add_taxtable,
471  (gpointer) out);
472  return ferror (out) == 0;
473 }
474 
475 
476 static gboolean
477 taxtable_is_grandchild (GncTaxTable* table)
478 {
479  return (gncTaxTableGetParent (gncTaxTableGetParent (table)) != NULL);
480 }
481 
482 static GncTaxTable*
483 taxtable_find_senior (GncTaxTable* table)
484 {
485  GncTaxTable* temp, *parent, *gp = NULL;
486 
487  temp = table;
488  do
489  {
490  /* See if "temp" is a grandchild */
491  parent = gncTaxTableGetParent (temp);
492  if (!parent)
493  break;
494  gp = gncTaxTableGetParent (parent);
495  if (!gp)
496  break;
497 
498  /* Yep, this is a grandchild. Move up one generation and try again */
499  temp = parent;
500  }
501  while (TRUE);
502 
503  /* Ok, at this point temp points to the most senior child and parent
504  * should point to the top taxtable (and gp should be NULL). If
505  * parent is NULL then we are the most senior child (and have no
506  * children), so do nothing. If temp == table then there is no
507  * grandparent, so do nothing.
508  *
509  * Do something if parent != NULL && temp != table
510  */
511  g_assert (gp == NULL);
512 
513  /* return the most senior table */
514  return temp;
515 }
516 
517 /* build a list of tax tables that are grandchildren or bogus (empty entry list). */
518 static void
519 taxtable_scrub_cb (QofInstance* table_p, gpointer list_p)
520 {
521  GncTaxTable* table = GNC_TAXTABLE (table_p);
522  GList** list = static_cast<decltype (list)> (list_p);
523 
524  if (taxtable_is_grandchild (table) || gncTaxTableGetEntries (table) == NULL)
525  *list = g_list_prepend (*list, table);
526 }
527 
528 /* for each entry, check the tax tables. If the tax tables are
529  * grandchildren, then fix them to point to the most senior child
530  */
531 static void
532 taxtable_scrub_entries (QofInstance* entry_p, gpointer ht_p)
533 {
534  GHashTable* ht = static_cast<decltype (ht)> (ht_p);
535  GncEntry* entry = GNC_ENTRY (entry_p);
536  GncTaxTable* table, *new_tt;
537  gint32 count;
538 
539  table = gncEntryGetInvTaxTable (entry);
540  if (table)
541  {
542  if (taxtable_is_grandchild (table))
543  {
544  gchar guidstr[GUID_ENCODING_LENGTH + 1];
545  guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (entry)), guidstr);
546  PINFO ("Fixing i-taxtable on entry %s\n", guidstr);
547  new_tt = taxtable_find_senior (table);
548  gncEntryBeginEdit (entry);
549  gncEntrySetInvTaxTable (entry, new_tt);
550  gncEntryCommitEdit (entry);
551  table = new_tt;
552  }
553  if (table)
554  {
555  count = GPOINTER_TO_INT (g_hash_table_lookup (ht, table));
556  count++;
557  g_hash_table_insert (ht, table, GINT_TO_POINTER (count));
558  }
559  }
560 
561  table = gncEntryGetBillTaxTable (entry);
562  if (table)
563  {
564  if (taxtable_is_grandchild (table))
565  {
566  gchar guidstr[GUID_ENCODING_LENGTH + 1];
567  guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (entry)), guidstr);
568  PINFO ("Fixing b-taxtable on entry %s\n", guidstr);
569  new_tt = taxtable_find_senior (table);
570  gncEntryBeginEdit (entry);
571  gncEntrySetBillTaxTable (entry, new_tt);
572  gncEntryCommitEdit (entry);
573  table = new_tt;
574  }
575  if (table)
576  {
577  count = GPOINTER_TO_INT (g_hash_table_lookup (ht, table));
578  count++;
579  g_hash_table_insert (ht, table, GINT_TO_POINTER (count));
580  }
581  }
582 }
583 
584 static void
585 taxtable_scrub_cust (QofInstance* cust_p, gpointer ht_p)
586 {
587  GHashTable* ht = static_cast<decltype (ht)> (ht_p);
588  GncCustomer* cust = GNC_CUSTOMER (cust_p);
590  gint32 count;
591 
592  table = gncCustomerGetTaxTable (cust);
593  if (table)
594  {
595  count = GPOINTER_TO_INT (g_hash_table_lookup (ht, table));
596  count++;
597  g_hash_table_insert (ht, table, GINT_TO_POINTER (count));
598  }
599 }
600 
601 static void
602 taxtable_scrub_vendor (QofInstance* vendor_p, gpointer ht_p)
603 {
604  GHashTable* ht = static_cast<decltype (ht)> (ht_p);
605  GncVendor* vendor = GNC_VENDOR (vendor_p);
607  gint32 count;
608 
609  table = gncVendorGetTaxTable (vendor);
610  if (table)
611  {
612  count = GPOINTER_TO_INT (g_hash_table_lookup (ht, table));
613  count++;
614  g_hash_table_insert (ht, table, GINT_TO_POINTER (count));
615  }
616 }
617 
618 static void
619 taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused)
620 {
621  GncTaxTable* table = static_cast<decltype (table)> (key);
622  gint32 count = GPOINTER_TO_INT (value);
623 
624  if (count != gncTaxTableGetRefcount (table) &&
625  !gncTaxTableGetInvisible (table))
626  {
627  gchar guidstr[GUID_ENCODING_LENGTH + 1];
628  guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (table)), guidstr);
629  PWARN ("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n",
630  guidstr, gncTaxTableGetRefcount (table), count);
631  gncTaxTableSetRefcount (table, count);
632  }
633 }
634 
635 static void
636 taxtable_scrub (QofBook* book)
637 {
638  GList* list = NULL;
639  GList* node;
640  GncTaxTable* parent, *table;
641  GHashTable* ht = g_hash_table_new (g_direct_hash, g_direct_equal);
642 
643  qof_object_foreach (GNC_ID_ENTRY, book, taxtable_scrub_entries, ht);
644  qof_object_foreach (GNC_ID_CUSTOMER, book, taxtable_scrub_cust, ht);
645  qof_object_foreach (GNC_ID_VENDOR, book, taxtable_scrub_vendor, ht);
646  qof_object_foreach (GNC_ID_TAXTABLE, book, taxtable_scrub_cb, &list);
647 
648  /* destroy the list of "grandchildren" tax tables */
649  for (node = list; node; node = node->next)
650  {
651  gchar guidstr[GUID_ENCODING_LENGTH + 1];
652  table = static_cast<decltype (table)> (node->data);
653 
654  guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (table)), guidstr);
655  PINFO ("deleting grandchild taxtable: %s\n", guidstr);
656 
657  /* Make sure the parent has no children */
658  parent = gncTaxTableGetParent (table);
659  gncTaxTableSetChild (parent, NULL);
660 
661  /* Destroy this tax table */
662  gncTaxTableBeginEdit (table);
663  gncTaxTableDestroy (table);
664  }
665 
666  /* reset the refcounts as necessary */
667  g_hash_table_foreach (ht, taxtable_reset_refcount, NULL);
668 
669  g_list_free (list);
670  g_hash_table_destroy (ht);
671 }
672 
673 static gboolean
674 taxtable_ns (FILE* out)
675 {
676  g_return_val_if_fail (out, FALSE);
677  return
678  gnc_xml2_write_namespace_decl (out, "taxtable")
679  && gnc_xml2_write_namespace_decl (out, "tte");
680 }
681 
682 void
683 gnc_taxtable_xml_initialize (void)
684 {
685  static GncXmlDataType_t be_data =
686  {
687  GNC_FILE_BACKEND_VERS,
688  gnc_taxtable_string,
689  taxtable_sixtp_parser_create,
690  NULL, /* add_item */
691  taxtable_get_count,
692  taxtable_write,
693  taxtable_scrub,
694  taxtable_ns,
695  };
696 
697  gnc_xml_register_backend(be_data);
698 }
Definition: sixtp.h:129
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
STRUCTS.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Definition: guid.cpp:208
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
void qof_object_foreach_sorted(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke callback &#39;cb&#39; on each instance in guid orted order.
Definition: qofobject.cpp:223
api for GnuCash version 2 XML-based file format
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition: guid.h:84
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback &#39;cb&#39; on every instance ov a particular object type.
Definition: qofobject.cpp:185
credit, discount and shipaddr are unique to GncCustomer id, name, notes, terms, addr, currency, taxtable, taxtable_override taxincluded, active and jobs are identical to ::GncVendor.
Business Entry Interface.
GncAmountType
How to interpret the amount.
Definition: gncTaxTable.h:78
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability.txt for an explanation of the following Code that handles refcount, parent, child, invisible and children is identical to that in ::GncBillTerm
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.cpp:2048