lib/ofx_container_transaction.cpp
Go to the documentation of this file.
/***************************************************************************
ofx_container_account.cpp
-------------------
copyright : (C) 2002 by Benoit Gr�goire
email : benoitg@coeus.ca
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cstdlib>
#include <string>
#include "messages.hh"
#include "libofx.h"
#include "ofx_containers.hh"
#include "ofx_utilities.hh"
extern OfxMainContainer * MainContainer;
/***************************************************************************
* OfxTransactionContainer *
***************************************************************************/
OfxTransactionContainer::OfxTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
{
OfxGenericContainer * tmp_parentcontainer = parentcontainer;
memset(&data, 0, sizeof(data));
type = "TRANSACTION";
/* Find the parent statement container*/
while (tmp_parentcontainer != NULL && tmp_parentcontainer->type != "STATEMENT")
{
tmp_parentcontainer = tmp_parentcontainer->parentcontainer;
}
if (tmp_parentcontainer != NULL)
{
parent_statement = (OfxStatementContainer*)tmp_parentcontainer;
}
else
{
parent_statement = NULL;
message_out(ERROR, "Unable to find the enclosing statement container this transaction");
}
if (parent_statement != NULL && parent_statement->data.account_id_valid == true)
{
strncpy(data.account_id, parent_statement->data.account_id, OFX_ACCOUNT_ID_LENGTH);
data.account_id_valid = true;
}
}
OfxTransactionContainer::~OfxTransactionContainer()
{
}
int OfxTransactionContainer::gen_event()
{
if (data.unique_id_valid == true && MainContainer != NULL)
{
data.security_data_ptr = MainContainer->find_security(data.unique_id);
if (data.security_data_ptr != NULL)
{
data.security_data_valid = true;
}
}
libofx_context->transactionCallback(data);
return true;
}
int OfxTransactionContainer::add_to_main_tree()
{
if (MainContainer != NULL)
{
return MainContainer->add_container(this);
}
else
{
return false;
}
}
void OfxTransactionContainer::add_attribute(const string identifier, const string value)
{
if (identifier == "DTPOSTED")
{
data.date_posted = ofxdate_to_time_t(value);
data.date_posted_valid = true;
}
else if (identifier == "DTUSER")
{
data.date_initiated = ofxdate_to_time_t(value);
data.date_initiated_valid = true;
}
else if (identifier == "DTAVAIL")
{
data.date_funds_available = ofxdate_to_time_t(value);
data.date_funds_available_valid = true;
}
else if (identifier == "FITID")
{
strncpy(data.fi_id, value.c_str(), sizeof(data.fi_id));
data.fi_id_valid = true;
}
else if (identifier == "CORRECTFITID")
{
strncpy(data.fi_id_corrected, value.c_str(), sizeof(data.fi_id_corrected));
data.fi_id_corrected_valid = true;
}
else if (identifier == "CORRECTACTION")
{
data.fi_id_correction_action_valid = true;
if (value == "REPLACE")
{
data.fi_id_correction_action = REPLACE;
}
else if (value == "DELETE")
{
data.fi_id_correction_action = DELETE;
}
else
{
data.fi_id_correction_action_valid = false;
}
}
else if ((identifier == "SRVRTID") || (identifier == "SRVRTID2"))
{
strncpy(data.server_transaction_id, value.c_str(), sizeof(data.server_transaction_id));
data.server_transaction_id_valid = true;
}
else if (identifier == "MEMO" || identifier == "MEMO2")
{
strncpy(data.memo, value.c_str(), sizeof(data.memo));
data.memo_valid = true;
}
else if (identifier == "CURRENCY")
{
data.amounts_are_foreign_currency = false;
data.amounts_are_foreign_currency_valid = true;
}
else if (identifier == "ORIGCURRENCY")
{
data.amounts_are_foreign_currency = true;
data.amounts_are_foreign_currency_valid = true;
}
else
{
/* Redirect unknown identifiers to the base class */
OfxGenericContainer::add_attribute(identifier, value);
}
}// end OfxTransactionContainer::add_attribute()
void OfxTransactionContainer::add_account(OfxAccountData * account_data)
{
if (account_data->account_id_valid == true)
{
data.account_ptr = account_data;
strncpy(data.account_id, account_data->account_id, OFX_ACCOUNT_ID_LENGTH);
data.account_id_valid = true;
}
}
/***************************************************************************
* OfxBankTransactionContainer *
***************************************************************************/
OfxBankTransactionContainer::OfxBankTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
{
;
}
void OfxBankTransactionContainer::add_attribute(const string identifier, const string value)
{
if ( identifier == "TRNTYPE")
{
data.transactiontype_valid = true;
if (value == "CREDIT")
{
data.transactiontype = OFX_CREDIT;
}
else if (value == "DEBIT")
{
data.transactiontype = OFX_DEBIT;
}
else if (value == "INT")
{
data.transactiontype = OFX_INT;
}
else if (value == "DIV")
{
data.transactiontype = OFX_DIV;
}
else if (value == "FEE")
{
data.transactiontype = OFX_FEE;
}
else if (value == "SRVCHG")
{
data.transactiontype = OFX_SRVCHG;
}
else if (value == "DEP")
{
data.transactiontype = OFX_DEP;
}
else if (value == "ATM")
{
data.transactiontype = OFX_ATM;
}
else if (value == "POS")
{
data.transactiontype = OFX_POS;
}
else if (value == "XFER")
{
data.transactiontype = OFX_XFER;
}
else if (value == "CHECK")
{
data.transactiontype = OFX_CHECK;
}
else if (value == "PAYMENT")
{
data.transactiontype = OFX_PAYMENT;
}
else if (value == "CASH")
{
data.transactiontype = OFX_CASH;
}
else if (value == "DIRECTDEP")
{
data.transactiontype = OFX_DIRECTDEP;
}
else if (value == "DIRECTDEBIT")
{
data.transactiontype = OFX_DIRECTDEBIT;
}
else if (value == "REPEATPMT")
{
data.transactiontype = OFX_REPEATPMT;
}
else if (value == "OTHER")
{
data.transactiontype = OFX_OTHER;
}
else
{
data.transactiontype_valid = false;
}
}//end TRANSTYPE
else if (identifier == "TRNAMT")
{
data.amount = ofxamount_to_double(value);
data.amount_valid = true;
data.units = -data.amount;
data.units_valid = true;
data.unitprice = 1.00;
data.unitprice_valid = true;
}
else if (identifier == "CHECKNUM")
{
strncpy(data.check_number, value.c_str(), sizeof(data.check_number));
data.check_number_valid = true;
}
else if (identifier == "REFNUM")
{
strncpy(data.reference_number, value.c_str(), sizeof(data.reference_number));
data.reference_number_valid = true;
}
else if (identifier == "SIC")
{
data.standard_industrial_code = atoi(value.c_str());
data.standard_industrial_code_valid = true;
}
else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
{
strncpy(data.payee_id, value.c_str(), sizeof(data.payee_id));
data.payee_id_valid = true;
}
else if (identifier == "NAME")
{
strncpy(data.name, value.c_str(), sizeof(data.name));
data.name_valid = true;
}
else
{
/* Redirect unknown identifiers to base class */
OfxTransactionContainer::add_attribute(identifier, value);
}
}//end OfxBankTransactionContainer::add_attribute
/***************************************************************************
* OfxInvestmentTransactionContainer *
***************************************************************************/
OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
{
type = "INVESTMENT";
data.transactiontype = OFX_OTHER;
data.transactiontype_valid = true;
data.invtransactiontype_valid = true;
if (para_tag_identifier == "BUYDEBT")
{
data.invtransactiontype = OFX_BUYDEBT;
}
else if (para_tag_identifier == "BUYMF")
{
data.invtransactiontype = OFX_BUYMF;
}
else if (para_tag_identifier == "BUYOPT")
{
data.invtransactiontype = OFX_BUYOPT;
}
else if (para_tag_identifier == "BUYOTHER")
{
data.invtransactiontype = OFX_BUYOTHER;
}
else if (para_tag_identifier == "BUYSTOCK")
{
data.invtransactiontype = OFX_BUYSTOCK;
}
else if (para_tag_identifier == "CLOSUREOPT")
{
data.invtransactiontype = OFX_CLOSUREOPT;
}
else if (para_tag_identifier == "INCOME")
{
data.invtransactiontype = OFX_INCOME;
}
else if (para_tag_identifier == "INVEXPENSE")
{
data.invtransactiontype = OFX_INVEXPENSE;
}
else if (para_tag_identifier == "JRNLFUND")
{
data.invtransactiontype = OFX_JRNLFUND;
}
else if (para_tag_identifier == "JRNLSEC")
{
data.invtransactiontype = OFX_JRNLSEC;
}
else if (para_tag_identifier == "MARGININTEREST")
{
data.invtransactiontype = OFX_MARGININTEREST;
}
else if (para_tag_identifier == "REINVEST")
{
data.invtransactiontype = OFX_REINVEST;
}
else if (para_tag_identifier == "RETOFCAP")
{
data.invtransactiontype = OFX_RETOFCAP;
}
else if (para_tag_identifier == "SELLDEBT")
{
data.invtransactiontype = OFX_SELLDEBT;
}
else if (para_tag_identifier == "SELLMF")
{
data.invtransactiontype = OFX_SELLMF;
}
else if (para_tag_identifier == "SELLOPT")
{
data.invtransactiontype = OFX_SELLOPT;
}
else if (para_tag_identifier == "SELLOTHER")
{
data.invtransactiontype = OFX_SELLOTHER;
}
else if (para_tag_identifier == "SELLSTOCK")
{
data.invtransactiontype = OFX_SELLSTOCK;
}
else if (para_tag_identifier == "SPLIT")
{
data.invtransactiontype = OFX_SPLIT;
}
else if (para_tag_identifier == "TRANSFER")
{
data.invtransactiontype = OFX_TRANSFER;
}
else if (para_tag_identifier == "INVBANKTRAN")
{
data.invtransactiontype = OFX_INVBANKTRAN;
}
else
{
message_out(ERROR, "This should not happen, " + para_tag_identifier + " is an unknown investment transaction type");
data.invtransactiontype_valid = false;
}
}
void OfxInvestmentTransactionContainer::add_attribute(const string identifier, const string value)
{
if (identifier == "UNIQUEID")
{
strncpy(data.unique_id, value.c_str(), sizeof(data.unique_id));
data.unique_id_valid = true;
}
else if (identifier == "UNIQUEIDTYPE")
{
strncpy(data.unique_id_type, value.c_str(), sizeof(data.unique_id_type));
data.unique_id_type_valid = true;
}
else if (identifier == "UNITS")
{
data.units = ofxamount_to_double(value);
data.units_valid = true;
}
else if (identifier == "UNITPRICE")
{
data.unitprice = ofxamount_to_double(value);
data.unitprice_valid = true;
}
else if (identifier == "MKTVAL")
{
data.market_value = ofxamount_to_double(value);
data.market_value_valid = true;
}
else if (identifier == "TOTAL")
{
data.amount = ofxamount_to_double(value);
data.amount_valid = true;
}
else if (identifier == "CURRATE")
{
data.currency_ratio = ofxamount_to_double(value);
data.currency_ratio_valid = true;
}
else if (identifier == "CURSYM")
{
strncpy(data.currency, value.c_str(), sizeof(data.currency));
data.currency_valid = true;
}
else if (identifier == "DTSETTLE")
{
data.date_posted = ofxdate_to_time_t(value);
data.date_posted_valid = true;
}
else if (identifier == "DTTRADE")
{
data.date_initiated = ofxdate_to_time_t(value);
data.date_initiated_valid = true;
}
else if (identifier == "COMMISSION")
{
data.commission = ofxamount_to_double(value);
data.commission_valid = true;
}
else if (identifier == "FEES")
{
data.fees = ofxamount_to_double(value);
data.fees_valid = true;
}
else if (identifier == "OLDUNITS")
{
data.oldunits = ofxamount_to_double(value);
data.oldunits_valid = true;
}
else if (identifier == "NEWUNITS")
{
data.newunits = ofxamount_to_double(value);
data.newunits_valid = true;
}
else if (identifier == "ACCRDINT")
{
data.accrued_interest = ofxamount_to_double(value);
data.accrued_interest_valid = true;
}
else if (identifier == "AVGCOSTBASIS")
{
data.avg_cost_basis = ofxamount_to_double(value);
data.avg_cost_basis_valid = true;
}
else if (identifier == "BUYTYPE" || identifier == "OPTBUYTYPE")
{
if (value == "BUY")
{
data.buy_type = data.OFX_BUY_TYPE_BUY;
data.buy_type_valid = true;
}
else if (value == "BUYTOCOVER")
{
data.buy_type = data.OFX_BUY_TYPE_BUYTOCOVER;
data.buy_type_valid = true;
}
else if (value == "BUYTOOPEN")
{
data.buy_type = data.OFX_BUY_TYPE_BUYTOOPEN;
data.buy_type_valid = true;
}
else if (value == "BUYTOCLOSE")
{
data.buy_type = data.OFX_BUY_TYPE_BUYTOCLOSE;
data.buy_type_valid = true;
}
}
else if (identifier == "DENOMINATOR")
{
data.denominator = ofxamount_to_double(value);
data.denominator_valid = true;
}
else if (identifier == "DTPAYROLL")
{
data.date_payroll = ofxdate_to_time_t(value);
data.date_payroll_valid = true;
}
else if (identifier == "DTPURCHASE")
{
data.date_purchase = ofxdate_to_time_t(value);
data.date_purchase_valid = true;
}
else if (identifier == "GAIN")
{
data.gain = ofxamount_to_double(value);
data.gain_valid = true;
}
else if (identifier == "FRACCASH")
{
data.cash_for_fractional = ofxamount_to_double(value);
data.cash_for_fractional_valid = true;
}
else if (identifier == "INCOMETYPE")
{
if (value == "CGLONG")
{
data.income_type = data.OFX_CGLONG;
data.income_type_valid = true;
}
else if (value == "CGSHORT")
{
data.income_type = data.OFX_CGSHORT;
data.income_type_valid = true;
}
else if (value == "DIV")
{
data.income_type = data.OFX_DIVIDEND;
data.income_type_valid = true;
}
else if (value == "INTEREST")
{
data.income_type = data.OFX_INTEREST;
data.income_type_valid = true;
}
else if (value == "MISC")
{
data.income_type = data.OFX_MISC;
data.income_type_valid = true;
}
}
else if (identifier == "INV401KSOURCE")
{
if (value == "PRETAX")
{
data.inv_401k_source = data.OFX_401K_SOURCE_PRETAX;
data.inv_401k_source_valid = true;
}
else if (value == "AFTERTAX")
{
data.inv_401k_source = data.OFX_401K_SOURCE_AFTERTAX;
data.inv_401k_source_valid = true;
}
else if (value == "MATCH")
{
data.inv_401k_source = data.OFX_401K_SOURCE_MATCH;
data.inv_401k_source_valid = true;
}
else if (value == "PROFITSHARING")
{
data.inv_401k_source = data.OFX_401K_SOURCE_PROFITSHARING;
data.inv_401k_source_valid = true;
}
else if (value == "ROLLOVER")
{
data.inv_401k_source = data.OFX_401K_SOURCE_ROLLOVER;
data.inv_401k_source_valid = true;
}
else if (value == "OTHERVEST")
{
data.inv_401k_source = data.OFX_401K_SOURCE_OTHERVEST;
data.inv_401k_source_valid = true;
}
else if (value == "OTHERNONVEST")
{
data.inv_401k_source = data.OFX_401K_SOURCE_OTHERNONVEST;
data.inv_401k_source_valid = true;
}
}
else if (identifier == "LOAD")
{
data.load = ofxamount_to_double(value);
data.load_valid = true;
}
else if (identifier == "LOANID")
{
strncpy(data.loan_id, value.c_str(), sizeof(data.loan_id));
data.loan_id_valid = true;
}
else if (identifier == "LOANINTEREST")
{
data.loan_interest = ofxamount_to_double(value);
data.loan_interest_valid = true;
}
else if (identifier == "LOANPRINCIPAL")
{
data.loan_principal = ofxamount_to_double(value);
data.loan_principal_valid = true;
}
else if (identifier == "MARKDOWN")
{
data.markdown = ofxamount_to_double(value);
data.markdown_valid = true;
}
else if (identifier == "MARKUP")
{
data.markup = ofxamount_to_double(value);
data.markup_valid = true;
}
else if (identifier == "NUMERATOR")
{
data.numerator = ofxamount_to_double(value);
data.numerator_valid = true;
}
else if (identifier == "OPTACTION")
{
if (value == "EXERCISE")
{
data.opt_action = data.OFX_OPTACTION_EXERCISE;
data.opt_action_valid = true;
}
else if (value == "ASSIGN")
{
data.opt_action = data.OFX_OPTACTION_ASSIGN;
data.opt_action_valid = true;
}
else if (value == "EXPIRE")
{
data.opt_action = data.OFX_OPTACTION_EXPIRE;
data.opt_action_valid = true;
}
}
else if (identifier == "PENALTY")
{
data.penalty = ofxamount_to_double(value);
data.penalty_valid = true;
}
else if (identifier == "POSTYPE")
{
if (value == "LONG")
{
data.pos_type = data.OFX_POSTYPE_LONG;
data.pos_type_valid = true;
}
else if (value == "SHORT")
{
data.pos_type = data.OFX_POSTYPE_SHORT;
data.pos_type_valid = true;
}
}
else if (identifier == "PRIORYEARCONTRIB")
{
if (value == "Y")
{
data.prior_year_contrib = true;
data.prior_year_contrib_valid = true;
}
else if (value == "N")
{
data.prior_year_contrib = false;
data.prior_year_contrib_valid = true;
}
}
else if (identifier == "RELFITID")
{
strncpy(data.related_fi_tid, value.c_str(), sizeof(data.related_fi_tid));
data.related_fi_tid_valid = true;
}
else if (identifier == "RELTYPE")
{
if (value == "SPREAD")
{
data.related_type = data.OFX_RELTYPE_SPREAD;
data.related_type_valid = true;
}
else if (value == "STRADDLE")
{
data.related_type = data.OFX_RELTYPE_STRADDLE;
data.related_type_valid = true;
}
else if (value == "NONE")
{
data.related_type = data.OFX_RELTYPE_NONE;
data.related_type_valid = true;
}
else if (value == "OTHER")
{
data.related_type = data.OFX_RELTYPE_OTHER;
data.related_type_valid = true;
}
}
else if (identifier == "SECURED")
{
if (value == "NAKED")
{
data.option_secured = data.OFX_SECURED_NAKED;
data.option_secured_valid = true;
}
else if (value == "COVERED")
{
data.option_secured = data.OFX_SECURED_COVERED;
data.option_secured_valid = true;
}
}
else if (identifier == "SELLREASON")
{
if (value == "CALL")
{
data.sell_reason = data.OFX_SELLREASON_CALL;
data.sell_reason_valid = true;
}
else if (value == "SELL")
{
data.sell_reason = data.OFX_SELLREASON_SELL;
data.sell_reason_valid = true;
}
else if (value == "MATURITY")
{
data.sell_reason = data.OFX_SELLREASON_MATURITY;
data.sell_reason_valid = true;
}
}
else if (identifier == "SELLTYPE" || identifier == "OPTSELLTYPE")
{
if (value == "SELL")
{
data.sell_type = data.OFX_SELL_TYPE_SELL;
data.sell_type_valid = true;
}
else if (value == "SELLSHORT")
{
data.sell_type = data.OFX_SELL_TYPE_SELLSHORT;
data.sell_type_valid = true;
}
else if (value == "SELLTOOPEN")
{
data.sell_type = data.OFX_SELL_TYPE_SELLTOOPEN;
data.sell_type_valid = true;
}
else if (value == "SELLTOCLOSE")
{
data.sell_type = data.OFX_SELL_TYPE_SELLTOCLOSE;
data.sell_type_valid = true;
}
}
else if (identifier == "SHPERCTRCT")
{
data.shares_per_cont = ofxamount_to_double(value);
data.shares_per_cont_valid = true;
}
else if (identifier == "STATEWITHHOLDING")
{
data.state_withholding = ofxamount_to_double(value);
data.state_withholding_valid = true;
}
else if (identifier == "SUBACCTFROM")
{
if (value == "CASH")
{
data.subacct_from = data.OFX_SUBACCT_CASH;
data.subacct_from_valid = true;
}
else if (value == "MARGIN")
{
data.subacct_from = data.OFX_SUBACCT_MARGIN;
data.subacct_from_valid = true;
}
else if (value == "SHORT")
{
data.subacct_from = data.OFX_SUBACCT_SHORT;
data.subacct_from_valid = true;
}
else if (value == "OTHER")
{
data.subacct_from = data.OFX_SUBACCT_OTHER;
data.subacct_from_valid = true;
}
}
else if (identifier == "SUBACCTFUND")
{
if (value == "CASH")
{
data.subacct_funding = data.OFX_SUBACCT_CASH;
data.subacct_funding_valid = true;
}
else if (value == "MARGIN")
{
data.subacct_funding = data.OFX_SUBACCT_MARGIN;
data.subacct_funding_valid = true;
}
else if (value == "SHORT")
{
data.subacct_funding = data.OFX_SUBACCT_SHORT;
data.subacct_funding_valid = true;
}
else if (value == "OTHER")
{
data.subacct_funding = data.OFX_SUBACCT_OTHER;
data.subacct_funding_valid = true;
}
}
else if (identifier == "SUBACCTSEC")
{
if (value == "CASH")
{
data.subacct_security = data.OFX_SUBACCT_CASH;
data.subacct_security_valid = true;
}
else if (value == "MARGIN")
{
data.subacct_security = data.OFX_SUBACCT_MARGIN;
data.subacct_security_valid = true;
}
else if (value == "SHORT")
{
data.subacct_security = data.OFX_SUBACCT_SHORT;
data.subacct_security_valid = true;
}
else if (value == "OTHER")
{
data.subacct_security = data.OFX_SUBACCT_OTHER;
data.subacct_security_valid = true;
}
}
else if (identifier == "SUBACCTTO")
{
if (value == "CASH")
{
data.subacct_to = data.OFX_SUBACCT_CASH;
data.subacct_to_valid = true;
}
else if (value == "MARGIN")
{
data.subacct_to = data.OFX_SUBACCT_MARGIN;
data.subacct_to_valid = true;
}
else if (value == "SHORT")
{
data.subacct_to = data.OFX_SUBACCT_SHORT;
data.subacct_to_valid = true;
}
else if (value == "OTHER")
{
data.subacct_to = data.OFX_SUBACCT_OTHER;
data.subacct_to_valid = true;
}
}
else if (identifier == "TAXES")
{
data.taxes = ofxamount_to_double(value);
data.taxes_valid = true;
}
else if (identifier == "TAXEXEMPT")
{
if (value == "Y")
{
data.tax_exempt = true;
data.tax_exempt_valid = true;
}
else if (value == "N")
{
data.tax_exempt = false;
data.tax_exempt_valid = true;
}
}
else if (identifier == "TFERACTION")
{
if (value == "IN")
{
data.transfer_action = data.OFX_TFERACTION_IN;
data.transfer_action_valid = true;
}
else if (value == "OUT")
{
data.transfer_action = data.OFX_TFERACTION_OUT;
data.transfer_action_valid = true;
}
}
else if (identifier == "UNITTYPE")
{
if (value == "SHARES")
{
data.unit_type = data.OFX_UNITTYPE_SHARES;
data.unit_type_valid = true;
}
else if (value == "CURRENCY")
{
data.unit_type = data.OFX_UNITTYPE_CURRENCY;
data.unit_type_valid = true;
}
}
else if (identifier == "WITHHOLDING")
{
data.withholding = ofxamount_to_double(value);
data.withholding_valid = true;
}
/* the following fields are <STMTTRN> elements for <INVBANKTRAN> */
else if ( identifier == "TRNTYPE")
{
data.transactiontype_valid = true;
if (value == "CREDIT")
{
data.transactiontype = OFX_CREDIT;
}
else if (value == "DEBIT")
{
data.transactiontype = OFX_DEBIT;
}
else if (value == "INT")
{
data.transactiontype = OFX_INT;
}
else if (value == "DIV")
{
data.transactiontype = OFX_DIV;
}
else if (value == "FEE")
{
data.transactiontype = OFX_FEE;
}
else if (value == "SRVCHG")
{
data.transactiontype = OFX_SRVCHG;
}
else if (value == "DEP")
{
data.transactiontype = OFX_DEP;
}
else if (value == "ATM")
{
data.transactiontype = OFX_ATM;
}
else if (value == "POS")
{
data.transactiontype = OFX_POS;
}
else if (value == "XFER")
{
data.transactiontype = OFX_XFER;
}
else if (value == "CHECK")
{
data.transactiontype = OFX_CHECK;
}
else if (value == "PAYMENT")
{
data.transactiontype = OFX_PAYMENT;
}
else if (value == "CASH")
{
data.transactiontype = OFX_CASH;
}
else if (value == "DIRECTDEP")
{
data.transactiontype = OFX_DIRECTDEP;
}
else if (value == "DIRECTDEBIT")
{
data.transactiontype = OFX_DIRECTDEBIT;
}
else if (value == "REPEATPMT")
{
data.transactiontype = OFX_REPEATPMT;
}
else if (value == "OTHER")
{
data.transactiontype = OFX_OTHER;
}
else
{
data.transactiontype_valid = false;
}
}//end TRANSTYPE
else if (identifier == "TRNAMT")
{
data.amount = ofxamount_to_double(value);
data.amount_valid = true;
data.units = -data.amount;
data.units_valid = true;
data.unitprice = 1.00;
data.unitprice_valid = true;
}
else if (identifier == "CHECKNUM")
{
strncpy(data.check_number, value.c_str(), sizeof(data.check_number));
data.check_number_valid = true;
}
else if (identifier == "REFNUM")
{
strncpy(data.reference_number, value.c_str(), sizeof(data.reference_number));
data.reference_number_valid = true;
}
else if (identifier == "SIC")
{
data.standard_industrial_code = atoi(value.c_str());
data.standard_industrial_code_valid = true;
}
else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
{
strncpy(data.payee_id, value.c_str(), sizeof(data.payee_id));
data.payee_id_valid = true;
}
else if (identifier == "NAME")
{
strncpy(data.name, value.c_str(), sizeof(data.name));
data.name_valid = true;
}
else
{
/* Redirect unknown identifiers to the base class */
OfxTransactionContainer::add_attribute(identifier, value);
}
}//end OfxInvestmentTransactionContainer::add_attribute
OFX_INT
Definition: inc/libofx.h:626
OFX_OTHER
Definition: inc/libofx.h:640
OfxTransactionData::date_posted
time_t date_posted
Definition: inc/libofx.h:747
OfxTransactionData::penalty
double penalty
Definition: inc/libofx.h:928
OFX_RETOFCAP
Definition: inc/libofx.h:657
OfxTransactionData::subacct_to_valid
int subacct_to_valid
Definition: inc/libofx.h:1004
OfxAccountData
An abstraction of an account.
Definition: inc/libofx.h:276
OfxTransactionData::OFX_MISC
Definition: inc/libofx.h:881
OFX_JRNLSEC
Definition: inc/libofx.h:654
OfxTransactionData::denominator
double denominator
Definition: inc/libofx.h:859
OFX_POS
Definition: inc/libofx.h:632
ofxamount_to_double
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float.
Definition: build/libofx-0.10.0/lib/ofx_utilities.cpp:230
OFX_REPEATPMT
Definition: inc/libofx.h:639
OfxTransactionData::gain
double gain
Definition: inc/libofx.h:868
OfxTransactionData::shares_per_cont
double shares_per_cont
Definition: inc/libofx.h:986
OfxTransactionData::load
double load
Definition: inc/libofx.h:898
OfxTransactionData::OFX_SELLREASON_SELL
Definition: inc/libofx.h:969
DELETE
Definition: inc/libofx.h:670
OfxTransactionContainer::add_to_main_tree
virtual int add_to_main_tree()
Add this container to the main tree.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:83
OFX_ATM
Definition: inc/libofx.h:631
OfxTransactionData::reference_number
char reference_number[OFX_REFERENCE_NUMBER_LENGTH]
Definition: inc/libofx.h:791
OfxGenericContainer
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:33
OFX_MARGININTEREST
Definition: inc/libofx.h:655
OfxTransactionData::tax_exempt
int tax_exempt
Definition: inc/libofx.h:1011
OfxTransactionData::OFX_SELLREASON_CALL
Definition: inc/libofx.h:968
OfxTransactionData::taxes
double taxes
Definition: inc/libofx.h:1007
OfxTransactionData::units
double units
Definition: inc/libofx.h:713
OfxTransactionData::unique_id
char unique_id[OFX_UNIQUE_ID_LENGTH]
Definition: inc/libofx.h:738
OfxAccountData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:290
OfxTransactionContainer
Represents a generic transaction.
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:245
ofx_utilities.hh
Various simple functions for type conversion & al.
OfxTransactionData::subacct_from_valid
int subacct_from_valid
Definition: inc/libofx.h:1001
OfxTransactionData::check_number
char check_number[OFX_CHECK_NUMBER_LENGTH]
Definition: inc/libofx.h:786
OfxTransactionData::numerator
double numerator
Definition: inc/libofx.h:916
OfxTransactionData::OFX_SELLREASON_MATURITY
Definition: inc/libofx.h:970
OFX_BUYOTHER
Definition: inc/libofx.h:648
OfxGenericContainer::add_attribute
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
Definition: build/libofx-0.10.0/lib/ofx_container_generic.cpp:57
OfxTransactionData::transactiontype_valid
int transactiontype_valid
Definition: inc/libofx.h:698
OfxTransactionData::name
char name[OFX_TRANSACTION_NAME_LENGTH]
Definition: inc/libofx.h:801
OfxTransactionData::withholding
double withholding
Definition: inc/libofx.h:1031
OFX_SELLDEBT
Definition: inc/libofx.h:658
OFX_CHECK
Definition: inc/libofx.h:634
OFX_FEE
Definition: inc/libofx.h:628
OFX_INVBANKTRAN
Definition: inc/libofx.h:665
OfxTransactionData::commission
double commission
Definition: inc/libofx.h:808
OFX_CASH
Definition: inc/libofx.h:636
LibofxContext
Definition: build/libofx-0.10.0/lib/context.hh:25
OfxTransactionData::memo
char memo[OFX_MEMO2_LENGTH]
Definition: inc/libofx.h:805
OfxTransactionData::OFX_CGSHORT
Definition: inc/libofx.h:878
OfxTransactionData::fi_id_correction_action
FiIdCorrectionAction fi_id_correction_action
Definition: inc/libofx.h:775
OFX_BUYDEBT
Definition: inc/libofx.h:645
OFX_SPLIT
Definition: inc/libofx.h:663
OFX_CLOSUREOPT
Definition: inc/libofx.h:650
OFX_TRANSFER
Definition: inc/libofx.h:664
ofxdate_to_time_t
time_t ofxdate_to_time_t(const string ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
Definition: build/libofx-0.10.0/lib/ofx_utilities.cpp:131
OfxTransactionData::loan_interest
double loan_interest
Definition: inc/libofx.h:904
OfxTransactionData::currency_ratio
double currency_ratio
Definition: inc/libofx.h:829
REPLACE
Definition: inc/libofx.h:672
OfxTransactionData::markup
double markup
Definition: inc/libofx.h:913
OfxTransactionData::market_value
double market_value
Definition: inc/libofx.h:821
OfxTransactionContainer::add_attribute
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:97
OfxTransactionData::amounts_are_foreign_currency
int amounts_are_foreign_currency
Definition: inc/libofx.h:835
OfxTransactionData::standard_industrial_code
long int standard_industrial_code
Definition: inc/libofx.h:794
OfxTransactionData::loan_principal
double loan_principal
Definition: inc/libofx.h:907
OFX_BUYMF
Definition: inc/libofx.h:646
OfxTransactionData::date_payroll
time_t date_payroll
Definition: inc/libofx.h:862
message_out
int message_out(OfxMsgType error_type, const string message)
Message output function.
Definition: build/libofx-0.10.0/lib/messages.cpp:61
OFX_SELLSTOCK
Definition: inc/libofx.h:662
OfxTransactionData::cash_for_fractional
double cash_for_fractional
Definition: inc/libofx.h:871
OfxTransactionData::subacct_funding_valid
int subacct_funding_valid
Definition: inc/libofx.h:1002
OfxTransactionData::date_initiated
time_t date_initiated
Definition: inc/libofx.h:754
OfxTransactionData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:690
OFX_CREDIT
Definition: inc/libofx.h:624
OfxTransactionData::fi_id
char fi_id[OFX_FITID_LENGTH]
Definition: inc/libofx.h:726
OFX_DEP
Definition: inc/libofx.h:630
OFX_JRNLFUND
Definition: inc/libofx.h:653
OFX_SELLMF
Definition: inc/libofx.h:659
OfxBankTransactionContainer::add_attribute
void add_attribute(const string identifier, const string value)
Add data to a container object.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:187
OfxTransactionData::unitprice
double unitprice
Definition: inc/libofx.h:716
OfxTransactionData::account_ptr
struct OfxAccountData * account_ptr
Definition: inc/libofx.h:693
OfxTransactionData::server_transaction_id
char server_transaction_id[OFX_SVRTID2_LENGTH]
Definition: inc/libofx.h:780
ofx_containers.hh
LibOFX internal object code.
OFX_SRVCHG
Definition: inc/libofx.h:629
OFX_BUYSTOCK
Definition: inc/libofx.h:649
OfxInvestmentTransactionContainer::add_attribute
void add_attribute(const string identifier, const string value)
Add data to a container object.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:410
OFX_DIRECTDEBIT
Definition: inc/libofx.h:638
OFX_SELLOTHER
Definition: inc/libofx.h:661
OFX_PAYMENT
Definition: inc/libofx.h:635
OfxTransactionData::related_fi_tid
char related_fi_tid[OFX_FITID_LENGTH]
Definition: inc/libofx.h:944
OFX_BUYOPT
Definition: inc/libofx.h:647
OfxTransactionData::amount
double amount
Definition: inc/libofx.h:720
OfxTransactionData::state_withholding
double state_withholding
Definition: inc/libofx.h:990
OfxStatementContainer
Represents a statement for either a bank account or a credit card account.
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:157
OFX_INCOME
Definition: inc/libofx.h:651
messages.hh
Message IO functionality.
OfxTransactionData::oldunits
double oldunits
Definition: inc/libofx.h:814
OfxTransactionData::avg_cost_basis
double avg_cost_basis
Definition: inc/libofx.h:845
OFX_SELLOPT
Definition: inc/libofx.h:660
OfxTransactionData::accrued_interest
double accrued_interest
Definition: inc/libofx.h:842
OfxGenericContainer::type
string type
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:36
OfxTransactionData::markdown
double markdown
Definition: inc/libofx.h:910
OFX_REINVEST
Definition: inc/libofx.h:656
OfxTransactionData::subacct_security_valid
int subacct_security_valid
Definition: inc/libofx.h:1003
OfxTransactionData::prior_year_contrib
int prior_year_contrib
Definition: inc/libofx.h:940
OfxTransactionData::security_data_valid
int security_data_valid
Definition: inc/libofx.h:745
OfxTransactionData::payee_id
char payee_id[OFX_SVRTID2_LENGTH]
Definition: inc/libofx.h:798
OfxTransactionData::newunits
double newunits
Definition: inc/libofx.h:817
OfxTransactionData::fees
double fees
Definition: inc/libofx.h:811
OFX_DEBIT
Definition: inc/libofx.h:625
OfxTransactionData::date_funds_available
time_t date_funds_available
Definition: inc/libofx.h:762
OFX_XFER
Definition: inc/libofx.h:633
OfxTransactionData::date_purchase
time_t date_purchase
Definition: inc/libofx.h:865
ERROR
Definition: build/libofx-0.10.0/lib/messages.hh:34
OfxTransactionData::currency
char currency[OFX_CURRENCY_LENGTH]
Definition: inc/libofx.h:825
OFX_DIV
Definition: inc/libofx.h:627
OfxTransactionData::OFX_INTEREST
Definition: inc/libofx.h:880
OfxTransactionData::unique_id_type
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
Definition: inc/libofx.h:740
OFX_INVEXPENSE
Definition: inc/libofx.h:652
OfxMainContainer
The root container. Created by the <OFX> OFX element or by the export functions.
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:291
OfxTransactionData::OFX_CGLONG
Definition: inc/libofx.h:877
OFX_DIRECTDEP
Definition: inc/libofx.h:637
OfxTransactionData::fi_id_corrected
char fi_id_corrected[OFX_FITID_LENGTH]
Definition: inc/libofx.h:770
OfxTransactionContainer::gen_event
virtual int gen_event()
Generate libofx.h events.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:69
OfxTransactionData::OFX_DIVIDEND
Definition: inc/libofx.h:879
OfxTransactionData::loan_id
char loan_id[OFX_LOANID_LENGTH]
Definition: inc/libofx.h:901