Data Structures | Defines | Typedefs | Functions | Variables

Expenses
[Query Object Framework]

Data Structures

struct  QofExpense
 Wraps QOF around Expense_t. More...

Defines

#define PQOF_EXPENSES_DESC   "Pilot-link QOF expenses"
#define PILOT_LINK_QOF_EXPENSES   "pilot_expenses"
#define EXP_DATE   "expense_date"
#define EXP_TYPE   "type_of_expense"
#define EXP_PAYMENT   "form_of_payment"
#define EXP_CURRENCY   "currency_code"
#define EXP_AMOUNT   "expense_amount"
#define EXP_ATTENDEES   "expense_attendees"
#define EXP_NOTE   "expense_note"
#define EXP_CATEGORY   "category"
#define EXP_DISTANCE   "distance_unit"
#define EXP_VENDOR   "expense_vendor"
#define EXP_CITY   "expense_city"
#define EXP_KVP   "currency_lookup"
#define PQ_CURRENCY_MNEMONIC   "expense/currency/mnemonic"
#define PQ_CURRENCY_SYMBOL   "expense/currency/symbol"
#define PQ_CURRENCY_FRACTION   "expense/currency/fraction"
#define PQ_EXPENSE_PREF   Expense_Pref
#define EXPENSE_CREATOR   "exps"

Typedefs

typedef struct Expense Expense_t

Functions

void populate_currencies (void)
 Populate the currency table with the known currencies.
PQCurrencypq_currency_lookup (QofInstance *inst, gint currency_code)
static gboolean currency_cb (gpointer key, gpointer value, gpointer data)
gint32 pq_set_currency (QofInstance *inst, gchar *mnemonic)
Expense_t * pq_expense_get_pilot (QofEntity *inst)
static QofExpenseexpense_create (QofBook *book)
static const gchar * qof_exp_distanceAsString (enum ExpenseDistance distance)
static const gchar * qof_exp_paymentAsString (enum ExpensePayment payment)
static const gchar * qof_exp_typeAsString (enum ExpenseType type)
static enum ExpensePayment qof_exp_paymentFromString (const gchar *payment_string)
static enum ExpenseType qof_exp_typeFromString (const gchar *type_string)
static QofTime * exp_getTime (QofExpense *e)
static const gchar * exp_getType (QofExpense *e)
static const gchar * exp_getPayment (QofExpense *e)
static gint exp_getCurrency (QofExpense *e)
static QofNumeric exp_getAmount (QofExpense *e)
static const gchar * exp_getVendor (QofExpense *e)
static const gchar * exp_getCity (QofExpense *e)
static const gchar * exp_getAttendees (QofExpense *e)
static const gchar * exp_getNote (QofExpense *e)
static const gchar * exp_getDistance (QofExpense *e)
static const gchar * exp_getCategory (QofExpense *e)
static void exp_setTime (QofExpense *e, QofTime *h)
static void exp_setType (QofExpense *e, const gchar *type_string)
static void exp_setPayment (QofExpense *e, const gchar *payment_string)
static void exp_combine_currency_with_amount (QofExpense *e)
static void exp_setCurrency (QofExpense *e, gint code)
static void exp_setAmount (QofExpense *e, QofNumeric h)
static void exp_setVendor (QofExpense *e, gchar *h)
static void exp_setCity (QofExpense *e, gchar *h)
static void exp_setAttendees (QofExpense *e, gchar *h)
static void exp_setNote (QofExpense *e, gchar *h)
static void exp_setDistance (QofExpense *e, const gchar *distance_name)
static void exp_setCategory (QofExpense *e, gchar *n)
static const gchar * expensePrintable (gpointer instance)
gboolean PQExpensesRegister (void)
 Register this object with QOF.

Variables

static QofLogModule log_module = "pilotqof-objects"
static GHashTable * PQCurrencyTable = NULL
 Currency Table data.
static QofObject expenses_object_def

Detailed Description

Like DB, Expenses uses UTC time within QOF and sets localtime when calling pilot-link code.

Note:
pack_Expense still uses the old prototype using 0xffff instead of pi_buf->used. exp_pack has been modified to set pi_buf->used from the length returned by pack_Expense. Other databases already support pi_buffer and if expense is updated, this will need to be changed.

Define Documentation

#define EXPENSE_CREATOR   "exps"

Inherited from pilot-link because the exported form using makelong is not constant.

Definition at line 71 of file pilot-expenses.h.

#define PQ_CURRENCY_FRACTION   "expense/currency/fraction"

type: KVP_TYPE_GINT64

Definition at line 64 of file pilot-expenses.h.

#define PQ_CURRENCY_MNEMONIC   "expense/currency/mnemonic"

type: KVP_TYPE_STRING

Definition at line 60 of file pilot-expenses.h.

#define PQ_CURRENCY_SYMBOL   "expense/currency/symbol"

type: KVP_TYPE_STRING

Definition at line 62 of file pilot-expenses.h.

#define PQ_EXPENSE_PREF   Expense_Pref

Expense Preferences identifier.

Definition at line 67 of file pilot-expenses.h.


Function Documentation

static void exp_setAmount ( QofExpense e,
QofNumeric  h 
) [static]

Todo:
FIXME: INSERT handler can set one without the other. Need to use the pref.default_currency?

Definition at line 843 of file pilot-expenses.c.

References QofExpense::reset_amount, and QofExpense::temp_amount.

{
    Expense_t *qe;

    g_return_if_fail (e != NULL);
    qe = &e->wrap;
    e->temp_amount = qof_numeric_to_double (h);
    e->reset_amount = TRUE;
    /* if an amount can ever be set without a currency_code,
       this needs to be reviewed. */
    if (e->currency)
        exp_combine_currency_with_amount (e);
}

static void exp_setDistance ( QofExpense e,
const gchar *  distance_name 
) [static]

Todo:
Convert when setting into ExpensePref

Definition at line 900 of file pilot-expenses.c.

{
    gint i;
    for (i = 0; ExpenseDistanceNames[i] != NULL; i++)
    {
        if (0 == safe_strcmp (ExpenseDistanceNames[i], distance_name))
        {
            e->distance_unit = i;
        }
    }
}

void populate_currencies ( void   ) 

Populate the currency table with the known currencies.

Custom currencies are not included.

All mnemonics are from gnucash and use the ISO4217 namespace

custom currencies are the same and may end up with the same struct: gchar name[16], gchar symbol[4], gchar rate[8].

Ignore currencies[5] (the five available currencies from the main table above) but:

Todo:
store currencies[4] from AppInfo which are the four custom currencies.

Variable Documentation

QofObject expenses_object_def [static]
Initial value:
 {
  interface_version  :  QOF_OBJECT_VERSION,
  e_type             :   "pilot_expenses" ,
  type_label         :   "Pilot-link QOF expenses" ,
  create             :  (gpointer) expense_create,
  book_begin         :  NULL,
  book_end           :  NULL,
  is_dirty           :  qof_collection_is_dirty,
  mark_clean         :  qof_collection_mark_clean,
  foreach            :  qof_collection_foreach,
  printable          :  expensePrintable,
  version_cmp        :  (gint (*)(gpointer, gpointer)) qof_instance_version_cmp,
}

Definition at line 934 of file pilot-expenses.c.

GHashTable* PQCurrencyTable = NULL [static]

Currency Table data.

Table relating the currencies[5] to the actual currency names, mnemonics and symbols. In pilot-qof it is indexed by GINT_TO_POINTER(pq_code).

Definition at line 53 of file pilot-expenses.c.