GnuCash  5.6-125-g579da58a10+
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)
 
time64 gncBillTermComputeDueDate (const GncBillTerm *term, time64 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 79 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 629 of file gncBillTerm.c.

630 {
631  int ret;
632 
633  if (!a && !b) return 0;
634  if (!a) return -1;
635  if (!b) return 1;
636 
637  ret = g_strcmp0 (a->name, b->name);
638  if (ret) return ret;
639 
640  return g_strcmp0 (a->desc, b->desc);
641 }

◆ gncBillTermEqual()

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

Check if all internal fields of a and b match.

Definition at line 643 of file gncBillTerm.c.

644 {
645  if (a == NULL && b == NULL) return TRUE;
646  if (a == NULL || b == NULL) return FALSE;
647 
648  g_return_val_if_fail(GNC_IS_BILLTERM(a), FALSE);
649  g_return_val_if_fail(GNC_IS_BILLTERM(b), FALSE);
650 
651  if (g_strcmp0(a->name, b->name) != 0)
652  {
653  PWARN("Names differ: %s vs %s", a->name, b->name);
654  return FALSE;
655  }
656 
657  if (g_strcmp0(a->desc, b->desc) != 0)
658  {
659  PWARN("Descriptions differ: %s vs %s", a->desc, b->desc);
660  return FALSE;
661  }
662 
663  if (a->type != b->type)
664  {
665  PWARN("Types differ");
666  return FALSE;
667  }
668 
669  if (a->due_days != b->due_days)
670  {
671  PWARN("Due days differ: %d vs %d", a->due_days, b->due_days);
672  return FALSE;
673  }
674 
675  if (a->disc_days != b->disc_days)
676  {
677  PWARN("Discount days differ: %d vs %d", a->disc_days, b->disc_days);
678  return FALSE;
679  }
680 
681  if (!gnc_numeric_equal(a->discount, b->discount))
682  {
683  PWARN("Discounts differ");
684  return FALSE;
685  }
686 
687  if (a->cutoff != b->cutoff)
688  {
689  PWARN("Cutoffs differ: %d vs %d", a->cutoff, b->cutoff);
690  return FALSE;
691  }
692 
693  if (a->invisible != b->invisible)
694  {
695  PWARN("Invisible flags differ");
696  return FALSE;
697  }
698 
699 // gint64 refcount;
700 // GncBillTerm * parent; /* if non-null, we are an immutable child */
701 // GncBillTerm * child; /* if non-null, we have not changed */
702 // GList * children; /* list of children for disconnection */
703 
704  return TRUE;
705 }
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:250

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

708 {
709  if (!gncBillTermCompare (a, b))
710  return TRUE;
711  else
712  return FALSE;
713 }
int gncBillTermCompare(const GncBillTerm *a, const GncBillTerm *b)
Compare BillTerms on their name for sorting.
Definition: gncBillTerm.c:629