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. | |
PQCurrency * | pq_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 QofExpense * | expense_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 |
#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.
static void exp_setAmount | ( | QofExpense * | e, | |
QofNumeric | h | |||
) | [static] |
Definition at line 843 of file pilot-expenses.c.
References QofExpense::reset_amount, and QofExpense::temp_amount.
Referenced by PQExpensesRegister().
00844 { 00845 Expense_t *qe; 00846 00847 g_return_if_fail (e != NULL); 00848 qe = &e->wrap; 00849 e->temp_amount = qof_numeric_to_double (h); 00850 e->reset_amount = TRUE; 00851 /* if an amount can ever be set without a currency_code, 00852 this needs to be reviewed. */ 00855 if (e->currency) 00856 exp_combine_currency_with_amount (e); 00857 }
static void exp_setDistance | ( | QofExpense * | e, | |
const gchar * | distance_name | |||
) | [static] |
Definition at line 900 of file pilot-expenses.c.
Referenced by PQExpensesRegister().
00901 { 00902 gint i; 00904 for (i = 0; ExpenseDistanceNames[i] != NULL; i++) 00905 { 00906 if (0 == safe_strcmp (ExpenseDistanceNames[i], distance_name)) 00907 { 00908 e->distance_unit = i; 00909 } 00910 } 00911 }
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:
Definition at line 72 of file pilot-expenses.c.
References PQCurrency_s::fraction, PQCurrency_s::mnemonic, PQCurrency_s::non_utf8, PQCurrency_s::pq_code, PQCurrencyTable, and PQCurrency_s::symbol.
00073 { 00074 if (PQCurrencyTable != NULL) 00075 return; 00076 PQCurrencyTable = g_hash_table_new (g_direct_hash, g_direct_equal); 00077 { /* Australia 0 100 AU$ AUD */ 00078 PQCurrency *c = g_new0 (PQCurrency, 1); 00079 c->pq_code = 0; 00080 c->fraction = 100; 00081 c->symbol = "AU$"; 00082 c->mnemonic = "AUD"; 00083 c->non_utf8 = FALSE; 00084 g_hash_table_insert (PQCurrencyTable, 00085 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00086 } 00087 { /* Austria 1 100 € ATS */ 00088 PQCurrency *c = g_new0 (PQCurrency, 1); 00089 c->pq_code = 1; 00090 c->fraction = 100; 00091 c->symbol = "€"; 00092 c->mnemonic = "ATS"; 00093 c->non_utf8 = TRUE; 00094 g_hash_table_insert (PQCurrencyTable, 00095 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00096 } 00097 { /* Belgium 2 100 € BEF */ 00098 PQCurrency *c = g_new0 (PQCurrency, 1); 00099 c->pq_code = 2; 00100 c->fraction = 100; 00101 c->symbol = "€"; 00102 c->mnemonic = "BEF"; 00103 c->non_utf8 = TRUE; 00104 g_hash_table_insert (PQCurrencyTable, 00105 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00106 } 00107 { /* Brazil 3 100 R$ BRL */ 00108 PQCurrency *c = g_new0 (PQCurrency, 1); 00109 c->pq_code = 3; 00110 c->fraction = 100; 00111 c->symbol = "R$"; 00112 c->mnemonic = "BRL"; 00113 c->non_utf8 = FALSE; 00114 g_hash_table_insert (PQCurrencyTable, 00115 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00116 } 00117 { /* Canada 4 100 $CN CAD */ 00118 PQCurrency *c = g_new0 (PQCurrency, 1); 00119 c->pq_code = 4; 00120 c->fraction = 100; 00121 c->symbol = "$CN"; 00122 c->mnemonic = "CAD"; 00123 c->non_utf8 = FALSE; 00124 g_hash_table_insert (PQCurrencyTable, 00125 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00126 } 00127 { /* Denmark 5 100 DKK DKK */ 00128 PQCurrency *c = g_new0 (PQCurrency, 1); 00129 c->pq_code = 5; 00130 c->fraction = 100; 00131 c->symbol = "DKK"; 00132 c->mnemonic = "DKK"; 00133 c->non_utf8 = FALSE; 00134 g_hash_table_insert (PQCurrencyTable, 00135 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00136 } 00137 { /* Finland 6 100 € FIM */ 00138 PQCurrency *c = g_new0 (PQCurrency, 1); 00139 c->pq_code = 6; 00140 c->fraction = 100; 00141 c->symbol = "€"; 00142 c->mnemonic = "FIM"; 00143 c->non_utf8 = TRUE; 00144 g_hash_table_insert (PQCurrencyTable, 00145 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00146 } 00147 { /* France 7 100 € FRF */ 00148 PQCurrency *c = g_new0 (PQCurrency, 1); 00149 c->pq_code = 7; 00150 c->fraction = 100; 00151 c->symbol = "€"; 00152 c->mnemonic = "FRF"; 00153 c->non_utf8 = TRUE; 00154 g_hash_table_insert (PQCurrencyTable, 00155 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00156 } 00157 { /* Germany 8 100 € DEM */ 00158 PQCurrency *c = g_new0 (PQCurrency, 1); 00159 c->pq_code = 8; 00160 c->fraction = 100; 00161 c->symbol = "€"; 00162 c->mnemonic = "DEM"; 00163 c->non_utf8 = TRUE; 00164 g_hash_table_insert (PQCurrencyTable, 00165 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00166 } 00167 { /* Hong Kong 9 100 HK$ HKD */ 00168 PQCurrency *c = g_new0 (PQCurrency, 1); 00169 c->pq_code = 9; 00170 c->fraction = 100; 00171 c->symbol = "HK$"; 00172 c->mnemonic = "HKD"; 00173 c->non_utf8 = FALSE; 00174 g_hash_table_insert (PQCurrencyTable, 00175 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00176 } 00177 { /* Iceland 10 100 ISK ISK */ 00178 PQCurrency *c = g_new0 (PQCurrency, 1); 00179 c->pq_code = 10; 00180 c->fraction = 100; 00181 c->symbol = "ISK"; 00182 c->mnemonic = "ISK"; 00183 c->non_utf8 = FALSE; 00184 g_hash_table_insert (PQCurrencyTable, 00185 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00186 } 00187 { /* Ireland 11 100 € IEP */ 00188 PQCurrency *c = g_new0 (PQCurrency, 1); 00189 c->pq_code = 11; 00190 c->fraction = 100; 00191 c->symbol = "€"; 00192 c->mnemonic = "IEP"; 00193 c->non_utf8 = TRUE; 00194 g_hash_table_insert (PQCurrencyTable, 00195 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00196 } 00197 { /* Italy 12 1 EUR ITL */ 00198 /* The Italian Lira had a fraction == 1 */ 00199 PQCurrency *c = g_new0 (PQCurrency, 1); 00200 c->pq_code = 12; 00201 c->fraction = 100; 00202 c->symbol = "EUR"; 00203 c->mnemonic = "ITL"; 00204 c->non_utf8 = FALSE; 00205 g_hash_table_insert (PQCurrencyTable, 00206 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00207 } 00208 { /* Japan 13 1 ¥ ¥ JPY */ 00209 PQCurrency *c = g_new0 (PQCurrency, 1); 00210 c->pq_code = 13; 00211 c->fraction = 1; 00212 c->symbol = "¥"; 00213 c->mnemonic = "JPY"; 00214 c->non_utf8 = TRUE; 00215 g_hash_table_insert (PQCurrencyTable, 00216 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00217 } 00218 { /* Luxembourg 14 100 ˆ € LUF */ 00219 PQCurrency *c = g_new0 (PQCurrency, 1); 00220 c->pq_code = 14; 00221 c->fraction = 100; 00222 c->symbol = "€"; 00223 c->mnemonic = "LUF"; 00224 c->non_utf8 = TRUE; 00225 g_hash_table_insert (PQCurrencyTable, 00226 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00227 } 00228 { /* Mexico 15 100 MXP MXP */ 00229 PQCurrency *c = g_new0 (PQCurrency, 1); 00230 c->pq_code = 15; 00231 c->fraction = 100; 00232 c->symbol = "MXP"; 00233 c->mnemonic = "MXP"; 00234 c->non_utf8 = FALSE; 00235 g_hash_table_insert (PQCurrencyTable, 00236 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00237 } 00238 { /* Netherlands 16 100 € ANG */ 00239 PQCurrency *c = g_new0 (PQCurrency, 1); 00240 c->pq_code = 16; 00241 c->fraction = 100; 00242 c->symbol = "€"; 00243 c->mnemonic = "ANG"; 00244 c->non_utf8 = TRUE; 00245 g_hash_table_insert (PQCurrencyTable, 00246 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00247 } 00248 { /* New Zealand 17 100 $NZ NZD */ 00249 PQCurrency *c = g_new0 (PQCurrency, 1); 00250 c->pq_code = 17; 00251 c->fraction = 100; 00252 c->symbol = "$NZ"; 00253 c->mnemonic = "NZD"; 00254 c->non_utf8 = FALSE; 00255 g_hash_table_insert (PQCurrencyTable, 00256 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00257 } 00258 { /* Norway 18 100 NOK NOK */ 00259 PQCurrency *c = g_new0 (PQCurrency, 1); 00260 c->pq_code = 18; 00261 c->fraction = 100; 00262 c->symbol = "NOK"; 00263 c->mnemonic = "NOK"; 00264 c->non_utf8 = FALSE; 00265 g_hash_table_insert (PQCurrencyTable, 00266 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00267 } 00268 { /* Spain 19 100 € ESP */ 00269 PQCurrency *c = g_new0 (PQCurrency, 1); 00270 c->pq_code = 19; 00271 c->fraction = 100; 00272 c->symbol = "€"; 00273 c->mnemonic = "ESP"; 00274 c->non_utf8 = TRUE; 00275 g_hash_table_insert (PQCurrencyTable, 00276 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00277 } 00278 { /* Sweden 20 100 SEK SEK */ 00279 PQCurrency *c = g_new0 (PQCurrency, 1); 00280 c->pq_code = 20; 00281 c->fraction = 100; 00282 c->symbol = "SEK"; 00283 c->mnemonic = "SEK"; 00284 c->non_utf8 = FALSE; 00285 g_hash_table_insert (PQCurrencyTable, 00286 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00287 } 00288 { /* Switzerland 21 100 CHF CHF */ 00289 PQCurrency *c = g_new0 (PQCurrency, 1); 00290 c->pq_code = 21; 00291 c->fraction = 100; 00292 c->symbol = "CHF"; 00293 c->mnemonic = "CHF"; 00294 c->non_utf8 = FALSE; 00295 g_hash_table_insert (PQCurrencyTable, 00296 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00297 } 00298 { /* United Kingdom 22 100 £ GBP */ 00299 PQCurrency *c = g_new0 (PQCurrency, 1); 00300 c->pq_code = 22; 00301 c->fraction = 100; 00302 c->symbol = "£"; 00303 c->mnemonic = "GBP"; 00304 c->non_utf8 = TRUE; 00305 g_hash_table_insert (PQCurrencyTable, 00306 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00307 } 00308 { /* United States 23 100 $US USD */ 00309 PQCurrency *c = g_new0 (PQCurrency, 1); 00310 c->pq_code = 23; 00311 c->fraction = 100; 00312 c->symbol = "$US"; 00313 c->mnemonic = "USD"; 00314 c->non_utf8 = FALSE; 00315 g_hash_table_insert (PQCurrencyTable, 00316 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00317 } 00318 { /* India 24 100 Rs INR */ 00319 PQCurrency *c = g_new0 (PQCurrency, 1); 00320 c->pq_code = 24; 00321 c->fraction = 100; 00322 c->symbol = "Rs"; 00323 c->mnemonic = "INR"; 00324 c->non_utf8 = FALSE; 00325 g_hash_table_insert (PQCurrencyTable, 00326 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00327 } 00328 { /* Indonesia 25 1 Rp IDR */ 00329 PQCurrency *c = g_new0 (PQCurrency, 1); 00330 c->pq_code = 25; 00331 c->fraction = 1; 00332 c->symbol = "Rp"; 00333 c->mnemonic = "IDR"; 00334 c->non_utf8 = FALSE; 00335 g_hash_table_insert (PQCurrencyTable, 00336 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00337 } 00338 { /* Korea 26 100 KRW KRW (South) */ 00339 PQCurrency *c = g_new0 (PQCurrency, 1); 00340 c->pq_code = 26; 00341 c->fraction = 100; 00342 c->symbol = "KRW"; 00343 c->mnemonic = "KRW"; 00344 c->non_utf8 = FALSE; 00345 g_hash_table_insert (PQCurrencyTable, 00346 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00347 } 00348 { /* Malaysia 27 100 RM MYR */ 00349 PQCurrency *c = g_new0 (PQCurrency, 1); 00350 c->pq_code = 27; 00351 c->fraction = 100; 00352 c->symbol = "RM"; 00353 c->mnemonic = "MYR"; 00354 c->non_utf8 = FALSE; 00355 g_hash_table_insert (PQCurrencyTable, 00356 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00357 } 00358 { /* P.R.C. // People's Rep. China 28 100 RMB CNY */ 00359 PQCurrency *c = g_new0 (PQCurrency, 1); 00360 c->pq_code = 28; 00361 c->fraction = 100; 00362 c->symbol = "RMB"; 00363 c->mnemonic = "CNY"; 00364 c->non_utf8 = FALSE; 00365 g_hash_table_insert (PQCurrencyTable, 00366 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00367 } 00368 { /* Phillipines 29 100 P PHP */ 00369 PQCurrency *c = g_new0 (PQCurrency, 1); 00370 c->pq_code = 29; 00371 c->fraction = 100; 00372 c->symbol = "P"; 00373 c->mnemonic = "PHP"; 00374 c->non_utf8 = FALSE; 00375 g_hash_table_insert (PQCurrencyTable, 00376 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00377 } 00378 { /* Singapore 30 100 $ SGD */ 00379 PQCurrency *c = g_new0 (PQCurrency, 1); 00380 c->pq_code = 30; 00381 c->fraction = 100; 00382 c->symbol = "$"; 00383 c->mnemonic = "SGD"; 00384 c->non_utf8 = FALSE; 00385 g_hash_table_insert (PQCurrencyTable, 00386 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00387 } 00388 { /* Thailand 31 100 BHT THB */ 00389 PQCurrency *c = g_new0 (PQCurrency, 1); 00390 c->pq_code = 31; 00391 c->fraction = 100; 00392 c->symbol = "BHT"; 00393 c->mnemonic = "THB"; 00394 c->non_utf8 = FALSE; 00395 g_hash_table_insert (PQCurrencyTable, 00396 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00397 } 00398 { /* Taiwan 32 100 NT$ TWD */ 00399 PQCurrency *c = g_new0 (PQCurrency, 1); 00400 c->pq_code = 32; 00401 c->fraction = 100; 00402 c->symbol = "NT$"; 00403 c->mnemonic = "TWD"; 00404 c->non_utf8 = FALSE; 00405 g_hash_table_insert (PQCurrencyTable, 00406 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00407 } 00408 { /* EU (Euro) 133 100 € EUR */ 00409 PQCurrency *c = g_new0 (PQCurrency, 1); 00410 c->pq_code = 133; 00411 c->fraction = 100; 00412 c->symbol = "€"; 00413 c->mnemonic = "EUR"; 00414 c->non_utf8 = TRUE; 00415 g_hash_table_insert (PQCurrencyTable, 00416 GINT_TO_POINTER (c->pq_code), (gpointer) c); 00417 } 00418 }
QofObject expenses_object_def [static] |
Initial value:
{ interface_version : 4 , 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.
Referenced by populate_currencies().