GnuCash
5.6-150-g038405b370+
|
A commodity is something of value that is easily tradeable or sellable; for example, currencies, stocks, bonds, grain, copper, and oil are all commodities. More...
Files | |
file | gnc-commodity.h |
Commodity handling public routines. | |
file | gnc-commodity.hpp |
Commodity handling public routines (C++ api) | |
Data Structures | |
struct | gnc_monetary |
Macros | |
#define | GNC_TYPE_COMMODITY (gnc_commodity_get_type ()) |
#define | GNC_COMMODITY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY, gnc_commodity)) |
#define | GNC_COMMODITY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY, gnc_commodityClass)) |
#define | GNC_IS_COMMODITY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY)) |
#define | GNC_IS_COMMODITY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY)) |
#define | GNC_COMMODITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY, gnc_commodityClass)) |
#define | GNC_TYPE_COMMODITY_NAMESPACE (gnc_commodity_namespace_get_type ()) |
#define | GNC_COMMODITY_NAMESPACE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY_NAMESPACE, gnc_commodity_namespace)) |
#define | GNC_COMMODITY_NAMESPACE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY_NAMESPACE, gnc_commodity_namespaceClass)) |
#define | GNC_IS_COMMODITY_NAMESPACE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY_NAMESPACE)) |
#define | GNC_IS_COMMODITY_NAMESPACE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY_NAMESPACE)) |
#define | GNC_COMMODITY_NAMESPACE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY_NAMESPACE, gnc_commodity_namespaceClass)) |
#define | GNC_COMMODITY_TABLE "gnc_commodity_table" |
#define | GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES" |
The commodity namespace definitions are used to tag a commodity by its type, or a stocks by the exchange where it is traded. More... | |
#define | GNC_COMMODITY_NS_TEMPLATE "template" |
#define | GNC_COMMODITY_NS_ISO "ISO4217" |
#define | GNC_COMMODITY_NS_CURRENCY "CURRENCY" |
#define | GNC_COMMODITY_NS_NONCURRENCY "NONCURRENCY" |
#define | GNC_COMMODITY_NS_NONISO_GUI NC_("Commodity Type", "All non-currency") |
#define | GNC_COMMODITY_NS_ISO_GUI NC_("Commodity Type", "Currencies") |
#define | GNC_COMMODITY_MAX_FRACTION 1000000000 |
Max fraction is 10^9 because 10^10 would require changing it to an int64_t. | |
Typedefs | |
typedef GList | CommodityList |
using | CommVec = std::vector< gnc_commodity * > |
Functions | |
GType | gnc_commodity_get_type (void) |
GType | gnc_commodity_namespace_get_type (void) |
void | gnc_quote_source_set_fq_installed (const char *version_string, const std::vector< std::string > &sources_list) |
Update gnucash internal tables based on what Finance::Quote sources are installed. More... | |
Commodity Quote Source functions | |
enum | QuoteSourceType { SOURCE_SINGLE = 0, SOURCE_MULTI, SOURCE_UNKNOWN, SOURCE_MAX, SOURCE_CURRENCY = SOURCE_MAX } |
The quote source type enum account types are used to determine how the transaction data in the account is displayed. More... | |
gboolean | gnc_quote_source_fq_installed (void) |
This function indicates whether or not the Finance::Quote module is installed on a user's computer. More... | |
const char * | gnc_quote_source_fq_version (void) |
This function returns the version of the Finance::Quote module installed on a user's computer. More... | |
gint | gnc_quote_source_num_entries (QuoteSourceType type) |
Return the number of entries for a given type of quote source. More... | |
gnc_quote_source * | gnc_quote_source_add_new (const char *name, gboolean supported) |
Create a new quote source. More... | |
gnc_quote_source * | gnc_quote_source_lookup_by_internal (const char *internal_name) |
Given the internal (gnucash or F::Q) name of a quote source, find the data structure identified by this name. More... | |
gnc_quote_source * | gnc_quote_source_lookup_by_ti (QuoteSourceType type, gint index) |
Given the type/index of a quote source, find the data structure identified by this pair. More... | |
gboolean | gnc_quote_source_get_supported (const gnc_quote_source *source) |
Given a gnc_quote_source data structure, return the flag that indicates whether this particular quote source is supported by the user's F::Q installation. More... | |
QuoteSourceType | gnc_quote_source_get_type (const gnc_quote_source *source) |
Given a gnc_quote_source data structure, return the type of this particular quote source. More... | |
gint | gnc_quote_source_get_index (const gnc_quote_source *source) |
Given a gnc_quote_source data structure, return the index of this particular quote source within its type. More... | |
const char * | gnc_quote_source_get_user_name (const gnc_quote_source *source) |
Given a gnc_quote_source data structure, return the user friendly name of this quote source. More... | |
const char * | gnc_quote_source_get_internal_name (const gnc_quote_source *source) |
Given a gnc_quote_source data structure, return the internal name of this quote source. More... | |
Commodity Creation | |
gnc_commodity * | gnc_commodity_new (QofBook *book, const char *fullname, const char *commodity_namespace, const char *mnemonic, const char *cusip, int fraction) |
Create a new commodity. More... | |
void | gnc_commodity_destroy (gnc_commodity *cm) |
Destroy a commodity. More... | |
void | gnc_commodity_copy (gnc_commodity *dest, const gnc_commodity *src) |
Copy src into dest. | |
gnc_commodity * | gnc_commodity_clone (const gnc_commodity *src, QofBook *dest_book) |
allocate and copy | |
Commodity Accessor Routines - Get | |
const char * | gnc_commodity_get_mnemonic (const gnc_commodity *cm) |
Retrieve the mnemonic for the specified commodity. More... | |
const char * | gnc_commodity_get_namespace (const gnc_commodity *cm) |
Retrieve the namespace for the specified commodity. More... | |
gnc_commodity_namespace * | gnc_commodity_get_namespace_ds (const gnc_commodity *cm) |
Retrieve the namespace data structure for the specified commodity. More... | |
const char * | gnc_commodity_get_fullname (const gnc_commodity *cm) |
Retrieve the full name for the specified commodity. More... | |
const char * | gnc_commodity_get_printname (const gnc_commodity *cm) |
Retrieve the 'print' name for the specified commodity. More... | |
const char * | gnc_commodity_get_cusip (const gnc_commodity *cm) |
Retrieve the 'exchange code' for the specified commodity. More... | |
const char * | gnc_commodity_get_unique_name (const gnc_commodity *cm) |
Retrieve the 'unique' name for the specified commodity. More... | |
int | gnc_commodity_get_fraction (const gnc_commodity *cm) |
Retrieve the fraction for the specified commodity. More... | |
gboolean | gnc_commodity_get_quote_flag (const gnc_commodity *cm) |
Retrieve the automatic price quote flag for the specified commodity. More... | |
gnc_quote_source * | gnc_commodity_get_quote_source (const gnc_commodity *cm) |
Retrieve the automatic price quote source for the specified commodity. More... | |
gnc_quote_source * | gnc_commodity_get_default_quote_source (const gnc_commodity *cm) |
const char * | gnc_commodity_get_quote_tz (const gnc_commodity *cm) |
Retrieve the automatic price quote timezone for the specified commodity. More... | |
const char * | gnc_commodity_get_user_symbol (const gnc_commodity *cm) |
Retrieve the user-defined symbol for the specified commodity. More... | |
const char * | gnc_commodity_get_default_symbol (const gnc_commodity *cm) |
Retrieve the default symbol for the specified commodity. More... | |
const char * | gnc_commodity_get_nice_symbol (const gnc_commodity *cm) |
Retrieve a symbol for the specified commodity, suitable for display to the user. More... | |
Commodity Accessor Routines - Set | |
void | gnc_commodity_set_mnemonic (gnc_commodity *cm, const char *mnemonic) |
Set the mnemonic for the specified commodity. More... | |
void | gnc_commodity_set_namespace (gnc_commodity *cm, const char *new_namespace) |
Set the namespace for the specified commodity. More... | |
void | gnc_commodity_set_fullname (gnc_commodity *cm, const char *fullname) |
Set the full name for the specified commodity. More... | |
void | gnc_commodity_set_cusip (gnc_commodity *cm, const char *cusip) |
Set the 'exchange code' for the specified commodity. More... | |
void | gnc_commodity_set_fraction (gnc_commodity *cm, int smallest_fraction) |
Set the fraction for the specified commodity. More... | |
void | gnc_commodity_user_set_quote_flag (gnc_commodity *cm, const gboolean flag) |
Set the automatic price quote flag for the specified commodity, based on user input. More... | |
void | gnc_commodity_set_quote_flag (gnc_commodity *cm, const gboolean flag) |
Set the automatic price quote flag for the specified commodity. More... | |
void | gnc_commodity_set_quote_source (gnc_commodity *cm, gnc_quote_source *src) |
Set the automatic price quote source for the specified commodity. More... | |
void | gnc_commodity_set_quote_tz (gnc_commodity *cm, const char *tz) |
Set the automatic price quote timezone for the specified commodity. More... | |
void | gnc_commodity_set_user_symbol (gnc_commodity *cm, const char *user_symbol) |
Set a user-defined symbol for the specified commodity. More... | |
Commodity Usage Count Adjustment Routines | |
void | gnc_commodity_increment_usage_count (gnc_commodity *cm) |
Increment a commodity's internal counter that tracks how many accounts are using that commodity. More... | |
void | gnc_commodity_decrement_usage_count (gnc_commodity *cm) |
Decrement a commodity's internal counter that tracks how many accounts are using that commodity. More... | |
Commodity Comparison | |
gboolean | gnc_commodity_equiv (const gnc_commodity *a, const gnc_commodity *b) |
This routine returns TRUE if the two commodities are equivalent. More... | |
gboolean | gnc_commodity_equal (const gnc_commodity *a, const gnc_commodity *b) |
This routine returns TRUE if the two commodities are equal. More... | |
int | gnc_commodity_compare (const gnc_commodity *a, const gnc_commodity *b) |
This routine returns 0 if the two commodities are equal, 1 otherwise. More... | |
int | gnc_commodity_compare_void (const void *a, const void *b) |
A wrapper around gnc_commodity_compare() which offers the function declaration that is needed for g_list_find_custom(), which needs void pointers instead of gnc_commodity ones. | |
Currency Checks | |
gboolean | gnc_commodity_namespace_is_iso (const char *commodity_namespace) |
Checks to see if the specified commodity namespace is the namespace for ISO 4217 currencies. More... | |
gboolean | gnc_commodity_is_iso (const gnc_commodity *cm) |
Checks to see if the specified commodity is an ISO 4217 recognized currency. More... | |
gboolean | gnc_commodity_is_currency (const gnc_commodity *cm) |
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency. More... | |
Commodity Table | |
gnc_commodity_table * | gnc_commodity_table_get_table (QofBook *book) |
Returns the commodity table associated with a book. | |
Commodity Table Lookup functions | |
gnc_commodity * | gnc_commodity_table_lookup (const gnc_commodity_table *table, const char *commodity_namespace, const char *mnemonic) |
gnc_commodity * | gnc_commodity_table_lookup_unique (const gnc_commodity_table *table, const char *unique_name) |
gnc_commodity * | gnc_commodity_table_find_full (const gnc_commodity_table *t, const char *commodity_namespace, const char *fullname) |
gnc_commodity * | gnc_commodity_find_commodity_by_guid (const GncGUID *guid, QofBook *book) |
Commodity Table Maintenance functions | |
gnc_commodity * | gnc_commodity_table_insert (gnc_commodity_table *table, gnc_commodity *comm) |
Add a new commodity to the commodity table. More... | |
void | gnc_commodity_table_remove (gnc_commodity_table *table, gnc_commodity *comm) |
Remove a commodity from the commodity table. More... | |
gboolean | gnc_commodity_table_add_default_data (gnc_commodity_table *table, QofBook *book) |
Add all the standard namespaces and currencies to the commodity table. More... | |
Commodity Table Namespace functions | |
const char * | gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns) |
Return the textual name of a namespace data structure. More... | |
const char * | gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns) |
Return the textual name of a namespace data structure in a form suitable to present to the user. More... | |
GList * | gnc_commodity_namespace_get_commodity_list (const gnc_commodity_namespace *ns) |
Return a list of all commodity data structures in the specified namespace. More... | |
int | gnc_commodity_table_has_namespace (const gnc_commodity_table *table, const char *commodity_namespace) |
Test to see if the indicated namespace exits in the commodity table. More... | |
GList * | gnc_commodity_table_get_namespaces (const gnc_commodity_table *t) |
Return a list of all namespaces in the commodity table. More... | |
GList * | gnc_commodity_table_get_namespaces_list (const gnc_commodity_table *t) |
Return a list of all namespace data structures in the commodity table. More... | |
gnc_commodity_namespace * | gnc_commodity_table_add_namespace (gnc_commodity_table *table, const char *commodity_namespace, QofBook *book) |
This function adds a new string to the list of commodity namespaces. More... | |
gnc_commodity_namespace * | gnc_commodity_table_find_namespace (const gnc_commodity_table *table, const char *commodity_namespace) |
This function finds a commodity namespace in the set of existing commodity namespaces. More... | |
void | gnc_commodity_table_delete_namespace (gnc_commodity_table *table, const char *commodity_namespace) |
This function deletes a string from the list of commodity namespaces. More... | |
Commodity Table Accessor functions | |
guint | gnc_commodity_table_get_size (const gnc_commodity_table *tbl) |
Returns the number of commodities in the commodity table. More... | |
CommodityList * | gnc_commodity_table_get_commodities (const gnc_commodity_table *table, const char *commodity_namespace) |
Return a list of all commodities in the commodity table that are in the given namespace. More... | |
CommodityList * | gnc_commodity_table_get_quotable_commodities (const gnc_commodity_table *table) |
This function returns a list of commodities for which price quotes should be retrieved. More... | |
gboolean | gnc_commodity_table_foreach_commodity (const gnc_commodity_table *table, gboolean(*f)(gnc_commodity *cm, gpointer user_data), gpointer user_data) |
Call a function once for each commodity in the commodity table. More... | |
Commodity Table Private/Internal-Use Only Routines | |
gnc_commodity_table * | gnc_commodity_table_new (void) |
You probably shouldn't be using gnc_commodity_table_new() directly, it's for internal use only. More... | |
void | gnc_commodity_table_destroy (gnc_commodity_table *table) |
gnc_commodity * | gnc_commodity_obtain_twin (const gnc_commodity *findlike, QofBook *book) |
Given the commodity 'findlike', this routine will find and return the equivalent commodity (commodity with the same 'unique name') in the indicated book. More... | |
gboolean | gnc_commodity_table_register (void) |
You should probably not be using gnc_commodity_table_register() It is an internal routine for registering the gncObject for the commodity table. | |
void | gnc_commodity_begin_edit (gnc_commodity *cm) |
void | gnc_commodity_commit_edit (gnc_commodity *cm) |
#define | gnc_commodity_get_kvp_frame(cm) qof_instance_get_slots(QOF_INSTANCE(cm)) |
Get the internal KVP from of the currency. More... | |
Monetary value, commodity identity and numeric value | |
typedef GList | MonetaryList |
Manipulate MonetaryList lists | |
MonetaryList * | gnc_monetary_list_add_monetary (MonetaryList *list, gnc_monetary mon) |
Add a gnc_monetary to the list. | |
MonetaryList * | gnc_monetary_list_delete_zeros (MonetaryList *list) |
Delete all the zero-value entries from a list. More... | |
void | gnc_monetary_list_free (MonetaryList *list) |
Free a monetary list and all the items it points to. More... | |
A commodity is something of value that is easily tradeable or sellable; for example, currencies, stocks, bonds, grain, copper, and oil are all commodities.
This file provides an API for defining a commodities, and for working with collections of commodities. All GnuCash financial transactions must identify the commodity that is being traded.
#define gnc_commodity_get_kvp_frame | ( | cm | ) | qof_instance_get_slots(QOF_INSTANCE(cm)) |
Get the internal KVP from of the currency.
You should rather use the individual accessors for individual properties
Definition at line 983 of file gnc-commodity.h.
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES" |
The commodity namespace definitions are used to tag a commodity by its type, or a stocks by the exchange where it is traded.
The LEGACY name is only used by the file i/o routines, and is converted to another commodity namespace before it is seen by the rest of the system. The ISO namespace represents currencies. With the exception of the NASDAQ namespace (which is used once in the binary importer) the rest of the namespace declarations are only used to populate an option menu in the commodity selection window.
Definition at line 103 of file gnc-commodity.h.
enum QuoteSourceType |
The quote source type enum account types are used to determine how the transaction data in the account is displayed.
These values can be safely changed from one release to the next.
Definition at line 128 of file gnc-commodity.h.
int gnc_commodity_compare | ( | const gnc_commodity * | a, |
const gnc_commodity * | b | ||
) |
This routine returns 0 if the two commodities are equal, 1 otherwise.
Commodities are equal if they have the same namespace, mnemonic, fullname, exchange private code and fraction. This function is useful for list-traversal comparison purposes where The semantics are 0, <0, or >0 (equal, greater than, less than) rather than "true or false"
Definition at line 1548 of file gnc-commodity.cpp.
void gnc_commodity_decrement_usage_count | ( | gnc_commodity * | cm | ) |
Decrement a commodity's internal counter that tracks how many accounts are using that commodity.
For currencies, this may have the side effect of disabling the commodity's quote flag.
cm | A pointer to a commodity data structure. |
Definition at line 1481 of file gnc-commodity.cpp.
void gnc_commodity_destroy | ( | gnc_commodity * | cm | ) |
Destroy a commodity.
Release all memory attached to this data structure.
cm | The commodity to destroy. |
Definition at line 884 of file gnc-commodity.cpp.
gboolean gnc_commodity_equal | ( | const gnc_commodity * | a, |
const gnc_commodity * | b | ||
) |
This routine returns TRUE if the two commodities are equal.
Commodities are equal if they have the same namespace, mnemonic, fullname, exchange private code and fraction.
Definition at line 1541 of file gnc-commodity.cpp.
gboolean gnc_commodity_equiv | ( | const gnc_commodity * | a, |
const gnc_commodity * | b | ||
) |
This routine returns TRUE if the two commodities are equivalent.
Commodities are equivalent if they have the same namespace and mnemonic. Equivalent commodities may belong to different exchanges, may have different fullnames, and may have different fractions.
Definition at line 1524 of file gnc-commodity.cpp.
const char* gnc_commodity_get_cusip | ( | const gnc_commodity * | cm | ) |
Retrieve the 'exchange code' for the specified commodity.
This will be a pointer to a null terminated string of the form "AXQ14728", etc. This field is often used when presenting information to the user.
cm | A pointer to a commodity data structure. |
Definition at line 1009 of file gnc-commodity.cpp.
const char* gnc_commodity_get_default_symbol | ( | const gnc_commodity * | cm | ) |
Retrieve the default symbol for the specified commodity.
This will be a pointer to a nul terminated string like "£", "US$", etc. Note that for the locale currency, you probably want to look at the system-provided symbol first. See gnc_commodity_get_nice_symbol.
cm | A pointer to a commodity data structure. |
Definition at line 1111 of file gnc-commodity.cpp.
int gnc_commodity_get_fraction | ( | const gnc_commodity * | cm | ) |
Retrieve the fraction for the specified commodity.
This will be an integer value specifying the number of fractional units that one of these commodities can be divided into. Should always be a power of 10.
cm | A pointer to a commodity data structure. |
Definition at line 1020 of file gnc-commodity.cpp.
const char* gnc_commodity_get_fullname | ( | const gnc_commodity * | cm | ) |
Retrieve the full name for the specified commodity.
This will be a pointer to a null terminated string of the form "Acme Systems, Inc.", etc.
cm | A pointer to a commodity data structure. |
Definition at line 985 of file gnc-commodity.cpp.
const char* gnc_commodity_get_mnemonic | ( | const gnc_commodity * | cm | ) |
Retrieve the mnemonic for the specified commodity.
This will be a pointer to a null terminated string of the form "ACME", "QWER", etc.
cm | A pointer to a commodity data structure. |
Definition at line 944 of file gnc-commodity.cpp.
const char* gnc_commodity_get_namespace | ( | const gnc_commodity * | cm | ) |
Retrieve the namespace for the specified commodity.
This will be a pointer to a null terminated string of the form "AMEX", "NASDAQ", etc.
cm | A pointer to a commodity data structure. |
Definition at line 967 of file gnc-commodity.cpp.
gnc_commodity_namespace* gnc_commodity_get_namespace_ds | ( | const gnc_commodity * | cm | ) |
Retrieve the namespace data structure for the specified commodity.
This will be a pointer to another data structure.
cm | A pointer to a commodity data structure. |
Definition at line 974 of file gnc-commodity.cpp.
const char* gnc_commodity_get_nice_symbol | ( | const gnc_commodity * | cm | ) |
Retrieve a symbol for the specified commodity, suitable for display to the user.
This will be a pointer to a nul terminated string like "£", "US$", etc. That function is locale-aware and will base its choice of symbol on the user-configured symbol, the locale a
cm | A pointer to a commodity data structure. |
Definition at line 1121 of file gnc-commodity.cpp.
const char* gnc_commodity_get_printname | ( | const gnc_commodity * | cm | ) |
Retrieve the 'print' name for the specified commodity.
This will be a pointer to a null terminated string of the form "Acme Systems, Inc. (ACME)", etc.
cm | A pointer to a commodity data structure. |
Definition at line 955 of file gnc-commodity.cpp.
gboolean gnc_commodity_get_quote_flag | ( | const gnc_commodity * | cm | ) |
Retrieve the automatic price quote flag for the specified commodity.
This flag indicates whether stock quotes should be retrieved for the specified stock.
cm | A pointer to a commodity data structure. |
Definition at line 1050 of file gnc-commodity.cpp.
gnc_quote_source* gnc_commodity_get_quote_source | ( | const gnc_commodity * | cm | ) |
Retrieve the automatic price quote source for the specified commodity.
This will be a pointer to a null terminated string of the form "Yahoo (Asia)", etc.
cm | A pointer to a commodity data structure. |
Definition at line 1061 of file gnc-commodity.cpp.
const char* gnc_commodity_get_quote_tz | ( | const gnc_commodity * | cm | ) |
Retrieve the automatic price quote timezone for the specified commodity.
This will be a pointer to a null terminated string of the form "America/New_York", etc.
cm | A pointer to a commodity data structure. |
Definition at line 1086 of file gnc-commodity.cpp.
const char* gnc_commodity_get_unique_name | ( | const gnc_commodity * | cm | ) |
Retrieve the 'unique' name for the specified commodity.
This will be a pointer to a null terminated string of the form "AMEX::ACME", etc. This field is often used when performing comparisons or other functions invisible to the user.
cm | A pointer to a commodity data structure. |
Definition at line 997 of file gnc-commodity.cpp.
const char* gnc_commodity_get_user_symbol | ( | const gnc_commodity * | cm | ) |
Retrieve the user-defined symbol for the specified commodity.
This will be a pointer to a nul terminated string like "£", "US$", etc.
cm | A pointer to a commodity data structure. |
Definition at line 1096 of file gnc-commodity.cpp.
void gnc_commodity_increment_usage_count | ( | gnc_commodity * | cm | ) |
Increment a commodity's internal counter that tracks how many accounts are using that commodity.
For currencies, this may have the side effect of enabling the commodity's quote flag.
cm | A pointer to a commodity data structure. |
Definition at line 1446 of file gnc-commodity.cpp.
gboolean gnc_commodity_is_currency | ( | const gnc_commodity * | cm | ) |
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency.
cm | The commodity to check. |
Definition at line 1997 of file gnc-commodity.cpp.
gboolean gnc_commodity_is_iso | ( | const gnc_commodity * | cm | ) |
Checks to see if the specified commodity is an ISO 4217 recognized currency.
cm | The commodity to check. |
Definition at line 1985 of file gnc-commodity.cpp.
GList* gnc_commodity_namespace_get_commodity_list | ( | const gnc_commodity_namespace * | ns | ) |
Return a list of all commodity data structures in the specified namespace.
Definition at line 1585 of file gnc-commodity.cpp.
const char* gnc_commodity_namespace_get_gui_name | ( | const gnc_commodity_namespace * | ns | ) |
Return the textual name of a namespace data structure in a form suitable to present to the user.
ns | A pointer to the namespace data structure. |
The returned string is marked for translation, but not translated yet. If you want it translated pass the return value on to gettext.
Definition at line 1575 of file gnc-commodity.cpp.
const char* gnc_commodity_namespace_get_name | ( | const gnc_commodity_namespace * | ns | ) |
Return the textual name of a namespace data structure.
ns | A pointer to the namespace data structure. |
Definition at line 1567 of file gnc-commodity.cpp.
gboolean gnc_commodity_namespace_is_iso | ( | const char * | commodity_namespace | ) |
Checks to see if the specified commodity namespace is the namespace for ISO 4217 currencies.
commodity_namespace | The string to check. |
Definition at line 1594 of file gnc-commodity.cpp.
gnc_commodity* gnc_commodity_new | ( | QofBook * | book, |
const char * | fullname, | ||
const char * | commodity_namespace, | ||
const char * | mnemonic, | ||
const char * | cusip, | ||
int | fraction | ||
) |
Create a new commodity.
This function allocates a new commodity data structure, populates it with the data provided, and then generates the dynamic names that exist as part of a commodity.
book | The book that the new commodity will belong to. |
fullname | The complete name of this commodity. E.G. "Acme Systems, Inc." |
commodity_namespace | An aggregation of commodities. E.G. ISO4217, Nasdaq, Downbelow, etc. |
mnemonic | An abbreviation for this stock. For publicly traced stocks, this field should contain the stock ticker symbol. This field is used to get online price quotes, so it must match the stock ticker symbol used by the exchange where you want to get automatic stock quote updates. E.G. ACME, ACME.US, etc. |
cusip | A string containing the CUSIP code or similar UNIQUE code for this commodity like the ISIN. The stock ticker is NOT appropriate as that goes in the mnemonic field. |
fraction | The smallest division of this commodity allowed. I.E. If this is 1, then the commodity must be traded in whole units; if 100 then the commodity may be traded in 0.01 units, etc. |
Definition at line 791 of file gnc-commodity.cpp.
gnc_commodity* gnc_commodity_obtain_twin | ( | const gnc_commodity * | findlike, |
QofBook * | book | ||
) |
Given the commodity 'findlike', this routine will find and return the equivalent commodity (commodity with the same 'unique name') in the indicated book.
This routine is primarily useful for setting up clones of things across multiple books.
Definition at line 1634 of file gnc-commodity.cpp.
void gnc_commodity_set_cusip | ( | gnc_commodity * | cm, |
const char * | cusip | ||
) |
Set the 'exchange code' for the specified commodity.
This should be a pointer to a null terminated string of the form "AXQ14728", etc.
cm | A pointer to a commodity data structure. |
cusip | A pointer to the cusip or other exchange specific data for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1223 of file gnc-commodity.cpp.
void gnc_commodity_set_fraction | ( | gnc_commodity * | cm, |
int | smallest_fraction | ||
) |
Set the fraction for the specified commodity.
This should be an integer value specifying the number of fractional units that one of these commodities can be divided into. Should always be a power of 10.
cm | A pointer to a commodity data structure. |
smallest_fraction | The number of fractional units that one of these commodities can be divided into. |
Definition at line 1245 of file gnc-commodity.cpp.
void gnc_commodity_set_fullname | ( | gnc_commodity * | cm, |
const char * | fullname | ||
) |
Set the full name for the specified commodity.
This should be a pointer to a null terminated string of the form "Acme Systems, Inc.", etc.
cm | A pointer to a commodity data structure. |
fullname | A pointer to the full name for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1201 of file gnc-commodity.cpp.
void gnc_commodity_set_mnemonic | ( | gnc_commodity * | cm, |
const char * | mnemonic | ||
) |
Set the mnemonic for the specified commodity.
This should be a pointer to a null terminated string of the form "ACME", "QWER", etc.
cm | A pointer to a commodity data structure. |
mnemonic | A pointer to the mnemonic for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1148 of file gnc-commodity.cpp.
void gnc_commodity_set_namespace | ( | gnc_commodity * | cm, |
const char * | new_namespace | ||
) |
Set the namespace for the specified commodity.
This should be a pointer to a null terminated string of the form "AMEX", "NASDAQ", etc.
cm | A pointer to a commodity data structure. |
new_namespace | A pointer to the namespace for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1171 of file gnc-commodity.cpp.
void gnc_commodity_set_quote_flag | ( | gnc_commodity * | cm, |
const gboolean | flag | ||
) |
Set the automatic price quote flag for the specified commodity.
This flag indicates whether stock quotes should be retrieved for the specified stock.
cm | A pointer to a commodity data structure. |
flag | TRUE if quotes should be pulled for this commodity, FALSE otherwise. |
Definition at line 1326 of file gnc-commodity.cpp.
void gnc_commodity_set_quote_source | ( | gnc_commodity * | cm, |
gnc_quote_source * | src | ||
) |
Set the automatic price quote source for the specified commodity.
This should be a pointer to a null terminated string of the form "Yahoo (Asia)", etc. Legal values can be found in the quote_sources array in the file gnc-ui-util.c.
cm | A pointer to a commodity data structure. |
src | A pointer to the price quote source for this commodity. |
Definition at line 1343 of file gnc-commodity.cpp.
void gnc_commodity_set_quote_tz | ( | gnc_commodity * | cm, |
const char * | tz | ||
) |
Set the automatic price quote timezone for the specified commodity.
This should be a pointer to a null terminated string of the form "America/New_York", etc. Legal values can be found in the known_timezones array in the file src/gnome-utils/dialog-commodity.c.
cm | A pointer to a commodity data structure. |
tz | A pointer to the price quote timezone for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1360 of file gnc-commodity.cpp.
void gnc_commodity_set_user_symbol | ( | gnc_commodity * | cm, |
const char * | user_symbol | ||
) |
Set a user-defined symbol for the specified commodity.
This should be a pointer to a nul terminated string like "£", "US$", etc.
cm | A pointer to a commodity data structure. |
tz | A pointer to the symbol for this commodity. This string belongs to the caller and will be duplicated by the engine. |
Definition at line 1389 of file gnc-commodity.cpp.
gboolean gnc_commodity_table_add_default_data | ( | gnc_commodity_table * | table, |
QofBook * | book | ||
) |
Add all the standard namespaces and currencies to the commodity table.
This routine creates the namespaces for the NYSE, NASDAQ, etc. It also adds all of the ISO 4217 currencies to the commodity table.
table | A pointer to the commodity table. |
book | Unused. |
Definition at line 2330 of file gnc-commodity.cpp.
gnc_commodity_namespace* gnc_commodity_table_add_namespace | ( | gnc_commodity_table * | table, |
const char * | commodity_namespace, | ||
QofBook * | book | ||
) |
This function adds a new string to the list of commodity namespaces.
If the new namespace already exists, nothing happens.
table | A pointer to the commodity table |
commodity_namespace | The new namespace to be added. |
book | The book that the new namespace will belong to. |
Definition at line 2150 of file gnc-commodity.cpp.
void gnc_commodity_table_delete_namespace | ( | gnc_commodity_table * | table, |
const char * | commodity_namespace | ||
) |
This function deletes a string from the list of commodity namespaces.
If the namespace does not exist, nothing happens.
table | A pointer to the commodity table |
commodity_namespace | The namespace to be deleted. |
Definition at line 2215 of file gnc-commodity.cpp.
gnc_commodity_namespace* gnc_commodity_table_find_namespace | ( | const gnc_commodity_table * | table, |
const char * | commodity_namespace | ||
) |
This function finds a commodity namespace in the set of existing commodity namespaces.
table | A pointer to the commodity table |
commodity_namespace | The new namespace to be added. |
Definition at line 2180 of file gnc-commodity.cpp.
gboolean gnc_commodity_table_foreach_commodity | ( | const gnc_commodity_table * | table, |
gboolean(*)(gnc_commodity *cm, gpointer user_data) | f, | ||
gpointer | user_data | ||
) |
Call a function once for each commodity in the commodity table.
This table walk returns whenever the end of the table is reached, or the function returns FALSE.
table | A pointer to the commodity table |
f | The function to call for each commodity. |
user_data | A pointer that is passed into the function unchanged by the table walk routine. |
CommodityList* gnc_commodity_table_get_commodities | ( | const gnc_commodity_table * | table, |
const char * | commodity_namespace | ||
) |
Return a list of all commodities in the commodity table that are in the given namespace.
table | A pointer to the commodity table |
commodity_namespace | A string indicating which commodities should be returned. It is a required argument. |
Definition at line 2033 of file gnc-commodity.cpp.
GList* gnc_commodity_table_get_namespaces | ( | const gnc_commodity_table * | t | ) |
Return a list of all namespaces in the commodity table.
This returns both system and user defined namespaces.
Definition at line 1961 of file gnc-commodity.cpp.
GList* gnc_commodity_table_get_namespaces_list | ( | const gnc_commodity_table * | t | ) |
Return a list of all namespace data structures in the commodity table.
This returns both system and user defined namespace structures.
Definition at line 1970 of file gnc-commodity.cpp.
CommodityList* gnc_commodity_table_get_quotable_commodities | ( | const gnc_commodity_table * | table | ) |
This function returns a list of commodities for which price quotes should be retrieved.
It will scan the entire commodity table (or a subset) and check each commodity to see if the price_quote_flag field has been set. All matching commodities are queued onto a list, and the head of that list is returned. Use the command-line given expression as a filter on the commodities to be returned. If non-null, only commodities in namespace that match the specified regular expression are checked. If none was given, all commodities are checked.
table | A pointer to the commodity table |
Definition at line 2079 of file gnc-commodity.cpp.
guint gnc_commodity_table_get_size | ( | const gnc_commodity_table * | tbl | ) |
Returns the number of commodities in the commodity table.
tbl | A pointer to the commodity table |
Definition at line 1677 of file gnc-commodity.cpp.
int gnc_commodity_table_has_namespace | ( | const gnc_commodity_table * | table, |
const char * | commodity_namespace | ||
) |
Test to see if the indicated namespace exits in the commodity table.
table | A pointer to the commodity table |
commodity_namespace | The new namespace to check. |
Definition at line 1904 of file gnc-commodity.cpp.
gnc_commodity* gnc_commodity_table_insert | ( | gnc_commodity_table * | table, |
gnc_commodity * | comm | ||
) |
Add a new commodity to the commodity table.
This routine handles the cases where the commodity already exists in the database (does nothing), or another entries has the same namespace and mnemonic (updates the existing entry).
table | A pointer to the commodity table |
comm | A pointer to the commodity to add. |
Definition at line 1798 of file gnc-commodity.cpp.
gnc_commodity_table* gnc_commodity_table_new | ( | void | ) |
You probably shouldn't be using gnc_commodity_table_new() directly, it's for internal use only.
You should probably be using gnc_commodity_table_get_table()
Definition at line 1614 of file gnc-commodity.cpp.
void gnc_commodity_table_remove | ( | gnc_commodity_table * | table, |
gnc_commodity * | comm | ||
) |
Remove a commodity from the commodity table.
If the commodity to remove doesn't exist, nothing happens.
table | A pointer to the commodity table |
comm | A pointer to the commodity to remove. |
Definition at line 1872 of file gnc-commodity.cpp.
void gnc_commodity_user_set_quote_flag | ( | gnc_commodity * | cm, |
const gboolean | flag | ||
) |
Set the automatic price quote flag for the specified commodity, based on user input.
This flag indicates whether stock quotes should be retrieved for the specified stock.
It is necessary to have a separate function to distinguish when this setting is being modified by a user so that the auto-enabling/auto-disabling of currencies can be handled properly.
cm | A pointer to a commodity data structure. |
flag | TRUE if quotes should be pulled for this commodity, FALSE otherwise. |
Definition at line 1290 of file gnc-commodity.cpp.
MonetaryList* gnc_monetary_list_delete_zeros | ( | MonetaryList * | list | ) |
Delete all the zero-value entries from a list.
Delete all the zero-value entries from a list.
Return list pointer will be a null pointer if there are no non-zero entries
Definition at line 2482 of file gnc-commodity.cpp.
void gnc_monetary_list_free | ( | MonetaryList * | list | ) |
Free a monetary list and all the items it points to.
Free a monetary list and all the items it points to.
Definition at line 2500 of file gnc-commodity.cpp.
gnc_quote_source* gnc_quote_source_add_new | ( | const char * | name, |
gboolean | supported | ||
) |
Create a new quote source.
This is called by the F::Q startup code or the XML parsing code to add new entries to the list of available quote sources.
name | The internal name for this new quote source. |
supported | TRUE if this quote source is supported by F::Q. Should only be set by the F::Q startup routine. |
Definition at line 333 of file gnc-commodity.cpp.
gboolean gnc_quote_source_fq_installed | ( | void | ) |
This function indicates whether or not the Finance::Quote module is installed on a user's computer.
This includes any other related modules that gnucash need to process F::Q information.
Definition at line 280 of file gnc-commodity.cpp.
const char* gnc_quote_source_fq_version | ( | void | ) |
This function returns the version of the Finance::Quote module installed on a user's computer.
If no proper installation is found it will return NULL.
Definition at line 293 of file gnc-commodity.cpp.
gint gnc_quote_source_get_index | ( | const gnc_quote_source * | source | ) |
Given a gnc_quote_source data structure, return the index of this particular quote source within its type.
source | The quote source in question. |
Definition at line 404 of file gnc-commodity.cpp.
const char* gnc_quote_source_get_internal_name | ( | const gnc_quote_source * | source | ) |
Given a gnc_quote_source data structure, return the internal name of this quote source.
This is the name used by both gnucash and by Finance::Quote. E.G. "yahoo_australia" or "australia"
source | The quote source in question. |
Definition at line 452 of file gnc-commodity.cpp.
gboolean gnc_quote_source_get_supported | ( | const gnc_quote_source * | source | ) |
Given a gnc_quote_source data structure, return the flag that indicates whether this particular quote source is supported by the user's F::Q installation.
source | The quote source in question. |
Definition at line 425 of file gnc-commodity.cpp.
QuoteSourceType gnc_quote_source_get_type | ( | const gnc_quote_source * | source | ) |
Given a gnc_quote_source data structure, return the type of this particular quote source.
(SINGLE, MULTI, UNKNOWN)
source | The quote source in question. |
Definition at line 390 of file gnc-commodity.cpp.
const char* gnc_quote_source_get_user_name | ( | const gnc_quote_source * | source | ) |
Given a gnc_quote_source data structure, return the user friendly name of this quote source.
E.G. "Yahoo Australia" or "Australia (Yahoo, ASX, ...)"
source | The quote source in question. |
Definition at line 439 of file gnc-commodity.cpp.
gnc_quote_source* gnc_quote_source_lookup_by_internal | ( | const char * | internal_name | ) |
Given the internal (gnucash or F::Q) name of a quote source, find the data structure identified by this name.
internal_name | The name of this quote source. |
Definition at line 366 of file gnc-commodity.cpp.
gnc_quote_source* gnc_quote_source_lookup_by_ti | ( | QuoteSourceType | type, |
gint | index | ||
) |
Given the type/index of a quote source, find the data structure identified by this pair.
type | The type of this quote source. |
index | The index of this quote source within its type. |
Definition at line 350 of file gnc-commodity.cpp.
gint gnc_quote_source_num_entries | ( | QuoteSourceType | type | ) |
Return the number of entries for a given type of quote source.
type | The quote source type whose count should be returned. |
Definition at line 316 of file gnc-commodity.cpp.
void gnc_quote_source_set_fq_installed | ( | const char * | version_string, |
const std::vector< std::string > & | sources_list | ||
) |
Update gnucash internal tables based on what Finance::Quote sources are installed.
Sources that have been explicitly coded into gnucash are marked sensitive/insensitive based upon whether they are present. New sources that gnucash doesn't know about are added to its internal tables.
sources_list | A list of strings containing the source names as they are known to F::Q. |
Definition at line 472 of file gnc-commodity.cpp.