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)
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")
123 data.fi_id_corrected_valid =
true;
125 else if (identifier ==
"CORRECTACTION")
127 data.fi_id_correction_action_valid =
true;
128 if (value ==
"REPLACE")
132 else if (value ==
"DELETE")
138 data.fi_id_correction_action_valid =
false;
141 else if ((identifier ==
"SRVRTID") || (identifier ==
"SRVRTID2"))
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;
151 else if (identifier ==
"CURRENCY")
154 data.amounts_are_foreign_currency_valid =
true;
156 else if (identifier ==
"ORIGCURRENCY")
159 data.amounts_are_foreign_currency_valid =
true;
168 void OfxTransactionContainer::add_account(
OfxAccountData * account_data)
170 if (account_data->account_id_valid ==
true)
174 data.account_id_valid =
true;
182 OfxBankTransactionContainer::OfxBankTransactionContainer(
LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer,
string para_tag_identifier):
189 if ( identifier ==
"TRNTYPE")
192 if (value ==
"CREDIT")
196 else if (value ==
"DEBIT")
200 else if (value ==
"INT")
202 data.transactiontype =
OFX_INT;
204 else if (value ==
"DIV")
206 data.transactiontype =
OFX_DIV;
208 else if (value ==
"FEE")
210 data.transactiontype =
OFX_FEE;
212 else if (value ==
"SRVCHG")
216 else if (value ==
"DEP")
218 data.transactiontype =
OFX_DEP;
220 else if (value ==
"ATM")
222 data.transactiontype =
OFX_ATM;
224 else if (value ==
"POS")
226 data.transactiontype =
OFX_POS;
228 else if (value ==
"XFER")
232 else if (value ==
"CHECK")
236 else if (value ==
"PAYMENT")
240 else if (value ==
"CASH")
244 else if (value ==
"DIRECTDEP")
248 else if (value ==
"DIRECTDEBIT")
252 else if (value ==
"REPEATPMT")
256 else if (value ==
"OTHER")
265 else if (identifier ==
"TRNAMT")
268 data.amount_valid =
true;
270 data.units_valid =
true;
272 data.unitprice_valid =
true;
274 else if (identifier ==
"CHECKNUM")
277 data.check_number_valid =
true;
279 else if (identifier ==
"REFNUM")
282 data.reference_number_valid =
true;
284 else if (identifier ==
"SIC")
287 data.standard_industrial_code_valid =
true;
289 else if ((identifier ==
"PAYEEID") || (identifier ==
"PAYEEID2"))
292 data.payee_id_valid =
true;
294 else if (identifier ==
"NAME")
296 strncpy(data.
name, value.c_str(),
sizeof(data.
name));
297 data.name_valid =
true;
311 OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(
LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer,
string para_tag_identifier):
318 data.invtransactiontype_valid =
true;
319 if (para_tag_identifier ==
"BUYDEBT")
323 else if (para_tag_identifier ==
"BUYMF")
327 else if (para_tag_identifier ==
"BUYOPT")
331 else if (para_tag_identifier ==
"BUYOTHER")
335 else if (para_tag_identifier ==
"BUYSTOCK")
339 else if (para_tag_identifier ==
"CLOSUREOPT")
343 else if (para_tag_identifier ==
"INCOME")
347 else if (para_tag_identifier ==
"INVEXPENSE")
351 else if (para_tag_identifier ==
"JRNLFUND")
355 else if (para_tag_identifier ==
"JRNLSEC")
359 else if (para_tag_identifier ==
"MARGININTEREST")
363 else if (para_tag_identifier ==
"REINVEST")
367 else if (para_tag_identifier ==
"RETOFCAP")
371 else if (para_tag_identifier ==
"SELLDEBT")
375 else if (para_tag_identifier ==
"SELLMF")
379 else if (para_tag_identifier ==
"SELLOPT")
383 else if (para_tag_identifier ==
"SELLOTHER")
387 else if (para_tag_identifier ==
"SELLSTOCK")
391 else if (para_tag_identifier ==
"SPLIT")
395 else if (para_tag_identifier ==
"TRANSFER")
399 else if (para_tag_identifier ==
"INVBANKTRAN")
405 message_out(
ERROR,
"This should not happen, " + para_tag_identifier +
" is an unknown investment transaction type");
406 data.invtransactiontype_valid =
false;
412 if (identifier ==
"UNIQUEID")
415 data.unique_id_valid =
true;
417 else if (identifier ==
"UNIQUEIDTYPE")
420 data.unique_id_type_valid =
true;
422 else if (identifier ==
"UNITS")
425 data.units_valid =
true;
427 else if (identifier ==
"UNITPRICE")
430 data.unitprice_valid =
true;
432 else if (identifier ==
"MKTVAL")
435 data.market_value_valid =
true;
437 else if (identifier ==
"TOTAL")
440 data.amount_valid =
true;
442 else if (identifier ==
"CURRATE")
445 data.currency_ratio_valid =
true;
447 else if (identifier ==
"CURSYM")
450 data.currency_valid =
true;
452 else if (identifier ==
"DTSETTLE")
455 data.date_posted_valid =
true;
457 else if (identifier ==
"DTTRADE")
460 data.date_initiated_valid =
true;
462 else if (identifier ==
"COMMISSION")
465 data.commission_valid =
true;
467 else if (identifier ==
"FEES")
470 data.fees_valid =
true;
472 else if (identifier ==
"OLDUNITS")
475 data.oldunits_valid =
true;
477 else if (identifier ==
"NEWUNITS")
480 data.newunits_valid =
true;
482 else if (identifier ==
"ACCRDINT")
485 data.accrued_interest_valid =
true;
487 else if (identifier ==
"AVGCOSTBASIS")
490 data.avg_cost_basis_valid =
true;
492 else if (identifier ==
"BUYTYPE" || identifier ==
"OPTBUYTYPE")
496 data.buy_type = data.OFX_BUY_TYPE_BUY;
497 data.buy_type_valid =
true;
499 else if (value ==
"BUYTOCOVER")
501 data.buy_type = data.OFX_BUY_TYPE_BUYTOCOVER;
502 data.buy_type_valid =
true;
504 else if (value ==
"BUYTOOPEN")
506 data.buy_type = data.OFX_BUY_TYPE_BUYTOOPEN;
507 data.buy_type_valid =
true;
509 else if (value ==
"BUYTOCLOSE")
511 data.buy_type = data.OFX_BUY_TYPE_BUYTOCLOSE;
512 data.buy_type_valid =
true;
515 else if (identifier ==
"DENOMINATOR")
518 data.denominator_valid =
true;
520 else if (identifier ==
"DTPAYROLL")
523 data.date_payroll_valid =
true;
525 else if (identifier ==
"DTPURCHASE")
528 data.date_purchase_valid =
true;
530 else if (identifier ==
"GAIN")
533 data.gain_valid =
true;
535 else if (identifier ==
"FRACCASH")
538 data.cash_for_fractional_valid =
true;
540 else if (identifier ==
"INCOMETYPE")
542 if (value ==
"CGLONG")
545 data.income_type_valid =
true;
547 else if (value ==
"CGSHORT")
550 data.income_type_valid =
true;
552 else if (value ==
"DIV")
555 data.income_type_valid =
true;
557 else if (value ==
"INTEREST")
560 data.income_type_valid =
true;
562 else if (value ==
"MISC")
565 data.income_type_valid =
true;
568 else if (identifier ==
"INV401KSOURCE")
570 if (value ==
"PRETAX")
572 data.inv_401k_source = data.OFX_401K_SOURCE_PRETAX;
573 data.inv_401k_source_valid =
true;
575 else if (value ==
"AFTERTAX")
577 data.inv_401k_source = data.OFX_401K_SOURCE_AFTERTAX;
578 data.inv_401k_source_valid =
true;
580 else if (value ==
"MATCH")
582 data.inv_401k_source = data.OFX_401K_SOURCE_MATCH;
583 data.inv_401k_source_valid =
true;
585 else if (value ==
"PROFITSHARING")
587 data.inv_401k_source = data.OFX_401K_SOURCE_PROFITSHARING;
588 data.inv_401k_source_valid =
true;
590 else if (value ==
"ROLLOVER")
592 data.inv_401k_source = data.OFX_401K_SOURCE_ROLLOVER;
593 data.inv_401k_source_valid =
true;
595 else if (value ==
"OTHERVEST")
597 data.inv_401k_source = data.OFX_401K_SOURCE_OTHERVEST;
598 data.inv_401k_source_valid =
true;
600 else if (value ==
"OTHERNONVEST")
602 data.inv_401k_source = data.OFX_401K_SOURCE_OTHERNONVEST;
603 data.inv_401k_source_valid =
true;
606 else if (identifier ==
"LOAD")
609 data.load_valid =
true;
611 else if (identifier ==
"LOANID")
614 data.loan_id_valid =
true;
616 else if (identifier ==
"LOANINTEREST")
619 data.loan_interest_valid =
true;
621 else if (identifier ==
"LOANPRINCIPAL")
624 data.loan_principal_valid =
true;
626 else if (identifier ==
"MARKDOWN")
629 data.markdown_valid =
true;
631 else if (identifier ==
"MARKUP")
634 data.markup_valid =
true;
636 else if (identifier ==
"NUMERATOR")
639 data.numerator_valid =
true;
641 else if (identifier ==
"OPTACTION")
643 if (value ==
"EXERCISE")
645 data.opt_action = data.OFX_OPTACTION_EXERCISE;
646 data.opt_action_valid =
true;
648 else if (value ==
"ASSIGN")
650 data.opt_action = data.OFX_OPTACTION_ASSIGN;
651 data.opt_action_valid =
true;
653 else if (value ==
"EXPIRE")
655 data.opt_action = data.OFX_OPTACTION_EXPIRE;
656 data.opt_action_valid =
true;
659 else if (identifier ==
"PENALTY")
662 data.penalty_valid =
true;
664 else if (identifier ==
"POSTYPE")
668 data.pos_type = data.OFX_POSTYPE_LONG;
669 data.pos_type_valid =
true;
671 else if (value ==
"SHORT")
673 data.pos_type = data.OFX_POSTYPE_SHORT;
674 data.pos_type_valid =
true;
677 else if (identifier ==
"PRIORYEARCONTRIB")
682 data.prior_year_contrib_valid =
true;
684 else if (value ==
"N")
687 data.prior_year_contrib_valid =
true;
690 else if (identifier ==
"RELFITID")
693 data.related_fi_tid_valid =
true;
695 else if (identifier ==
"RELTYPE")
697 if (value ==
"SPREAD")
699 data.related_type = data.OFX_RELTYPE_SPREAD;
700 data.related_type_valid =
true;
702 else if (value ==
"STRADDLE")
704 data.related_type = data.OFX_RELTYPE_STRADDLE;
705 data.related_type_valid =
true;
707 else if (value ==
"NONE")
709 data.related_type = data.OFX_RELTYPE_NONE;
710 data.related_type_valid =
true;
712 else if (value ==
"OTHER")
714 data.related_type = data.OFX_RELTYPE_OTHER;
715 data.related_type_valid =
true;
718 else if (identifier ==
"SECURED")
720 if (value ==
"NAKED")
722 data.option_secured = data.OFX_SECURED_NAKED;
723 data.option_secured_valid =
true;
725 else if (value ==
"COVERED")
727 data.option_secured = data.OFX_SECURED_COVERED;
728 data.option_secured_valid =
true;
731 else if (identifier ==
"SELLREASON")
736 data.sell_reason_valid =
true;
738 else if (value ==
"SELL")
741 data.sell_reason_valid =
true;
743 else if (value ==
"MATURITY")
746 data.sell_reason_valid =
true;
749 else if (identifier ==
"SELLTYPE" || identifier ==
"OPTSELLTYPE")
753 data.sell_type = data.OFX_SELL_TYPE_SELL;
754 data.sell_type_valid =
true;
756 else if (value ==
"SELLSHORT")
758 data.sell_type = data.OFX_SELL_TYPE_SELLSHORT;
759 data.sell_type_valid =
true;
761 else if (value ==
"SELLTOOPEN")
763 data.sell_type = data.OFX_SELL_TYPE_SELLTOOPEN;
764 data.sell_type_valid =
true;
766 else if (value ==
"SELLTOCLOSE")
768 data.sell_type = data.OFX_SELL_TYPE_SELLTOCLOSE;
769 data.sell_type_valid =
true;
772 else if (identifier ==
"SHPERCTRCT")
775 data.shares_per_cont_valid =
true;
777 else if (identifier ==
"STATEWITHHOLDING")
780 data.state_withholding_valid =
true;
782 else if (identifier ==
"SUBACCTFROM")
786 data.subacct_from = data.OFX_SUBACCT_CASH;
789 else if (value ==
"MARGIN")
791 data.subacct_from = data.OFX_SUBACCT_MARGIN;
794 else if (value ==
"SHORT")
796 data.subacct_from = data.OFX_SUBACCT_SHORT;
799 else if (value ==
"OTHER")
801 data.subacct_from = data.OFX_SUBACCT_OTHER;
805 else if (identifier ==
"SUBACCTFUND")
809 data.subacct_funding = data.OFX_SUBACCT_CASH;
812 else if (value ==
"MARGIN")
814 data.subacct_funding = data.OFX_SUBACCT_MARGIN;
817 else if (value ==
"SHORT")
819 data.subacct_funding = data.OFX_SUBACCT_SHORT;
822 else if (value ==
"OTHER")
824 data.subacct_funding = data.OFX_SUBACCT_OTHER;
828 else if (identifier ==
"SUBACCTSEC")
832 data.subacct_security = data.OFX_SUBACCT_CASH;
835 else if (value ==
"MARGIN")
837 data.subacct_security = data.OFX_SUBACCT_MARGIN;
840 else if (value ==
"SHORT")
842 data.subacct_security = data.OFX_SUBACCT_SHORT;
845 else if (value ==
"OTHER")
847 data.subacct_security = data.OFX_SUBACCT_OTHER;
851 else if (identifier ==
"SUBACCTTO")
855 data.subacct_to = data.OFX_SUBACCT_CASH;
858 else if (value ==
"MARGIN")
860 data.subacct_to = data.OFX_SUBACCT_MARGIN;
863 else if (value ==
"SHORT")
865 data.subacct_to = data.OFX_SUBACCT_SHORT;
868 else if (value ==
"OTHER")
870 data.subacct_to = data.OFX_SUBACCT_OTHER;
874 else if (identifier ==
"TAXES")
877 data.taxes_valid =
true;
879 else if (identifier ==
"TAXEXEMPT")
884 data.tax_exempt_valid =
true;
886 else if (value ==
"N")
889 data.tax_exempt_valid =
true;
892 else if (identifier ==
"TFERACTION")
896 data.transfer_action = data.OFX_TFERACTION_IN;
897 data.transfer_action_valid =
true;
899 else if (value ==
"OUT")
901 data.transfer_action = data.OFX_TFERACTION_OUT;
902 data.transfer_action_valid =
true;
905 else if (identifier ==
"UNITTYPE")
907 if (value ==
"SHARES")
909 data.unit_type = data.OFX_UNITTYPE_SHARES;
910 data.unit_type_valid =
true;
912 else if (value ==
"CURRENCY")
914 data.unit_type = data.OFX_UNITTYPE_CURRENCY;
915 data.unit_type_valid =
true;
918 else if (identifier ==
"WITHHOLDING")
921 data.withholding_valid =
true;
924 else if ( identifier ==
"TRNTYPE")
927 if (value ==
"CREDIT")
931 else if (value ==
"DEBIT")
935 else if (value ==
"INT")
937 data.transactiontype =
OFX_INT;
939 else if (value ==
"DIV")
941 data.transactiontype =
OFX_DIV;
943 else if (value ==
"FEE")
945 data.transactiontype =
OFX_FEE;
947 else if (value ==
"SRVCHG")
951 else if (value ==
"DEP")
953 data.transactiontype =
OFX_DEP;
955 else if (value ==
"ATM")
957 data.transactiontype =
OFX_ATM;
959 else if (value ==
"POS")
961 data.transactiontype =
OFX_POS;
963 else if (value ==
"XFER")
967 else if (value ==
"CHECK")
971 else if (value ==
"PAYMENT")
975 else if (value ==
"CASH")
979 else if (value ==
"DIRECTDEP")
983 else if (value ==
"DIRECTDEBIT")
987 else if (value ==
"REPEATPMT")
991 else if (value ==
"OTHER")
1000 else if (identifier ==
"TRNAMT")
1003 data.amount_valid =
true;
1005 data.units_valid =
true;
1007 data.unitprice_valid =
true;
1009 else if (identifier ==
"CHECKNUM")
1012 data.check_number_valid =
true;
1014 else if (identifier ==
"REFNUM")
1017 data.reference_number_valid =
true;
1019 else if (identifier ==
"SIC")
1022 data.standard_industrial_code_valid =
true;
1024 else if ((identifier ==
"PAYEEID") || (identifier ==
"PAYEEID2"))
1027 data.payee_id_valid =
true;
1029 else if (identifier ==
"NAME")
1031 strncpy(data.
name, value.c_str(),
sizeof(data.
name));
1032 data.name_valid =
true;
An abstraction of an account.
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float.
virtual int add_to_main_tree()
Add this container to the main tree.
char reference_number[OFX_REFERENCE_NUMBER_LENGTH]
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
char unique_id[OFX_UNIQUE_ID_LENGTH]
char account_id[OFX_ACCOUNT_ID_LENGTH]
Represents a generic transaction.
Various simple functions for type conversion & al.
char check_number[OFX_CHECK_NUMBER_LENGTH]
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
int transactiontype_valid
char name[OFX_TRANSACTION_NAME_LENGTH]
char memo[OFX_MEMO2_LENGTH]
FiIdCorrectionAction fi_id_correction_action
time_t ofxdate_to_time_t(const string ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
int amounts_are_foreign_currency
long int standard_industrial_code
int message_out(OfxMsgType error_type, const string message)
Message output function.
double cash_for_fractional
int subacct_funding_valid
char account_id[OFX_ACCOUNT_ID_LENGTH]
char fi_id[OFX_FITID_LENGTH]
void add_attribute(const string identifier, const string value)
Add data to a container object.
struct OfxAccountData * account_ptr
char server_transaction_id[OFX_SVRTID2_LENGTH]
LibOFX internal object code.
void add_attribute(const string identifier, const string value)
Add data to a container object.
char related_fi_tid[OFX_FITID_LENGTH]
Represents a statement for either a bank account or a credit card account.
Message IO functionality.
int subacct_security_valid
char payee_id[OFX_SVRTID2_LENGTH]
time_t date_funds_available
char currency[OFX_CURRENCY_LENGTH]
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
The root container. Created by the <OFX> OFX element or by the export functions.
char fi_id_corrected[OFX_FITID_LENGTH]
virtual int gen_event()
Generate libofx.h events.
char loan_id[OFX_LOANID_LENGTH]