24 #ifndef GNC_PRICE_PROPS_HPP 25 #define GNC_PRICE_PROPS_HPP 32 #include <glib/gi18n.h> 40 #include <gnc-datetime.hpp> 41 #include <gnc-numeric.hpp> 47 enum class GncPricePropType {
54 PRICE_PROPS = TO_CURRENCY
57 enum Result { FAILED, ADDED, DUPLICATED, REPLACED };
63 extern std::map<GncPricePropType, const char*> gnc_price_col_type_strs;
71 bool operator()(
const std::pair<GncPricePropType, const char*>& v )
const 73 return !g_strcmp0(v.second, m_name);
79 gnc_commodity* parse_commodity_price_comm (
const std::string& symbol_str,
const std::string& namespace_str);
80 bool parse_namespace (
const std::string& namespace_str);
81 GncNumeric parse_amount_price (
const std::string &str,
int currency_format);
86 GncImportPrice (
int date_format,
int currency_format) : m_date_format{date_format},
87 m_currency_format{currency_format}{};
89 void set (GncPricePropType prop_type,
const std::string& value,
bool enable_test_empty);
90 void set_date_format (
int date_format) { m_date_format = date_format ;}
91 void set_currency_format (
int currency_format) { m_currency_format = currency_format ;}
92 void reset (GncPricePropType prop_type);
93 std::string verify_essentials (
void);
94 Result create_price (QofBook* book, GNCPriceDB *pdb,
bool over);
96 gnc_commodity* get_from_commodity () {
if (m_from_commodity)
return *m_from_commodity;
else return nullptr; }
97 void set_from_commodity (gnc_commodity* comm) {
if (comm) m_from_commodity = comm;
else m_from_commodity.reset(); }
99 gnc_commodity* get_to_currency () {
if (m_to_currency)
return *m_to_currency;
else return nullptr; }
100 void set_to_currency (gnc_commodity* curr) {
if (curr) m_to_currency = curr;
else m_to_currency.reset(); }
102 std::string errors();
106 int m_currency_format;
107 std::optional<GncDate> m_date;
108 std::optional<GncNumeric> m_amount;
109 std::optional<gnc_commodity*> m_from_commodity;
110 std::optional<std::string> m_from_namespace;
111 std::optional<std::string> m_from_symbol;
112 std::optional<gnc_commodity*> m_to_currency;
114 std::map<GncPricePropType, std::string> m_errors;
a simple price database for gnucash
The primary numeric class for representing amounts and values.
Functor to check if the above map has an element of which the value equals name.
Commodity handling public routines.