39 memset(&data, 0,
sizeof(data));
42 OfxPositionContainer::~OfxPositionContainer()
47 if (identifier ==
"UNIQUEID")
50 data.unique_id_valid =
true;
52 else if (identifier ==
"UNIQUEIDTYPE")
55 data.unique_id_type_valid =
true;
57 else if (identifier ==
"HELDINACCT")
62 data.heldinaccount_type_valid =
true;
64 else if (value ==
"MARGIN")
67 data.heldinaccount_type_valid =
true;
69 else if (value ==
"SHORT")
72 data.heldinaccount_type_valid =
true;
74 else if (value ==
"OTHER")
77 data.heldinaccount_type_valid =
true;
80 else if (identifier ==
"POSTYPE")
84 data.position_type = data.OFX_POSITION_SHORT;
85 data.position_type_valid =
true;
87 else if (value ==
"LONG")
89 data.position_type = data.OFX_POSITION_LONG;
90 data.position_type_valid =
true;
93 else if (identifier ==
"UNITS")
96 data.units_valid =
true;
98 else if (identifier ==
"UNITPRICE")
101 data.unit_price_valid =
true;
103 else if (identifier ==
"MKTVAL")
106 data.market_value_valid =
true;
108 else if (identifier ==
"DTPRICEASOF")
111 data.date_unit_price_valid =
true;
113 else if (identifier ==
"CURRATE")
116 data.currency_ratio_valid =
true;
118 else if (identifier ==
"CURSYM")
121 data.currency_valid =
true;
123 else if (identifier ==
"CURRENCY")
126 data.amounts_are_foreign_currency_valid =
true;
128 else if (identifier ==
"ORIGCURRENCY")
131 data.amounts_are_foreign_currency_valid =
true;
133 else if (identifier ==
"MEMO")
135 strncpy(data.
memo, value.c_str(),
sizeof(data.
memo));
136 data.memo_valid =
true;
138 else if (identifier ==
"INV401KSOURCE")
140 if (value ==
"PRETAX")
142 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_PRETAX;
143 data.inv_401k_source_valid =
true;
145 else if (value ==
"AFTERTAX")
147 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_AFTERTAX;
148 data.inv_401k_source_valid =
true;
150 else if (value ==
"MATCH")
152 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_MATCH;
153 data.inv_401k_source_valid =
true;
155 else if (value ==
"PROFITSHARING")
157 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_PROFITSHARING;
158 data.inv_401k_source_valid =
true;
160 else if (value ==
"ROLLOVER")
162 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_ROLLOVER;
163 data.inv_401k_source_valid =
true;
165 else if (value ==
"OTHERVEST")
167 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_OTHERVEST;
168 data.inv_401k_source_valid =
true;
170 else if (value ==
"OTHERNONVEST")
172 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_OTHERNONVEST;
173 data.inv_401k_source_valid =
true;
184 if (data.unique_id_valid ==
true && MainContainer != NULL)
189 data.security_data_valid =
true;
192 libofx_context->positionCallback(data);
196 void OfxPositionContainer::add_account(
OfxAccountData * account_data)
198 if (account_data->account_id_valid ==
true)
202 data.account_id_valid =
true;
208 if (MainContainer != NULL)
210 return MainContainer->add_container(
this);
void add_attribute(const string identifier, const string value)
Add data to a container object.
An abstraction of an account.
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float.
char currency[OFX_CURRENCY_LENGTH]
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
int amounts_are_foreign_currency
char account_id[OFX_ACCOUNT_ID_LENGTH]
char account_id[OFX_ACCOUNT_ID_LENGTH]
Various simple functions for type conversion & al.
virtual int gen_event()
Generate libofx.h events.
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
time_t ofxdate_to_time_t(const string ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
struct OfxSecurityData * security_data_ptr
char unique_id[OFX_UNIQUE_ID_LENGTH]
char memo[OFX_MEMO_LENGTH]
LibOFX internal object code.
virtual int add_to_main_tree()
Add this container to the main tree.
Message IO functionality.
struct OfxAccountData * account_ptr
The root container. Created by the <OFX> OFX element or by the export functions.