/* ================================================================= */ gboolean gnc_sql_save_billterm (GncSqlBackend* be, QofInstance* inst) { g_return_val_if_fail (inst != NULL, FALSE); g_return_val_if_fail (GNC_IS_BILLTERM (inst), FALSE); g_return_val_if_fail (be != NULL, FALSE); return gnc_sql_commit_standard_item (be, inst, TABLE_NAME, GNC_ID_BILLTERM, col_table); }
/** Returns a list of my type of object which refers to an object. For example, when called as qof_instance_get_typed_referring_object_list(taxtable, account); it will return the list of taxtables which refer to a specific account. The result should be the same regardless of which taxtable object is used. The list must be freed by the caller but the objects on the list must not. */ static GList* impl_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref) { if (!GNC_IS_BILLTERM(ref) && !GNC_IS_TAXTABLE(ref)) { return NULL; } return qof_instance_get_referring_object_list_from_collection(qof_instance_get_collection(inst), ref); }
/** Does this object refer to a specific object */ static gboolean impl_refers_to_object(const QofInstance* inst, const QofInstance* ref) { GncCustomer* cust; g_return_val_if_fail(inst != NULL, FALSE); g_return_val_if_fail(GNC_IS_CUSTOMER(inst), FALSE); cust = GNC_CUSTOMER(inst); if (GNC_IS_BILLTERM(ref)) { return (cust->terms == GNC_BILLTERM(ref)); } else if (GNC_IS_TAXTABLE(ref)) { return (cust->taxtable == GNC_TAXTABLE(ref)); } return FALSE; }
static void gnc_billterm_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GncBillTerm *bt; g_return_if_fail(GNC_IS_BILLTERM(object)); bt = GNC_BILLTERM(object); switch (prop_id) { case PROP_NAME: g_value_set_string(value, bt->name); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
static void bt_set_parent (gpointer data, gpointer value) { GncBillTerm* billterm; GncBillTerm* parent; QofBook* pBook; GncGUID* guid = (GncGUID*)value; g_return_if_fail (data != NULL); g_return_if_fail (GNC_IS_BILLTERM (data)); billterm = GNC_BILLTERM (data); pBook = qof_instance_get_book (QOF_INSTANCE (billterm)); if (guid != NULL) { parent = gncBillTermLookup (pBook, guid); if (parent != NULL) { gncBillTermSetParent (billterm, parent); gncBillTermSetChild (parent, billterm); } } }
static gpointer bt_get_parent (gpointer pObject) { const GncBillTerm* billterm; const GncBillTerm* pParent; const GncGUID* parent_guid; g_return_val_if_fail (pObject != NULL, NULL); g_return_val_if_fail (GNC_IS_BILLTERM (pObject), NULL); billterm = GNC_BILLTERM (pObject); pParent = gncBillTermGetParent (billterm); if (pParent == NULL) { parent_guid = NULL; } else { parent_guid = qof_instance_get_guid (QOF_INSTANCE (pParent)); } return (gpointer)parent_guid; }
static void gnc_billterm_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GncBillTerm *bt; g_return_if_fail(GNC_IS_BILLTERM(object)); bt = GNC_BILLTERM(object); g_assert (qof_instance_get_editlevel(bt)); switch (prop_id) { case PROP_NAME: gncBillTermSetName(bt, g_value_get_string(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
gboolean gncBillTermEqual(const GncBillTerm *a, const GncBillTerm *b) { if (a == NULL && b == NULL) return TRUE; if (a == NULL || b == NULL) return FALSE; g_return_val_if_fail(GNC_IS_BILLTERM(a), FALSE); g_return_val_if_fail(GNC_IS_BILLTERM(b), FALSE); if (g_strcmp0(a->name, b->name) != 0) { PWARN("Names differ: %s vs %s", a->name, b->name); return FALSE; } if (g_strcmp0(a->desc, b->desc) != 0) { PWARN("Descriptions differ: %s vs %s", a->desc, b->desc); return FALSE; } if (a->type != b->type) { PWARN("Types differ"); return FALSE; } if (a->due_days != b->due_days) { PWARN("Due days differ: %d vs %d", a->due_days, b->due_days); return FALSE; } if (a->disc_days != b->disc_days) { PWARN("Discount days differ: %d vs %d", a->disc_days, b->disc_days); return FALSE; } if (!gnc_numeric_equal(a->discount, b->discount)) { PWARN("Discounts differ"); return FALSE; } if (a->cutoff != b->cutoff) { PWARN("Cutoffs differ: %d vs %d", a->cutoff, b->cutoff); return FALSE; } if (a->invisible != b->invisible) { PWARN("Invisible flags differ"); return FALSE; } // gint64 refcount; // GncBillTerm * parent; /* if non-null, we are an immutable child */ // GncBillTerm * child; /* if non-null, we have not changed */ // GList * children; /* list of children for disconnection */ return TRUE; }