23#include <boost/container/flat_map.hpp>
27#include "gnc-session.h"
28#include <gnc-numeric.hpp>
29#include <gnc-rational-rounding.hpp>
32static const boost::container::flat_map <std::string, GncNumeric> gnc_euro_rates =
34 {
"ATS", {137603, 10000} },
35 {
"BEF", {403399, 10000} },
36 {
"BGN", {195583, 100000} },
37 {
"CYP", {585274, 1000000} },
38 {
"DEM", {195583, 100000} },
39 {
"EEK", {156466, 10000} },
40 {
"ESP", {166386, 1000} },
42 {
"FIM", {594573, 100000} },
43 {
"FRF", {655957, 100000} },
44 {
"GRD", {340750, 1000} },
45 {
"HRK", {753450, 100000} },
46 {
"IEP", {787564, 1000000} },
47 {
"ITL", {193627, 100} },
48 {
"LUF", {403399, 10000} },
49 {
"LVL", {702804, 1000000} },
50 {
"MTL", {429300, 1000000} },
51 {
"NLG", {220371, 100000} },
52 {
"PTE", {200482, 1000} },
53 {
"SIT", {239640, 1000} },
54 {
"SKK", {301260, 10000} }
57static std::optional<GncNumeric>
58get_euro_rate (
const gnc_commodity * currency)
64 if (it == gnc_euro_rates.end())
73gnc_is_euro_currency(
const gnc_commodity * currency)
75 return get_euro_rate (currency).has_value();
81gnc_convert_to_euro(
const gnc_commodity * currency, gnc_numeric value)
83 auto euro_rate = get_euro_rate (currency);
85 return gnc_numeric_zero();
91 return (value / *euro_rate).convert<RoundType::half_up>(100);
97gnc_convert_from_euro(
const gnc_commodity * currency, gnc_numeric value)
99 auto euro_rate = get_euro_rate (currency);
101 return gnc_numeric_zero();
111gnc_euro_currency_get_rate (
const gnc_commodity *currency)
113 auto euro_rate = get_euro_rate (currency);
115 return gnc_numeric_zero();
117 return static_cast<gnc_numeric
>(*euro_rate);
128 return gnc_commodity_table_lookup (
table, GNC_COMMODITY_NS_CURRENCY,
"EUR");
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.