mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/gnome/dialog-transfer.c: set price for euro currencies
automatically * src/EuroUtils.c (gnc_euro_currency_get_rate): new func git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4035 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9303cbb978
commit
03b3547395
@ -36,6 +36,7 @@ typedef struct _gnc_euro_rate_struct {
|
||||
|
||||
|
||||
/* This array MUST be sorted ! */
|
||||
/* The rates are per EURO */
|
||||
static gnc_euro_rate_struct _gnc_euro_rate_[] =
|
||||
{
|
||||
{ "ATS", 13.7603 }, /* austrian schilling */
|
||||
@ -82,7 +83,7 @@ _gnc_euro_rate_compare_(const void * key, const void * value)
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
gboolean
|
||||
gnc_is_euro_currency(gnc_commodity * currency)
|
||||
gnc_is_euro_currency(const gnc_commodity * currency)
|
||||
{
|
||||
|
||||
gnc_euro_rate_struct *result;
|
||||
@ -113,7 +114,7 @@ gnc_is_euro_currency(gnc_commodity * currency)
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
gnc_numeric
|
||||
gnc_convert_to_euro(gnc_commodity * currency, gnc_numeric value) {
|
||||
gnc_convert_to_euro(const gnc_commodity * currency, gnc_numeric value) {
|
||||
|
||||
gnc_euro_rate_struct *result;
|
||||
const char *namespace;
|
||||
@ -150,7 +151,7 @@ gnc_convert_to_euro(gnc_commodity * currency, gnc_numeric value) {
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
gnc_numeric
|
||||
gnc_convert_from_euro(gnc_commodity * currency, gnc_numeric value) {
|
||||
gnc_convert_from_euro(const gnc_commodity * currency, gnc_numeric value) {
|
||||
|
||||
gnc_euro_rate_struct * result;
|
||||
const char *namespace;
|
||||
@ -186,6 +187,37 @@ gnc_convert_from_euro(gnc_commodity * currency, gnc_numeric value) {
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
gnc_numeric
|
||||
gnc_euro_currency_get_rate (const gnc_commodity *currency)
|
||||
{
|
||||
gnc_euro_rate_struct * result;
|
||||
const char *namespace;
|
||||
|
||||
if (currency == NULL)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
namespace = gnc_commodity_get_namespace (currency);
|
||||
if (namespace == NULL)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
if (strcmp (namespace, GNC_COMMODITY_NS_ISO) != 0)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
result = bsearch(currency,
|
||||
_gnc_euro_rate_,
|
||||
sizeof(_gnc_euro_rate_) / sizeof(gnc_euro_rate_struct),
|
||||
sizeof(gnc_euro_rate_struct),
|
||||
_gnc_euro_rate_compare_);
|
||||
|
||||
if (result == NULL)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
return double_to_gnc_numeric (result->rate, GNC_DENOM_AUTO,
|
||||
GNC_DENOM_SIGFIGS(6) | GNC_RND_ROUND);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
gnc_commodity *
|
||||
gnc_get_euro (void)
|
||||
{
|
||||
|
@ -27,11 +27,12 @@
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-numeric.h"
|
||||
|
||||
gboolean gnc_is_euro_currency (gnc_commodity * currency);
|
||||
gnc_numeric gnc_convert_to_euro (gnc_commodity * currency,
|
||||
gboolean gnc_is_euro_currency (const gnc_commodity * currency);
|
||||
gnc_numeric gnc_convert_to_euro (const gnc_commodity * currency,
|
||||
gnc_numeric value);
|
||||
gnc_numeric gnc_convert_from_euro (gnc_commodity * currency,
|
||||
gnc_numeric gnc_convert_from_euro (const gnc_commodity * currency,
|
||||
gnc_numeric value);
|
||||
gnc_numeric gnc_euro_currency_get_rate (const gnc_commodity *currency);
|
||||
|
||||
gnc_commodity * gnc_get_euro (void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user