GnuCash 2.3.0
Files | Defines | Typedefs | Functions
BillTerm
Business

Files

file  gncBillTerm.h
 

Billing Term interface.


Defines

#define GNC_ID_BILLTERM   "gncBillTerm"
#define GNC_TYPE_BILLTERM   (gnc_billterm_get_type ())
#define GNC_BILLTERM(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILLTERM, GncBillTerm))
#define GNC_BILLTERM_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILLTERM, GncBillTermClass))
#define GNC_IS_BILLTERM(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILLTERM))
#define GNC_IS_BILLTERM_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILLTERM))
#define GNC_BILLTERM_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILLTERM, GncBillTermClass))
#define ENUM_TERMS_TYPE(_)
#define gncBillTermGetGUID(x)   qof_instance_get_guid (QOF_INSTANCE(x))

Typedefs

typedef struct _gncBillTerm GncBillTerm
typedef struct _gncBillTermClass GncBillTermClass

Functions

GType gnc_billterm_get_type (void)
Timespec gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date)

BillTerm parameter names

#define GNC_BILLTERM_NAME   "name"
#define GNC_BILLTERM_DESC   "description"
#define GNC_BILLTERM_DUEDAYS   "number of days due"
#define GNC_BILLTERM_DISCDAYS   "number of discounted days"
#define GNC_BILLTERM_CUTOFF   "cut off"
#define GNC_BILLTERM_TYPE   "bill type"
#define GNC_BILLTERM_DISCOUNT   "amount of discount"
#define GNC_BILLTERM_REFCOUNT   "reference count"

Create/Destroy Functions

GncBillTermgncBillTermCreate (QofBook *book)
void gncBillTermDestroy (GncBillTerm *term)
void gncBillTermIncRef (GncBillTerm *term)
void gncBillTermDecRef (GncBillTerm *term)
void gncBillTermChanged (GncBillTerm *term)
void gncBillTermBeginEdit (GncBillTerm *term)
void gncBillTermCommitEdit (GncBillTerm *term)

Set Functions

void gncBillTermSetName (GncBillTerm *term, const char *name)
void gncBillTermSetDescription (GncBillTerm *term, const char *name)
void gncBillTermSetType (GncBillTerm *term, GncBillTermType type)
void gncBillTermSetDueDays (GncBillTerm *term, gint days)
void gncBillTermSetDiscountDays (GncBillTerm *term, gint days)
void gncBillTermSetDiscount (GncBillTerm *term, gnc_numeric discount)
void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff)

Get Functions

GncBillTermgncBillTermLookupByName (QofBook *book, const char *name)
GList * gncBillTermGetTerms (QofBook *book)
const char * gncBillTermGetName (const GncBillTerm *term)
const char * gncBillTermGetDescription (const GncBillTerm *term)
GncBillTermType gncBillTermGetType (const GncBillTerm *term)
gint gncBillTermGetDueDays (const GncBillTerm *term)
gint gncBillTermGetDiscountDays (const GncBillTerm *term)
gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term)
gint gncBillTermGetCutoff (const GncBillTerm *term)
gboolean gncBillTermIsDirty (const GncBillTerm *term)
GncBillTermgncBillTermGetParent (const GncBillTerm *term)
GncBillTermgncBillTermReturnChild (GncBillTerm *term, gboolean make_new)
gint64 gncBillTermGetRefcount (const GncBillTerm *term)
#define gncBillTermGetChild(t)   gncBillTermReturnChild((t),FALSE)

Comparison Functions

int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b)
gboolean gncBillTermEqual (const GncBillTerm *a, const GncBillTerm *b)
gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b)

Define Documentation

#define ENUM_TERMS_TYPE (   _)
Value:
_(GNC_TERM_TYPE_DAYS,=1) \
 _(GNC_TERM_TYPE_PROXIMO,)

How to interpret the amount. You can interpret it as a VALUE or a PERCENT. ??? huh? NOTE: This enum /depends/ on starting at value 1

Definition at line 76 of file gncBillTerm.h.


Function Documentation

int gncBillTermCompare ( const GncBillTerm a,
const GncBillTerm b 
)

Compare BillTerms on their name for sorting.

Definition at line 620 of file gncBillTerm.c.

{
    int ret;

    if (!a && !b) return 0;
    if (!a) return -1;
    if (!b) return 1;

    ret = safe_strcmp (a->name, b->name);
    if (ret) return ret;

    return safe_strcmp (a->desc, b->desc);
}
gboolean gncBillTermEqual ( const GncBillTerm a,
const GncBillTerm b 
)

Check if all internal fields of a and b match.

Definition at line 634 of file gncBillTerm.c.

{
    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 (safe_strcmp(a->name, b->name) != 0)
    {
        PWARN("Names differ: %s vs %s", a->name, b->name);
        return FALSE;
    }

    if (safe_strcmp(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;
}
gboolean gncBillTermIsFamily ( const GncBillTerm a,
const GncBillTerm b 
)

Check only if the bill terms are "family". This is the case if

  • a and b are the same bill term
  • a is b's parent or vice versa
  • a and be are children of the same parent

In practice, this check if performed by comparing the bill term's names. This is required to be unique per parent/children group.

Definition at line 698 of file gncBillTerm.c.

{
    if (!gncBillTermCompare (a, b))
        return TRUE;
    else
        return FALSE;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines