GnuCash  2.7.1
Files | Macros | Enumerations | Functions

Files

file  gncBillTerm.h
 Billing Term interface.
 

Macros

#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(_)
 How to interpret the amount. More...
 
#define gncBillTermGetGUID(x)   qof_instance_get_guid (QOF_INSTANCE(x))
 

Enumerations

enum  GncBillTermType { GNC_TERM_TYPE_DAYS =1, GNC_TERM_TYPE_PROXIMO, GNC_TERM_TYPE_DAYS =1, GNC_TERM_TYPE_PROXIMO }
 
enum  GncBillTermType { GNC_TERM_TYPE_DAYS =1, GNC_TERM_TYPE_PROXIMO, GNC_TERM_TYPE_DAYS =1, GNC_TERM_TYPE_PROXIMO }
 

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

GncBillTerm * gncBillTermCreate (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

GncBillTerm * gncBillTermLookupByName (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)
 
GncBillTerm * gncBillTermGetParent (const GncBillTerm *term)
 
GncBillTerm * gncBillTermReturnChild (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)
 Compare BillTerms on their name for sorting. More...
 
gboolean gncBillTermEqual (const GncBillTerm *a, const GncBillTerm *b)
 Check if all internal fields of a and b match. More...
 
gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b)
 Check only if the bill terms are "family". More...
 

Detailed Description

Macro Definition Documentation

◆ ENUM_TERMS_TYPE

#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

◆ gncBillTermCompare()

int gncBillTermCompare ( const GncBillTerm *  a,
const GncBillTerm *  b 
)

Compare BillTerms on their name for sorting.

Definition at line 633 of file gncBillTerm.c.

634 {
635  int ret;
636 
637  if (!a && !b) return 0;
638  if (!a) return -1;
639  if (!b) return 1;
640 
641  ret = g_strcmp0 (a->name, b->name);
642  if (ret) return ret;
643 
644  return g_strcmp0 (a->desc, b->desc);
645 }

◆ gncBillTermEqual()

gboolean gncBillTermEqual ( const GncBillTerm *  a,
const GncBillTerm *  b 
)

Check if all internal fields of a and b match.

Definition at line 647 of file gncBillTerm.c.

648 {
649  if (a == NULL && b == NULL) return TRUE;
650  if (a == NULL || b == NULL) return FALSE;
651 
652  g_return_val_if_fail(GNC_IS_BILLTERM(a), FALSE);
653  g_return_val_if_fail(GNC_IS_BILLTERM(b), FALSE);
654 
655  if (g_strcmp0(a->name, b->name) != 0)
656  {
657  PWARN("Names differ: %s vs %s", a->name, b->name);
658  return FALSE;
659  }
660 
661  if (g_strcmp0(a->desc, b->desc) != 0)
662  {
663  PWARN("Descriptions differ: %s vs %s", a->desc, b->desc);
664  return FALSE;
665  }
666 
667  if (a->type != b->type)
668  {
669  PWARN("Types differ");
670  return FALSE;
671  }
672 
673  if (a->due_days != b->due_days)
674  {
675  PWARN("Due days differ: %d vs %d", a->due_days, b->due_days);
676  return FALSE;
677  }
678 
679  if (a->disc_days != b->disc_days)
680  {
681  PWARN("Discount days differ: %d vs %d", a->disc_days, b->disc_days);
682  return FALSE;
683  }
684 
685  if (!gnc_numeric_equal(a->discount, b->discount))
686  {
687  PWARN("Discounts differ");
688  return FALSE;
689  }
690 
691  if (a->cutoff != b->cutoff)
692  {
693  PWARN("Cutoffs differ: %d vs %d", a->cutoff, b->cutoff);
694  return FALSE;
695  }
696 
697  if (a->invisible != b->invisible)
698  {
699  PWARN("Invisible flags differ");
700  return FALSE;
701  }
702 
703 // gint64 refcount;
704 // GncBillTerm * parent; /* if non-null, we are an immutable child */
705 // GncBillTerm * child; /* if non-null, we have not changed */
706 // GList * children; /* list of children for disconnection */
707 
708  return TRUE;
709 }
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:243

◆ gncBillTermIsFamily()

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 711 of file gncBillTerm.c.

712 {
713  if (!gncBillTermCompare (a, b))
714  return TRUE;
715  else
716  return FALSE;
717 }
int gncBillTermCompare(const GncBillTerm *a, const GncBillTerm *b)
Compare BillTerms on their name for sorting.
Definition: gncBillTerm.c:633