1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/***************************************************************************
ofx_container_statement.cpp
-------------------
copyright : (C) 2002 by Benoit Gr�goire
email : benoitg@coeus.ca
***************************************************************************/
/**@file
* \brief Implementation of OfxStatementContainer for bank statements,
credit cart statements, etc.
*/
/***************************************************************************
* *
* 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 <string>
#include "messages.hh"
#include "libofx.h"
#include "ofx_containers.hh"
#include "ofx_utilities.hh"
extern OfxMainContainer * MainContainer;
/***************************************************************************
* OfxStatementContainer *
***************************************************************************/
OfxStatementContainer::OfxStatementContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
{
memset(&data, 0, sizeof(data));
type = "STATEMENT";
}
OfxStatementContainer::~OfxStatementContainer()
{
/* while(transaction_queue.empty()!=true)
{
ofx_proc_transaction_cb(transaction_queue.front());
transaction_queue.pop();
}*/
}
void OfxStatementContainer::add_attribute(const string identifier, const string value)
{
if (identifier == "CURDEF")
{
strncpy(data.currency, value.c_str(), OFX_CURRENCY_LENGTH);
data.currency_valid = true;
}
else if (identifier == "MKTGINFO")
{
strncpy(data.marketing_info, value.c_str(), OFX_MARKETING_INFO_LENGTH);
data.marketing_info_valid = true;
}
else if (identifier == "DTSTART")
{
data.date_start = ofxdate_to_time_t(value);
data.date_start_valid = true;
}
else if (identifier == "DTEND")
{
data.date_end = ofxdate_to_time_t(value);
data.date_end_valid = true;
}
else
{
OfxGenericContainer::add_attribute(identifier, value);
}
}//end OfxStatementContainer::add_attribute()
void OfxStatementContainer::add_balance(OfxBalanceContainer* ptr_balance_container)
{
if (ptr_balance_container->tag_identifier == "LEDGERBAL")
{
data.ledger_balance = ptr_balance_container->amount;
data.ledger_balance_valid = ptr_balance_container->amount_valid;
data.ledger_balance_date = ptr_balance_container->date;
data.ledger_balance_date_valid = ptr_balance_container->date_valid;
}
else if (ptr_balance_container->tag_identifier == "AVAILBAL")
{
data.available_balance = ptr_balance_container->amount;
data.available_balance_valid = ptr_balance_container->amount_valid;
data.available_balance_date = ptr_balance_container->date;
data.available_balance_date_valid = ptr_balance_container->date_valid;
}
else
{
message_out(ERROR, "OfxStatementContainer::add_balance(): the balance has unknown tag_identifier: " + ptr_balance_container->tag_identifier);
}
}
int OfxStatementContainer::add_to_main_tree()
{
if (MainContainer != NULL)
{
return MainContainer->add_container(this);
}
else
{
return false;
}
}
int OfxStatementContainer::gen_event()
{
libofx_context->statementCallback(data);
return true;
}
void OfxStatementContainer::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;
}
}
/*void OfxStatementContainer::add_transaction(const OfxTransactionData transaction_data)
{
transaction_queue.push(transaction_data);
}*/
|