31 #include <qofinstance-p.h>
36 #include "gncEntryP.h"
56 gboolean i_taxincluded;
60 GncDiscountHow i_disc_how;
66 gboolean b_taxincluded;
72 GncEntryPaymentType b_payment;
80 gboolean values_dirty;
116 case (GNC_DISC_PRETAX):
118 case (GNC_DISC_SAMETIME):
120 case (GNC_DISC_POSTTAX):
123 g_warning (
"asked to translate unknown discount-how %d.\n", how);
131 gboolean gncEntryDiscountStringToHow (
const char *str, GncDiscountHow *how)
133 if (g_strcmp0 (
"PRETAX", str) == 0)
135 *how = GNC_DISC_PRETAX;
138 if (g_strcmp0 (
"SAMETIME", str) == 0)
140 *how = GNC_DISC_SAMETIME;
143 if (g_strcmp0 (
"POSTTAX", str) == 0)
145 *how = GNC_DISC_POSTTAX;
148 g_warning (
"asked to translate unknown discount-how string %s.\n",
149 str ? str :
"(null)");
156 const char * gncEntryPaymentTypeToString (GncEntryPaymentType type)
160 case (GNC_PAYMENT_CASH):
162 case (GNC_PAYMENT_CARD):
165 g_warning (
"asked to translate unknown payment type %d.\n", type);
173 gboolean gncEntryPaymentStringToType (
const char *str, GncEntryPaymentType *type)
175 if (g_strcmp0 (
"CASH", str) == 0)
177 *type = GNC_PAYMENT_CASH;
180 if (g_strcmp0 (
"CARD", str) == 0)
182 *type = GNC_PAYMENT_CARD;
185 g_warning (
"asked to translate unknown discount-how string %s.\n",
186 str ? str :
"(null)");
191 #define _GNC_MOD_NAME GNC_ID_ENTRY
193 #define SET_STR(obj, member, str) { \
196 if (!g_strcmp0 (member, str)) return; \
197 gncEntryBeginEdit (obj); \
198 tmp = CACHE_INSERT (str); \
199 CACHE_REMOVE (member); \
203 G_INLINE_FUNC
void mark_entry (
GncEntry *entry);
206 qof_instance_set_dirty(&entry->inst);
244 G_DEFINE_TYPE(
GncEntry, gnc_entry, QOF_TYPE_INSTANCE);
252 gnc_entry_dispose(GObject *entryp)
254 G_OBJECT_CLASS(gnc_entry_parent_class)->dispose(entryp);
258 gnc_entry_finalize(GObject* entryp)
260 G_OBJECT_CLASS(gnc_entry_parent_class)->finalize(entryp);
264 gnc_entry_get_property (GObject *
object,
271 g_return_if_fail(GNC_IS_ENTRY(
object));
273 entry = GNC_ENTRY(
object);
276 case PROP_DESCRIPTION:
277 g_value_set_string(value, entry->desc);
280 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
286 gnc_entry_set_property (GObject *
object,
293 g_return_if_fail(GNC_IS_ENTRY(
object));
295 entry = GNC_ENTRY(
object);
296 g_assert (qof_instance_get_editlevel(entry));
300 case PROP_DESCRIPTION:
301 gncEntrySetDescription(entry, g_value_get_string(value));
304 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
317 g_return_val_if_fail(inst != NULL, FALSE);
318 g_return_val_if_fail(GNC_IS_ENTRY(inst), FALSE);
320 entry = GNC_ENTRY(inst);
321 if (entry->order != NULL)
324 s = g_strdup_printf(
"Entry in %s", display_name);
325 g_free(display_name);
328 if (entry->invoice != NULL)
331 s = g_strdup_printf(
"Entry in %s", display_name);
332 g_free(display_name);
335 if (entry->bill != NULL)
338 s = g_strdup_printf(
"Entry in %s", display_name);
339 g_free(display_name);
343 return g_strdup_printf(
"Entry %p", inst);
352 g_return_val_if_fail(inst != NULL, FALSE);
353 g_return_val_if_fail(GNC_IS_ENTRY(inst), FALSE);
355 entry = GNC_ENTRY(inst);
357 if (GNC_IS_ACCOUNT(ref))
359 Account* acc = GNC_ACCOUNT(ref);
360 return (entry->i_account == acc || entry->b_account == acc);
362 else if (GNC_IS_TAXTABLE(ref))
365 return (entry->i_tax_table == tt || entry->b_tax_table == tt);
380 if (!GNC_IS_ACCOUNT(ref) && !GNC_IS_TAXTABLE(ref))
391 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
394 gobject_class->dispose = gnc_entry_dispose;
395 gobject_class->finalize = gnc_entry_finalize;
396 gobject_class->set_property = gnc_entry_set_property;
397 gobject_class->get_property = gnc_entry_get_property;
399 qof_class->get_display_name = impl_get_display_name;
400 qof_class->refers_to_object = impl_refers_to_object;
401 qof_class->get_typed_referring_object_list = impl_get_typed_referring_object_list;
403 g_object_class_install_property
406 g_param_spec_string (
"description",
408 "The description is an arbitrary string "
409 "assigned by the user. It provides identification "
421 if (!book)
return NULL;
423 entry = g_object_new (GNC_TYPE_ENTRY, NULL);
426 entry->desc = CACHE_INSERT (
"");
427 entry->action = CACHE_INSERT (
"");
428 entry->notes = CACHE_INSERT (
"");
429 entry->quantity = zero;
431 entry->i_price = zero;
432 entry->i_taxable = TRUE;
433 entry->i_discount = zero;
435 entry->i_disc_how = GNC_DISC_PRETAX;
437 entry->b_price = zero;
438 entry->b_taxable = TRUE;
439 entry->billto.type = GNC_OWNER_CUSTOMER;
440 entry->b_payment = GNC_PAYMENT_CASH;
442 entry->values_dirty = TRUE;
449 void gncEntryDestroy (
GncEntry *entry)
452 qof_instance_set_destroying(entry, TRUE);
453 gncEntryCommitEdit(entry);
456 static void gncEntryFree (
GncEntry *entry)
462 CACHE_REMOVE (entry->desc);
463 CACHE_REMOVE (entry->action);
464 CACHE_REMOVE (entry->notes);
465 if (entry->i_tax_values)
467 if (entry->b_tax_values)
469 if (entry->i_tax_table)
470 gncTaxTableDecRef (entry->i_tax_table);
471 if (entry->b_tax_table)
472 gncTaxTableDecRef (entry->b_tax_table);
475 g_object_unref (entry);
483 gboolean first_date = FALSE;
490 gncEntryBeginEdit (entry);
493 gncEntryCommitEdit (entry);
507 if (!entry || !date || !g_date_valid(date))
522 gncEntryBeginEdit (entry);
523 entry->date_entered = date;
525 gncEntryCommitEdit (entry);
528 void gncEntrySetDescription (
GncEntry *entry,
const char *desc)
530 if (!entry || !desc)
return;
531 SET_STR (entry, entry->desc, desc);
533 gncEntryCommitEdit (entry);
536 void gncEntrySetAction (
GncEntry *entry,
const char *action)
538 if (!entry || !action)
return;
539 SET_STR (entry, entry->action, action);
541 gncEntryCommitEdit (entry);
544 void gncEntrySetNotes (
GncEntry *entry,
const char *notes)
546 if (!entry || !notes)
return;
547 SET_STR (entry, entry->notes, notes);
549 gncEntryCommitEdit (entry);
556 gncEntryBeginEdit (entry);
557 entry->quantity = quantity;
558 entry->values_dirty = TRUE;
560 gncEntryCommitEdit (entry);
567 gncEntryBeginEdit (entry);
569 entry->values_dirty = TRUE;
571 gncEntryCommitEdit (entry);
579 if (entry->i_account == acc)
return;
580 gncEntryBeginEdit (entry);
581 entry->i_account = acc;
583 gncEntryCommitEdit (entry);
590 gncEntryBeginEdit (entry);
591 entry->i_price = price;
592 entry->values_dirty = TRUE;
594 gncEntryCommitEdit (entry);
597 void gncEntrySetInvTaxable (
GncEntry *entry, gboolean taxable)
600 if (entry->i_taxable == taxable)
return;
601 gncEntryBeginEdit (entry);
602 entry->i_taxable = taxable;
603 entry->values_dirty = TRUE;
605 gncEntryCommitEdit (entry);
608 void gncEntrySetInvTaxIncluded (
GncEntry *entry, gboolean taxincluded)
611 if (entry->i_taxincluded == taxincluded)
return;
612 gncEntryBeginEdit (entry);
613 entry->i_taxincluded = taxincluded;
614 entry->values_dirty = TRUE;
616 gncEntryCommitEdit (entry);
622 if (entry->i_tax_table == table)
return;
623 gncEntryBeginEdit (entry);
624 if (entry->i_tax_table)
625 gncTaxTableDecRef (entry->i_tax_table);
627 gncTaxTableIncRef (table);
628 entry->i_tax_table = table;
629 entry->values_dirty = TRUE;
631 gncEntryCommitEdit (entry);
638 gncEntryBeginEdit (entry);
639 entry->i_discount = discount;
640 entry->values_dirty = TRUE;
642 gncEntryCommitEdit (entry);
648 if (entry->i_disc_type == type)
return;
650 gncEntryBeginEdit (entry);
651 entry->i_disc_type = type;
652 entry->values_dirty = TRUE;
654 gncEntryCommitEdit (entry);
657 void gncEntrySetInvDiscountHow (
GncEntry *entry, GncDiscountHow how)
660 if (entry->i_disc_how == how)
return;
662 gncEntryBeginEdit (entry);
663 entry->i_disc_how = how;
664 entry->values_dirty = TRUE;
666 gncEntryCommitEdit (entry);
669 void qofEntrySetInvDiscType (
GncEntry *entry,
const char *type_string)
674 gncAmountStringToType(type_string, &type);
675 if (entry->i_disc_type == type)
return;
676 gncEntryBeginEdit (entry);
677 entry->i_disc_type = type;
678 entry->values_dirty = TRUE;
680 gncEntryCommitEdit (entry);
684 void qofEntrySetInvDiscHow (
GncEntry *entry,
const char *type)
686 GncDiscountHow how = GNC_DISC_PRETAX;
689 gncEntryBeginEdit (entry);
690 gncEntryDiscountStringToHow(type, &how);
691 if (entry->i_disc_how == how)
return;
692 entry->i_disc_how = how;
693 entry->values_dirty = TRUE;
695 gncEntryCommitEdit (entry);
703 if (entry->b_account == acc)
return;
704 gncEntryBeginEdit (entry);
705 entry->b_account = acc;
707 gncEntryCommitEdit (entry);
714 gncEntryBeginEdit (entry);
715 entry->b_price = price;
716 entry->values_dirty = TRUE;
718 gncEntryCommitEdit (entry);
721 void gncEntrySetBillTaxable (
GncEntry *entry, gboolean taxable)
724 if (entry->b_taxable == taxable)
return;
725 gncEntryBeginEdit (entry);
726 entry->b_taxable = taxable;
727 entry->values_dirty = TRUE;
729 gncEntryCommitEdit (entry);
732 void gncEntrySetBillTaxIncluded (
GncEntry *entry, gboolean taxincluded)
735 if (entry->b_taxincluded == taxincluded)
return;
736 gncEntryBeginEdit (entry);
737 entry->b_taxincluded = taxincluded;
738 entry->values_dirty = TRUE;
740 gncEntryCommitEdit (entry);
746 if (entry->b_tax_table == table)
return;
747 gncEntryBeginEdit (entry);
748 if (entry->b_tax_table)
749 gncTaxTableDecRef (entry->b_tax_table);
751 gncTaxTableIncRef (table);
752 entry->b_tax_table = table;
753 entry->values_dirty = TRUE;
755 gncEntryCommitEdit (entry);
758 void gncEntrySetBillable (
GncEntry *entry, gboolean billable)
761 if (entry->billable == billable)
return;
763 gncEntryBeginEdit (entry);
764 entry->billable = billable;
766 gncEntryCommitEdit (entry);
771 if (!entry || !billto)
return;
774 gncEntryBeginEdit (entry);
775 gncOwnerCopy (billto, &entry->billto);
777 gncEntryCommitEdit (entry);
780 void gncEntrySetBillPayment (
GncEntry *entry, GncEntryPaymentType type)
783 if (entry->b_payment == type)
return;
784 gncEntryBeginEdit (entry);
785 entry->b_payment = type;
787 gncEntryCommitEdit (entry);
794 if (entry->order == order)
return;
795 gncEntryBeginEdit (entry);
796 entry->order = order;
798 gncEntryCommitEdit (entry);
806 if (entry->invoice == invoice)
return;
807 gncEntryBeginEdit (entry);
808 entry->invoice = invoice;
810 gncEntryCommitEdit (entry);
817 if (entry->bill == bill)
return;
818 gncEntryBeginEdit (entry);
821 gncEntryCommitEdit (entry);
826 if (!src || !dest)
return;
828 gncEntryBeginEdit (dest);
829 dest->date = src->date;
830 dest->date_entered = src->date_entered;
831 gncEntrySetDescription (dest, src->desc);
832 gncEntrySetAction (dest, src->action);
833 gncEntrySetNotes (dest, src->notes);
834 dest->quantity = src->quantity;
836 dest->i_account = src->i_account;
837 dest->i_price = src->i_price;
838 dest->i_taxable = src->i_taxable;
839 dest->i_taxincluded = src->i_taxincluded;
840 dest->i_discount = src->i_discount;
841 dest->i_disc_type = src->i_disc_type;
842 dest->i_disc_how = src->i_disc_how;
845 dest->b_account = src->b_account;
846 dest->b_price = src->b_price;
847 dest->b_taxable = src->b_taxable;
848 dest->b_taxincluded = src->b_taxincluded;
849 dest->billable = src->billable;
850 dest->billto = src->billto;
852 if (src->i_tax_table)
853 gncEntrySetInvTaxTable (dest, src->i_tax_table);
855 if (src->b_tax_table)
856 gncEntrySetBillTaxTable (dest, src->b_tax_table);
861 gncOrderAddEntry (src->order, dest);
864 gncInvoiceAddEntry (src->invoice, dest);
870 dest->values_dirty = TRUE;
872 gncEntryCommitEdit (dest);
883 if (!entry)
return ts;
897 if (!entry)
return ts;
898 return entry->date_entered;
901 const char * gncEntryGetDescription (
const GncEntry *entry)
903 if (!entry)
return NULL;
907 const char * gncEntryGetAction (
const GncEntry *entry)
909 if (!entry)
return NULL;
910 return entry->action;
913 const char * gncEntryGetNotes (
const GncEntry *entry)
915 if (!entry)
return NULL;
921 if (!entry)
return gnc_numeric_zero();
922 return entry->quantity;
935 if (!entry)
return NULL;
936 return entry->i_account;
941 if (!entry)
return gnc_numeric_zero();
942 return entry->i_price;
947 if (!entry)
return gnc_numeric_zero();
948 return entry->i_discount;
953 if (!entry)
return 0;
954 return entry->i_disc_type;
957 GncDiscountHow gncEntryGetInvDiscountHow (
const GncEntry *entry)
959 if (!entry)
return 0;
960 return entry->i_disc_how;
963 char* qofEntryGetInvDiscType (
const GncEntry *entry)
967 if (!entry)
return 0;
968 type_string = g_strdup(gncAmountTypeToString(entry->i_disc_type));
972 char* qofEntryGetInvDiscHow (
const GncEntry *entry)
976 if (!entry)
return 0;
981 gboolean gncEntryGetInvTaxable (
const GncEntry *entry)
983 if (!entry)
return FALSE;
984 return entry->i_taxable;
987 gboolean gncEntryGetInvTaxIncluded (
const GncEntry *entry)
989 if (!entry)
return FALSE;
990 return entry->i_taxincluded;
995 if (!entry)
return NULL;
996 return entry->i_tax_table;
1003 if (!entry)
return NULL;
1004 return entry->b_account;
1009 if (!entry)
return gnc_numeric_zero();
1010 return entry->b_price;
1013 gboolean gncEntryGetBillTaxable (
const GncEntry *entry)
1015 if (!entry)
return FALSE;
1016 return entry->b_taxable;
1019 gboolean gncEntryGetBillTaxIncluded (
const GncEntry *entry)
1021 if (!entry)
return FALSE;
1022 return entry->b_taxincluded;
1027 if (!entry)
return NULL;
1028 return entry->b_tax_table;
1031 gboolean gncEntryGetBillable (
const GncEntry *entry)
1033 if (!entry)
return FALSE;
1034 return entry->billable;
1039 if (!entry)
return NULL;
1040 return &entry->billto;
1043 GncEntryPaymentType gncEntryGetBillPayment (
const GncEntry* entry)
1045 if (!entry)
return 0;
1046 return entry->b_payment;
1051 if (!entry)
return NULL;
1052 return entry->invoice;
1057 if (!entry)
return NULL;
1063 if (!entry)
return NULL;
1064 return entry->order;
1103 const GncTaxTable *tax_table, gboolean tax_included,
1105 GncDiscountHow discount_how,
int SCU,
1113 gnc_numeric percent = gnc_numeric_create (100, 1);
1117 GList * entries = gncTaxTableGetEntries (tax_table);
1127 for (node = entries; node; node = node->next)
1130 gnc_numeric amount = gncTaxTableEntryGetAmount (entry);
1132 switch (gncTaxTableEntryGetType (entry))
1143 g_warning (
"Unknown tax type: %d", gncTaxTableEntryGetType (entry));
1154 if (tax_table && tax_included)
1164 gnc_numeric_create (1, 1),
1192 switch (discount_how)
1194 case GNC_DISC_PRETAX:
1195 case GNC_DISC_SAMETIME:
1209 if (discount_how == GNC_DISC_PRETAX)
1213 case GNC_DISC_POSTTAX:
1234 g_warning (
"unknown DiscountHow value: %d", discount_how);
1245 if (discount_value != NULL)
1248 *discount_value = discount;
1259 if (tax_value != NULL)
1261 GList * taxes = NULL;
1263 for (node = entries; node; node = node->next)
1266 Account *acc = gncTaxTableEntryGetAccount (entry);
1267 gnc_numeric amount = gncTaxTableEntryGetAmount (entry);
1269 g_return_if_fail (acc);
1271 switch (gncTaxTableEntryGetType (entry))
1295 get_entry_commodity_denom (
const GncEntry *entry)
1302 c = gncInvoiceGetCurrency (entry->invoice);
1308 c = gncInvoiceGetCurrency (entry->bill);
1316 gncEntryRecomputeValues (
GncEntry *entry)
1321 if (entry->i_tax_table)
1323 Timespec modtime = gncTaxTableLastModified (entry->i_tax_table);
1324 if (
timespec_cmp (&entry->i_taxtable_modtime, &modtime))
1326 entry->values_dirty = TRUE;
1327 entry->i_taxtable_modtime = modtime;
1330 if (entry->b_tax_table)
1332 Timespec modtime = gncTaxTableLastModified (entry->b_tax_table);
1333 if (
timespec_cmp (&entry->b_taxtable_modtime, &modtime))
1335 entry->values_dirty = TRUE;
1336 entry->b_taxtable_modtime = modtime;
1340 if (!entry->values_dirty)
1344 if (entry->i_tax_values)
1347 entry->i_tax_values = NULL;
1349 if (entry->b_tax_values)
1352 entry->b_tax_values = NULL;
1356 denom = get_entry_commodity_denom (entry);
1360 (entry->i_taxable ? entry->i_tax_table : NULL),
1361 entry->i_taxincluded,
1362 entry->i_discount, entry->i_disc_type,
1365 &(entry->i_value), &(entry->i_disc_value),
1366 &(entry->i_tax_values));
1370 (entry->b_taxable ? entry->b_tax_table : NULL),
1371 entry->b_taxincluded,
1374 &(entry->b_value), NULL, &(entry->b_tax_values));
1389 entry->values_dirty = FALSE;
1394 static gnc_numeric gncEntryGetIntValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc)
1396 if (!entry)
return gnc_numeric_zero();
1397 gncEntryRecomputeValues (entry);
1399 return (is_cust_doc ? entry->i_value_rounded : entry->b_value_rounded);
1401 return (is_cust_doc ? entry->i_value : entry->b_value);
1404 static gnc_numeric gncEntryGetIntTaxValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc)
1406 if (!entry)
return gnc_numeric_zero();
1407 gncEntryRecomputeValues (entry);
1409 return (is_cust_doc ? entry->i_tax_value_rounded : entry->b_tax_value_rounded);
1411 return (is_cust_doc ? entry->i_tax_value : entry->b_tax_value);
1415 static AccountValueList * gncEntryGetIntTaxValues (
GncEntry *entry, gboolean is_cust_doc)
1417 if (!entry)
return NULL;
1418 gncEntryRecomputeValues (entry);
1419 return (is_cust_doc ? entry->i_tax_values : entry->b_tax_values);
1422 static gnc_numeric gncEntryGetIntDiscountValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc)
1424 if (!entry)
return gnc_numeric_zero();
1425 gncEntryRecomputeValues (entry);
1427 return (is_cust_doc ? entry->i_disc_value_rounded : gnc_numeric_zero());
1429 return (is_cust_doc ? entry->i_disc_value : gnc_numeric_zero());
1432 gnc_numeric gncEntryGetDocValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
1434 gnc_numeric value = gncEntryGetIntValue (entry, round, is_cust_doc);
1438 gnc_numeric gncEntryGetDocTaxValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
1440 gnc_numeric value = gncEntryGetIntTaxValue (entry, round, is_cust_doc);
1447 AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1448 AccountValueList *values = NULL, *node;
1451 for (node = int_values; node; node = node->next)
1456 : acct_val->value));
1462 gnc_numeric gncEntryGetDocDiscountValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
1464 gnc_numeric value = gncEntryGetIntDiscountValue (entry, round, is_cust_doc);
1470 gnc_numeric value = gncEntryGetIntValue (entry, round, is_cust_doc);
1474 gnc_numeric gncEntryGetBalTaxValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc)
1476 gnc_numeric value = gncEntryGetIntTaxValue (entry, round, is_cust_doc);
1483 AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1484 AccountValueList *values = NULL, *node;
1487 for (node = int_values; node; node = node->next)
1492 : acct_val->value));
1498 gnc_numeric gncEntryGetBalDiscountValue (
GncEntry *entry, gboolean round, gboolean is_cust_doc)
1500 gnc_numeric value = gncEntryGetIntDiscountValue (entry, round, is_cust_doc);
1505 gboolean gncEntryIsOpen (
const GncEntry *entry)
1507 if (!entry)
return FALSE;
1508 return (qof_instance_get_editlevel(entry) > 0);
1513 void gncEntryBeginEdit (
GncEntry *entry)
1520 PERR(
"Entry QofBackend Failure: %d", errcode);
1521 gnc_engine_signal_commit_error( errcode );
1529 gncEntryFree (entry);
1532 void gncEntryCommitEdit (
GncEntry *entry)
1540 gncEntryOnDone, entry_free);
1547 if (a == b)
return 0;
1548 if (!a && b)
return -1;
1549 if (a && !b)
return 1;
1552 if (compare)
return compare;
1554 compare =
timespec_cmp (&(a->date_entered), &(b->date_entered));
1555 if (compare)
return compare;
1557 compare = g_strcmp0 (a->desc, b->desc);
1558 if (compare)
return compare;
1560 compare = g_strcmp0 (a->action, b->action);
1561 if (compare)
return compare;
1566 #define CHECK_STRING(X, Y, FIELD) \
1567 if (g_strcmp0((X)->FIELD, (Y)->FIELD) != 0) \
1569 PWARN("%s differ: %s vs %s", #FIELD, (X)->FIELD, (Y)->FIELD); \
1573 #define CHECK_ACCOUNT(X, Y, FIELD) \
1574 if (!xaccAccountEqual((X)->FIELD, (Y)->FIELD, TRUE)) \
1576 PWARN("%s differ", #FIELD); \
1580 #define CHECK_NUMERIC(X, Y, FIELD) \
1581 if (!gnc_numeric_equal((X)->FIELD, (Y)->FIELD)) \
1583 PWARN("%s differ", #FIELD); \
1587 #define CHECK_VALUE(X, Y, FIELD) \
1588 if ((X)->FIELD != (Y)->FIELD) \
1590 PWARN("%s differ", #FIELD); \
1599 destroy_entry_on_book_close(
QofInstance *ent, gpointer data)
1603 gncEntryBeginEdit(entry);
1604 gncEntryDestroy(entry);
1612 gnc_entry_book_end(
QofBook* book)
1623 DI(.e_type = ) _GNC_MOD_NAME,
1624 DI(.type_label = ) "Order/Invoice/Bill Entry",
1625 DI(.create = ) (gpointer)gncEntryCreate,
1626 DI(.book_begin = ) NULL,
1627 DI(.book_end = ) gnc_entry_book_end,
1631 DI(.printable = ) NULL,
1635 gboolean gncEntryRegister (
void)
1647 { ENTRY_INVOICE, GNC_ID_INVOICE, (
QofAccessFunc)gncEntryGetInvoice, NULL },
1650 { ENTRY_BILL, GNC_ID_INVOICE, (
QofAccessFunc)gncEntryGetBill, NULL },
1652 ENTRY_INV_DISC_TYPE, QOF_TYPE_STRING, (
QofAccessFunc)qofEntryGetInvDiscType,
1656 ENTRY_INV_DISC_HOW, QOF_TYPE_STRING, (
QofAccessFunc)qofEntryGetInvDiscHow,
1660 ENTRY_INV_TAXABLE, QOF_TYPE_BOOLEAN, (
QofAccessFunc)gncEntryGetInvTaxable,
1664 ENTRY_INV_TAX_INC, QOF_TYPE_BOOLEAN, (
QofAccessFunc)gncEntryGetInvTaxIncluded,
1668 ENTRY_BILL_TAXABLE, QOF_TYPE_BOOLEAN, (
QofAccessFunc)gncEntryGetBillTaxable,
1672 ENTRY_BILL_TAX_INC, QOF_TYPE_BOOLEAN, (
QofAccessFunc)gncEntryGetBillTaxIncluded,
1677 { ENTRY_ORDER, GNC_ID_ORDER, (
QofAccessFunc)gncEntryGetOrder, NULL },
int qof_instance_version_cmp(const QofInstance *left, const QofInstance *right)
int gnc_commodity_get_fraction(const gnc_commodity *cm)
const GncGUID * qof_instance_get_guid(gconstpointer)
void gncEntrySetQuantity(GncEntry *entry, gnc_numeric quantity)
void gncEntrySetDate(GncEntry *entry, Timespec date)
QofBook * qof_instance_get_book(gconstpointer)
gboolean qof_collection_is_dirty(const QofCollection *col)
QofBackendError
The errors that can be reported to the GUI & other front-end users.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
gboolean kvp_frame_is_empty(const KvpFrame *frame)
Timespec timespecCanonicalDayTime(Timespec t)
GList * qof_instance_get_referring_object_list_from_collection(const QofCollection *coll, const QofInstance *ref)
void gnc_features_set_used(QofBook *book, const gchar *feature)
AccountValueList * gncEntryGetDocTaxValues(GncEntry *entry, gboolean is_cust_doc, gboolean is_cn)
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_fcn, const QofParam *params)
gboolean timespec_equal(const Timespec *ta, const Timespec *tb)
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Use a 64-bit unsigned int timespec.
Timespec gncEntryGetDate(const GncEntry *entry)
QofCollection * qof_instance_get_collection(gconstpointer inst)
gnc_numeric gncAccountValueTotal(GList *list)
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
void gncInvoiceSortEntries(GncInvoice *invoice)
void gncEntrySetDocQuantity(GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
#define QOF_OBJECT_VERSION
gboolean qof_commit_edit(QofInstance *inst)
#define PERR(format, args...)
void qof_collection_foreach(const QofCollection *, QofInstanceForeachCB, gpointer user_data)
void qof_instance_init_data(QofInstance *, QofIdType, QofBook *)
gint timespec_cmp(const Timespec *ta, const Timespec *tb)
gboolean qof_begin_edit(QofInstance *inst)
GDate timespec_to_gdate(Timespec ts)
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
AccountValueList * gncEntryGetBalTaxValues(GncEntry *entry, gboolean is_cust_doc)
void gncEntryComputeValue(gnc_numeric qty, gnc_numeric price, const GncTaxTable *tax_table, gboolean tax_included, gnc_numeric discount, GncAmountType discount_type, GncDiscountHow discount_how, int SCU, gnc_numeric *value, gnc_numeric *discount_value, GList **tax_value)
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
void gncBillAddEntry(GncInvoice *bill, GncEntry *entry)
GDate gncEntryGetDateGDate(const GncEntry *entry)
int(* QofSortFunc)(gconstpointer, gconstpointer)
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
void gncEntrySetDateGDate(GncEntry *entry, const GDate *date)
void qof_collection_mark_clean(QofCollection *)
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
void gncAccountValueDestroy(GList *list)
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
const char * gncEntryDiscountHowToString(GncDiscountHow how)
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Business Invoice Interface.
gint qof_instance_guid_compare(const gconstpointer ptr1, const gconstpointer ptr2)
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
void(* QofSetterFunc)(gpointer, gpointer)
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
Timespec gdate_to_timespec(GDate d)
gboolean qof_object_register(const QofObject *object)
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
Business Entry Interface.
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
gnc_numeric gncEntryGetDocQuantity(const GncEntry *entry, gboolean is_cn)
Commodity handling public routines.
const gchar * QofLogModule
gchar * qof_instance_get_display_name(const QofInstance *inst)
Utility functions for file access.