00001
00002
00003
00004
00005
00006
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023
00024 #include <string>
00025 #include "messages.hh"
00026 #include "libofx.h"
00027 #include "ofx_containers.hh"
00028 #include "ofx_utilities.hh"
00029
00030 extern OfxMainContainer * MainContainer;
00031
00032
00033
00034
00035
00036 OfxStatementContainer::OfxStatementContainer(OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00037 OfxGenericContainer(para_parentcontainer, para_tag_identifier)
00038 {
00039 memset(&data,0,sizeof(data));
00040 type="STATEMENT";
00041 }
00042 OfxStatementContainer::~OfxStatementContainer()
00043 {
00044
00045
00046
00047
00048
00049 }
00050 void OfxStatementContainer::add_attribute(const string identifier, const string value)
00051 {
00052 if(identifier=="CURDEF"){
00053 strncpy(data.currency,value.c_str(),OFX_CURRENCY_LENGTH);
00054 data.currency_valid=true;
00055 }
00056 else if(identifier=="MKTGINFO"){
00057 strncpy(data.marketing_info,value.c_str(),OFX_MARKETING_INFO_LENGTH);
00058 data.marketing_info_valid=true;
00059 }
00060 else if(identifier=="DTSTART"){
00061 data.date_start = ofxdate_to_time_t(value);
00062 data.date_start_valid = true;
00063 }
00064 else if(identifier=="DTEND"){
00065 data.date_end = ofxdate_to_time_t(value);
00066 data.date_end_valid = true;
00067 }
00068 else{
00069 OfxGenericContainer::add_attribute(identifier, value);
00070 }
00071 }
00072
00073 void OfxStatementContainer::add_balance(OfxBalanceContainer* ptr_balance_container)
00074 {
00075 if(ptr_balance_container->tag_identifier=="LEDGERBAL"){
00076 data.ledger_balance=ptr_balance_container->amount;
00077 data.ledger_balance_valid=ptr_balance_container->amount_valid;
00078 }
00079 else if(ptr_balance_container->tag_identifier=="AVAILBAL"){
00080 data.available_balance=ptr_balance_container->amount;
00081 data.available_balance_valid=ptr_balance_container->amount_valid;
00082 }
00083 else{
00084 message_out(ERROR,"OfxStatementContainer::add_balance(): the balance has unknown tag_identifier: "+ptr_balance_container->tag_identifier);
00085 }
00086 }
00087
00088
00089 int OfxStatementContainer::add_to_main_tree()
00090 {
00091 if(MainContainer != NULL)
00092 {
00093 return MainContainer->add_container(this);
00094 }
00095 else
00096 {
00097 return false;
00098 }
00099 }
00100
00101 int OfxStatementContainer::gen_event()
00102 {
00103 ofx_proc_statement_cb(data);
00104 return true;
00105 }
00106
00107
00108 void OfxStatementContainer::add_account(OfxAccountData * account_data)
00109 {
00110 if(account_data->account_id_valid==true)
00111 {
00112 data.account_ptr = account_data;
00113 strncpy(data.account_id,account_data->account_id,OFX_ACCOUNT_ID_LENGTH);
00114 data.account_id_valid = true;
00115 }
00116 }
00117
00118
00119
00120