42 memset(&data, 0,
sizeof(data));
45 while (tmp_parentcontainer != NULL && tmp_parentcontainer->
type !=
"STATEMENT")
47 tmp_parentcontainer = tmp_parentcontainer->parentcontainer;
49 if (tmp_parentcontainer != NULL)
55 parent_statement = NULL;
56 message_out(
ERROR,
"Unable to find the enclosing statement container this transaction");
58 if (parent_statement != NULL && parent_statement->data.account_id_valid ==
true)
60 strncpy(data.
account_id, parent_statement->data.account_id, OFX_ACCOUNT_ID_LENGTH);
61 data.account_id_valid =
true;
64 OfxTransactionContainer::~OfxTransactionContainer()
71 if (data.unique_id_valid ==
true && MainContainer != NULL)
73 data.security_data_ptr = MainContainer->find_security(data.unique_id);
74 if (data.security_data_ptr != NULL)
76 data.security_data_valid =
true;
79 libofx_context->transactionCallback(data);
86 if (MainContainer != NULL)
88 return MainContainer->add_container(
this);
100 if (identifier ==
"DTPOSTED")
103 data.date_posted_valid =
true;
105 else if (identifier ==
"DTUSER")
108 data.date_initiated_valid =
true;
110 else if (identifier ==
"DTAVAIL")
113 data.date_funds_available_valid =
true;
115 else if (identifier ==
"FITID")
117 strncpy(data.fi_id, value.c_str(),
sizeof(data.fi_id));
118 data.fi_id_valid =
true;
120 else if (identifier ==
"CORRECTFITID")
122 strncpy(data.fi_id_corrected, value.c_str(),
sizeof(data.fi_id));
123 data.fi_id_corrected_valid =
true;
125 else if (identifier ==
"CORRECTACTION")
127 data.fi_id_correction_action_valid =
true;
128 if (value ==
"REPLACE")
130 data.fi_id_correction_action =
REPLACE;
132 else if (value ==
"DELETE")
134 data.fi_id_correction_action =
DELETE;
138 data.fi_id_correction_action_valid =
false;
141 else if ((identifier ==
"SRVRTID") || (identifier ==
"SRVRTID2"))
143 strncpy(data.server_transaction_id, value.c_str(),
sizeof(data.server_transaction_id));
144 data.server_transaction_id_valid =
true;
146 else if (identifier ==
"MEMO" || identifier ==
"MEMO2")
148 strncpy(data.memo, value.c_str(),
sizeof(data.memo));
149 data.memo_valid =
true;
158 void OfxTransactionContainer::add_account(
OfxAccountData * account_data)
160 if (account_data->account_id_valid ==
true)
164 data.account_id_valid =
true;
172 OfxBankTransactionContainer::OfxBankTransactionContainer(
LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer,
string para_tag_identifier):
179 if ( identifier ==
"TRNTYPE")
181 data.transactiontype_valid =
true;
182 if (value ==
"CREDIT")
186 else if (value ==
"DEBIT")
190 else if (value ==
"INT")
192 data.transactiontype =
OFX_INT;
194 else if (value ==
"DIV")
196 data.transactiontype =
OFX_DIV;
198 else if (value ==
"FEE")
200 data.transactiontype =
OFX_FEE;
202 else if (value ==
"SRVCHG")
206 else if (value ==
"DEP")
208 data.transactiontype =
OFX_DEP;
210 else if (value ==
"ATM")
212 data.transactiontype =
OFX_ATM;
214 else if (value ==
"POS")
216 data.transactiontype =
OFX_POS;
218 else if (value ==
"XFER")
222 else if (value ==
"CHECK")
226 else if (value ==
"PAYMENT")
230 else if (value ==
"CASH")
234 else if (value ==
"DIRECTDEP")
238 else if (value ==
"DIRECTDEBIT")
242 else if (value ==
"REPEATPMT")
246 else if (value ==
"OTHER")
252 data.transactiontype_valid =
false;
255 else if (identifier ==
"TRNAMT")
258 data.amount_valid =
true;
259 data.units = -data.amount;
260 data.units_valid =
true;
261 data.unitprice = 1.00;
262 data.unitprice_valid =
true;
264 else if (identifier ==
"CHECKNUM")
266 strncpy(data.check_number, value.c_str(),
sizeof(data.check_number));
267 data.check_number_valid =
true;
269 else if (identifier ==
"REFNUM")
271 strncpy(data.reference_number, value.c_str(),
sizeof(data.reference_number));
272 data.reference_number_valid =
true;
274 else if (identifier ==
"SIC")
276 data.standard_industrial_code = atoi(value.c_str());
277 data.standard_industrial_code_valid =
true;
279 else if ((identifier ==
"PAYEEID") || (identifier ==
"PAYEEID2"))
281 strncpy(data.payee_id, value.c_str(),
sizeof(data.payee_id));
282 data.payee_id_valid =
true;
284 else if (identifier ==
"NAME")
286 strncpy(data.name, value.c_str(),
sizeof(data.name));
287 data.name_valid =
true;
301 OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(
LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer,
string para_tag_identifier):
306 data.transactiontype_valid =
true;
308 data.invtransactiontype_valid =
true;
309 if (para_tag_identifier ==
"BUYDEBT")
313 else if (para_tag_identifier ==
"BUYMF")
317 else if (para_tag_identifier ==
"BUYOPT")
321 else if (para_tag_identifier ==
"BUYOTHER")
325 else if (para_tag_identifier ==
"BUYSTOCK")
329 else if (para_tag_identifier ==
"CLOSUREOPT")
333 else if (para_tag_identifier ==
"INCOME")
337 else if (para_tag_identifier ==
"INVEXPENSE")
341 else if (para_tag_identifier ==
"JRNLFUND")
345 else if (para_tag_identifier ==
"JRNLSEC")
349 else if (para_tag_identifier ==
"MARGININTEREST")
353 else if (para_tag_identifier ==
"REINVEST")
357 else if (para_tag_identifier ==
"RETOFCAP")
361 else if (para_tag_identifier ==
"SELLDEBT")
365 else if (para_tag_identifier ==
"SELLMF")
369 else if (para_tag_identifier ==
"SELLOPT")
373 else if (para_tag_identifier ==
"SELLOTHER")
377 else if (para_tag_identifier ==
"SELLSTOCK")
381 else if (para_tag_identifier ==
"SPLIT")
385 else if (para_tag_identifier ==
"TRANSFER")
391 message_out(
ERROR,
"This should not happen, " + para_tag_identifier +
" is an unknown investment transaction type");
392 data.invtransactiontype_valid =
false;
398 if (identifier ==
"UNIQUEID")
400 strncpy(data.unique_id, value.c_str(),
sizeof(data.unique_id));
401 data.unique_id_valid =
true;
403 else if (identifier ==
"UNIQUEIDTYPE")
405 strncpy(data.unique_id_type, value.c_str(),
sizeof(data.unique_id_type));
406 data.unique_id_type_valid =
true;
408 else if (identifier ==
"UNITS")
411 data.units_valid =
true;
413 else if (identifier ==
"UNITPRICE")
416 data.unitprice_valid =
true;
418 else if (identifier ==
"MKTVAL")
420 message_out(
DEBUG,
"MKTVAL of " + value +
" ignored since MKTVAL should always be UNITS*UNITPRICE");
422 else if (identifier ==
"TOTAL")
425 data.amount_valid =
true;
427 else if (identifier ==
"DTSETTLE")
430 data.date_posted_valid =
true;
432 else if (identifier ==
"DTTRADE")
435 data.date_initiated_valid =
true;
437 else if (identifier ==
"COMMISSION")
440 data.commission_valid =
true;
442 else if (identifier ==
"FEES")
445 data.fees_valid =
true;
447 else if (identifier ==
"OLDUNITS")
450 data.oldunits_valid =
true;
452 else if (identifier ==
"NEWUNITS")
455 data.newunits_valid =
true;
An abstraction of an account.
virtual int add_to_main_tree()
Add this container to the main tree.
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
char account_id[OFX_ACCOUNT_ID_LENGTH]
Represents a generic transaction.
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
char account_id[OFX_ACCOUNT_ID_LENGTH]
int message_out(OfxMsgType error_type, const string message)
Message output function.
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.
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float.
struct OfxAccountData * account_ptr
void add_attribute(const string identifier, const string value)
Add data to a container object.
Various simple functions for type conversion & al.
Represents a statement for either a bank account or a credit card account.
LibOFX internal object code.
Message IO functionality.
The root container. Created by the <OFX> OFX element or by the export functions.
virtual int gen_event()
Generate libofx.h events.