LibOFX: ofx_container_transaction.cpp Source File

LibOFX

build/libofx-0.10.0/lib/ofx_container_transaction.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 ofx_container_account.cpp
3 -------------------
4 copyright : (C) 2002 by Benoit Gr�goire
5 email : benoitg@coeus.ca
6 ***************************************************************************/
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <cstdlib>
25 #include <string>
26 #include "messages.hh"
27 #include "libofx.h"
28 #include "ofx_containers.hh"
29 #include "ofx_utilities.hh"
30
31 extern OfxMainContainer * MainContainer;
32
33 /***************************************************************************
34 * OfxTransactionContainer *
35 ***************************************************************************/
36
37 OfxTransactionContainer::OfxTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
38 OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
39 {
40 OfxGenericContainer * tmp_parentcontainer = parentcontainer;
41
42 memset(&data, 0, sizeof(data));
43 type = "TRANSACTION";
44 /* Find the parent statement container*/
45 while (tmp_parentcontainer != NULL && tmp_parentcontainer->type != "STATEMENT")
46 {
47 tmp_parentcontainer = tmp_parentcontainer->parentcontainer;
48 }
49 if (tmp_parentcontainer != NULL)
50 {
51 parent_statement = (OfxStatementContainer*)tmp_parentcontainer;
52 }
53 else
54 {
55 parent_statement = NULL;
56 message_out(ERROR, "Unable to find the enclosing statement container this transaction");
57 }
58 if (parent_statement != NULL && parent_statement->data.account_id_valid == true)
59 {
60 strncpy(data.account_id, parent_statement->data.account_id, OFX_ACCOUNT_ID_LENGTH);
61 data.account_id_valid = true;
62 }
63 }
64 OfxTransactionContainer::~OfxTransactionContainer()
65 {
66
67 }
68
69 int OfxTransactionContainer::gen_event()
70 {
71 if (data.unique_id_valid == true && MainContainer != NULL)
72 {
73 data.security_data_ptr = MainContainer->find_security(data.unique_id);
74 if (data.security_data_ptr != NULL)
75 {
76 data.security_data_valid = true;
77 }
78 }
79 libofx_context->transactionCallback(data);
80 return true;
81 }
82
83 int OfxTransactionContainer::add_to_main_tree()
84 {
85
86 if (MainContainer != NULL)
87 {
88 return MainContainer->add_container(this);
89 }
90 else
91 {
92 return false;
93 }
94 }
95
96
97 void OfxTransactionContainer::add_attribute(const string identifier, const string value)
98 {
99
100 if (identifier == "DTPOSTED")
101 {
102 data.date_posted = ofxdate_to_time_t(value);
103 data.date_posted_valid = true;
104 }
105 else if (identifier == "DTUSER")
106 {
107 data.date_initiated = ofxdate_to_time_t(value);
108 data.date_initiated_valid = true;
109 }
110 else if (identifier == "DTAVAIL")
111 {
112 data.date_funds_available = ofxdate_to_time_t(value);
113 data.date_funds_available_valid = true;
114 }
115 else if (identifier == "FITID")
116 {
117 strncpy(data.fi_id, value.c_str(), sizeof(data.fi_id));
118 data.fi_id_valid = true;
119 }
120 else if (identifier == "CORRECTFITID")
121 {
122 strncpy(data.fi_id_corrected, value.c_str(), sizeof(data.fi_id_corrected));
123 data.fi_id_corrected_valid = true;
124 }
125 else if (identifier == "CORRECTACTION")
126 {
127 data.fi_id_correction_action_valid = true;
128 if (value == "REPLACE")
129 {
130 data.fi_id_correction_action = REPLACE;
131 }
132 else if (value == "DELETE")
133 {
134 data.fi_id_correction_action = DELETE;
135 }
136 else
137 {
138 data.fi_id_correction_action_valid = false;
139 }
140 }
141 else if ((identifier == "SRVRTID") || (identifier == "SRVRTID2"))
142 {
143 strncpy(data.server_transaction_id, value.c_str(), sizeof(data.server_transaction_id));
144 data.server_transaction_id_valid = true;
145 }
146 else if (identifier == "MEMO" || identifier == "MEMO2")
147 {
148 strncpy(data.memo, value.c_str(), sizeof(data.memo));
149 data.memo_valid = true;
150 }
151 else if (identifier == "CURRENCY")
152 {
153 data.amounts_are_foreign_currency = false;
154 data.amounts_are_foreign_currency_valid = true;
155 }
156 else if (identifier == "ORIGCURRENCY")
157 {
158 data.amounts_are_foreign_currency = true;
159 data.amounts_are_foreign_currency_valid = true;
160 }
161 else
162 {
163 /* Redirect unknown identifiers to the base class */
164 OfxGenericContainer::add_attribute(identifier, value);
165 }
166 }// end OfxTransactionContainer::add_attribute()
167
168 void OfxTransactionContainer::add_account(OfxAccountData * account_data)
169 {
170 if (account_data->account_id_valid == true)
171 {
172 data.account_ptr = account_data;
173 strncpy(data.account_id, account_data->account_id, OFX_ACCOUNT_ID_LENGTH);
174 data.account_id_valid = true;
175 }
176 }
177
178 /***************************************************************************
179 * OfxBankTransactionContainer *
180 ***************************************************************************/
181
182 OfxBankTransactionContainer::OfxBankTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
183 OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
184 {
185 ;
186 }
187 void OfxBankTransactionContainer::add_attribute(const string identifier, const string value)
188 {
189 if ( identifier == "TRNTYPE")
190 {
191 data.transactiontype_valid = true;
192 if (value == "CREDIT")
193 {
194 data.transactiontype = OFX_CREDIT;
195 }
196 else if (value == "DEBIT")
197 {
198 data.transactiontype = OFX_DEBIT;
199 }
200 else if (value == "INT")
201 {
202 data.transactiontype = OFX_INT;
203 }
204 else if (value == "DIV")
205 {
206 data.transactiontype = OFX_DIV;
207 }
208 else if (value == "FEE")
209 {
210 data.transactiontype = OFX_FEE;
211 }
212 else if (value == "SRVCHG")
213 {
214 data.transactiontype = OFX_SRVCHG;
215 }
216 else if (value == "DEP")
217 {
218 data.transactiontype = OFX_DEP;
219 }
220 else if (value == "ATM")
221 {
222 data.transactiontype = OFX_ATM;
223 }
224 else if (value == "POS")
225 {
226 data.transactiontype = OFX_POS;
227 }
228 else if (value == "XFER")
229 {
230 data.transactiontype = OFX_XFER;
231 }
232 else if (value == "CHECK")
233 {
234 data.transactiontype = OFX_CHECK;
235 }
236 else if (value == "PAYMENT")
237 {
238 data.transactiontype = OFX_PAYMENT;
239 }
240 else if (value == "CASH")
241 {
242 data.transactiontype = OFX_CASH;
243 }
244 else if (value == "DIRECTDEP")
245 {
246 data.transactiontype = OFX_DIRECTDEP;
247 }
248 else if (value == "DIRECTDEBIT")
249 {
250 data.transactiontype = OFX_DIRECTDEBIT;
251 }
252 else if (value == "REPEATPMT")
253 {
254 data.transactiontype = OFX_REPEATPMT;
255 }
256 else if (value == "OTHER")
257 {
258 data.transactiontype = OFX_OTHER;
259 }
260 else
261 {
262 data.transactiontype_valid = false;
263 }
264 }//end TRANSTYPE
265 else if (identifier == "TRNAMT")
266 {
267 data.amount = ofxamount_to_double(value);
268 data.amount_valid = true;
269 data.units = -data.amount;
270 data.units_valid = true;
271 data.unitprice = 1.00;
272 data.unitprice_valid = true;
273 }
274 else if (identifier == "CHECKNUM")
275 {
276 strncpy(data.check_number, value.c_str(), sizeof(data.check_number));
277 data.check_number_valid = true;
278 }
279 else if (identifier == "REFNUM")
280 {
281 strncpy(data.reference_number, value.c_str(), sizeof(data.reference_number));
282 data.reference_number_valid = true;
283 }
284 else if (identifier == "SIC")
285 {
286 data.standard_industrial_code = atoi(value.c_str());
287 data.standard_industrial_code_valid = true;
288 }
289 else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
290 {
291 strncpy(data.payee_id, value.c_str(), sizeof(data.payee_id));
292 data.payee_id_valid = true;
293 }
294 else if (identifier == "NAME")
295 {
296 strncpy(data.name, value.c_str(), sizeof(data.name));
297 data.name_valid = true;
298 }
299 else
300 {
301 /* Redirect unknown identifiers to base class */
302 OfxTransactionContainer::add_attribute(identifier, value);
303 }
304 }//end OfxBankTransactionContainer::add_attribute
305
306
307 /***************************************************************************
308 * OfxInvestmentTransactionContainer *
309 ***************************************************************************/
310
311 OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
312 OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
313 {
314 type = "INVESTMENT";
315 data.transactiontype = OFX_OTHER;
316 data.transactiontype_valid = true;
317
318 data.invtransactiontype_valid = true;
319 if (para_tag_identifier == "BUYDEBT")
320 {
321 data.invtransactiontype = OFX_BUYDEBT;
322 }
323 else if (para_tag_identifier == "BUYMF")
324 {
325 data.invtransactiontype = OFX_BUYMF;
326 }
327 else if (para_tag_identifier == "BUYOPT")
328 {
329 data.invtransactiontype = OFX_BUYOPT;
330 }
331 else if (para_tag_identifier == "BUYOTHER")
332 {
333 data.invtransactiontype = OFX_BUYOTHER;
334 }
335 else if (para_tag_identifier == "BUYSTOCK")
336 {
337 data.invtransactiontype = OFX_BUYSTOCK;
338 }
339 else if (para_tag_identifier == "CLOSUREOPT")
340 {
341 data.invtransactiontype = OFX_CLOSUREOPT;
342 }
343 else if (para_tag_identifier == "INCOME")
344 {
345 data.invtransactiontype = OFX_INCOME;
346 }
347 else if (para_tag_identifier == "INVEXPENSE")
348 {
349 data.invtransactiontype = OFX_INVEXPENSE;
350 }
351 else if (para_tag_identifier == "JRNLFUND")
352 {
353 data.invtransactiontype = OFX_JRNLFUND;
354 }
355 else if (para_tag_identifier == "JRNLSEC")
356 {
357 data.invtransactiontype = OFX_JRNLSEC;
358 }
359 else if (para_tag_identifier == "MARGININTEREST")
360 {
361 data.invtransactiontype = OFX_MARGININTEREST;
362 }
363 else if (para_tag_identifier == "REINVEST")
364 {
365 data.invtransactiontype = OFX_REINVEST;
366 }
367 else if (para_tag_identifier == "RETOFCAP")
368 {
369 data.invtransactiontype = OFX_RETOFCAP;
370 }
371 else if (para_tag_identifier == "SELLDEBT")
372 {
373 data.invtransactiontype = OFX_SELLDEBT;
374 }
375 else if (para_tag_identifier == "SELLMF")
376 {
377 data.invtransactiontype = OFX_SELLMF;
378 }
379 else if (para_tag_identifier == "SELLOPT")
380 {
381 data.invtransactiontype = OFX_SELLOPT;
382 }
383 else if (para_tag_identifier == "SELLOTHER")
384 {
385 data.invtransactiontype = OFX_SELLOTHER;
386 }
387 else if (para_tag_identifier == "SELLSTOCK")
388 {
389 data.invtransactiontype = OFX_SELLSTOCK;
390 }
391 else if (para_tag_identifier == "SPLIT")
392 {
393 data.invtransactiontype = OFX_SPLIT;
394 }
395 else if (para_tag_identifier == "TRANSFER")
396 {
397 data.invtransactiontype = OFX_TRANSFER;
398 }
399 else if (para_tag_identifier == "INVBANKTRAN")
400 {
401 data.invtransactiontype = OFX_INVBANKTRAN;
402 }
403 else
404 {
405 message_out(ERROR, "This should not happen, " + para_tag_identifier + " is an unknown investment transaction type");
406 data.invtransactiontype_valid = false;
407 }
408 }
409
410 void OfxInvestmentTransactionContainer::add_attribute(const string identifier, const string value)
411 {
412 if (identifier == "UNIQUEID")
413 {
414 strncpy(data.unique_id, value.c_str(), sizeof(data.unique_id));
415 data.unique_id_valid = true;
416 }
417 else if (identifier == "UNIQUEIDTYPE")
418 {
419 strncpy(data.unique_id_type, value.c_str(), sizeof(data.unique_id_type));
420 data.unique_id_type_valid = true;
421 }
422 else if (identifier == "UNITS")
423 {
424 data.units = ofxamount_to_double(value);
425 data.units_valid = true;
426 }
427 else if (identifier == "UNITPRICE")
428 {
429 data.unitprice = ofxamount_to_double(value);
430 data.unitprice_valid = true;
431 }
432 else if (identifier == "MKTVAL")
433 {
434 data.market_value = ofxamount_to_double(value);
435 data.market_value_valid = true;
436 }
437 else if (identifier == "TOTAL")
438 {
439 data.amount = ofxamount_to_double(value);
440 data.amount_valid = true;
441 }
442 else if (identifier == "CURRATE")
443 {
444 data.currency_ratio = ofxamount_to_double(value);
445 data.currency_ratio_valid = true;
446 }
447 else if (identifier == "CURSYM")
448 {
449 strncpy(data.currency, value.c_str(), sizeof(data.currency));
450 data.currency_valid = true;
451 }
452 else if (identifier == "DTSETTLE")
453 {
454 data.date_posted = ofxdate_to_time_t(value);
455 data.date_posted_valid = true;
456 }
457 else if (identifier == "DTTRADE")
458 {
459 data.date_initiated = ofxdate_to_time_t(value);
460 data.date_initiated_valid = true;
461 }
462 else if (identifier == "COMMISSION")
463 {
464 data.commission = ofxamount_to_double(value);
465 data.commission_valid = true;
466 }
467 else if (identifier == "FEES")
468 {
469 data.fees = ofxamount_to_double(value);
470 data.fees_valid = true;
471 }
472 else if (identifier == "OLDUNITS")
473 {
474 data.oldunits = ofxamount_to_double(value);
475 data.oldunits_valid = true;
476 }
477 else if (identifier == "NEWUNITS")
478 {
479 data.newunits = ofxamount_to_double(value);
480 data.newunits_valid = true;
481 }
482 else if (identifier == "ACCRDINT")
483 {
484 data.accrued_interest = ofxamount_to_double(value);
485 data.accrued_interest_valid = true;
486 }
487 else if (identifier == "AVGCOSTBASIS")
488 {
489 data.avg_cost_basis = ofxamount_to_double(value);
490 data.avg_cost_basis_valid = true;
491 }
492 else if (identifier == "BUYTYPE" || identifier == "OPTBUYTYPE")
493 {
494 if (value == "BUY")
495 {
496 data.buy_type = data.OFX_BUY_TYPE_BUY;
497 data.buy_type_valid = true;
498 }
499 else if (value == "BUYTOCOVER")
500 {
501 data.buy_type = data.OFX_BUY_TYPE_BUYTOCOVER;
502 data.buy_type_valid = true;
503 }
504 else if (value == "BUYTOOPEN")
505 {
506 data.buy_type = data.OFX_BUY_TYPE_BUYTOOPEN;
507 data.buy_type_valid = true;
508 }
509 else if (value == "BUYTOCLOSE")
510 {
511 data.buy_type = data.OFX_BUY_TYPE_BUYTOCLOSE;
512 data.buy_type_valid = true;
513 }
514 }
515 else if (identifier == "DENOMINATOR")
516 {
517 data.denominator = ofxamount_to_double(value);
518 data.denominator_valid = true;
519 }
520 else if (identifier == "DTPAYROLL")
521 {
522 data.date_payroll = ofxdate_to_time_t(value);
523 data.date_payroll_valid = true;
524 }
525 else if (identifier == "DTPURCHASE")
526 {
527 data.date_purchase = ofxdate_to_time_t(value);
528 data.date_purchase_valid = true;
529 }
530 else if (identifier == "GAIN")
531 {
532 data.gain = ofxamount_to_double(value);
533 data.gain_valid = true;
534 }
535 else if (identifier == "FRACCASH")
536 {
537 data.cash_for_fractional = ofxamount_to_double(value);
538 data.cash_for_fractional_valid = true;
539 }
540 else if (identifier == "INCOMETYPE")
541 {
542 if (value == "CGLONG")
543 {
544 data.income_type = data.OFX_CGLONG;
545 data.income_type_valid = true;
546 }
547 else if (value == "CGSHORT")
548 {
549 data.income_type = data.OFX_CGSHORT;
550 data.income_type_valid = true;
551 }
552 else if (value == "DIV")
553 {
554 data.income_type = data.OFX_DIVIDEND;
555 data.income_type_valid = true;
556 }
557 else if (value == "INTEREST")
558 {
559 data.income_type = data.OFX_INTEREST;
560 data.income_type_valid = true;
561 }
562 else if (value == "MISC")
563 {
564 data.income_type = data.OFX_MISC;
565 data.income_type_valid = true;
566 }
567 }
568 else if (identifier == "INV401KSOURCE")
569 {
570 if (value == "PRETAX")
571 {
572 data.inv_401k_source = data.OFX_401K_SOURCE_PRETAX;
573 data.inv_401k_source_valid = true;
574 }
575 else if (value == "AFTERTAX")
576 {
577 data.inv_401k_source = data.OFX_401K_SOURCE_AFTERTAX;
578 data.inv_401k_source_valid = true;
579 }
580 else if (value == "MATCH")
581 {
582 data.inv_401k_source = data.OFX_401K_SOURCE_MATCH;
583 data.inv_401k_source_valid = true;
584 }
585 else if (value == "PROFITSHARING")
586 {
587 data.inv_401k_source = data.OFX_401K_SOURCE_PROFITSHARING;
588 data.inv_401k_source_valid = true;
589 }
590 else if (value == "ROLLOVER")
591 {
592 data.inv_401k_source = data.OFX_401K_SOURCE_ROLLOVER;
593 data.inv_401k_source_valid = true;
594 }
595 else if (value == "OTHERVEST")
596 {
597 data.inv_401k_source = data.OFX_401K_SOURCE_OTHERVEST;
598 data.inv_401k_source_valid = true;
599 }
600 else if (value == "OTHERNONVEST")
601 {
602 data.inv_401k_source = data.OFX_401K_SOURCE_OTHERNONVEST;
603 data.inv_401k_source_valid = true;
604 }
605 }
606 else if (identifier == "LOAD")
607 {
608 data.load = ofxamount_to_double(value);
609 data.load_valid = true;
610 }
611 else if (identifier == "LOANID")
612 {
613 strncpy(data.loan_id, value.c_str(), sizeof(data.loan_id));
614 data.loan_id_valid = true;
615 }
616 else if (identifier == "LOANINTEREST")
617 {
618 data.loan_interest = ofxamount_to_double(value);
619 data.loan_interest_valid = true;
620 }
621 else if (identifier == "LOANPRINCIPAL")
622 {
623 data.loan_principal = ofxamount_to_double(value);
624 data.loan_principal_valid = true;
625 }
626 else if (identifier == "MARKDOWN")
627 {
628 data.markdown = ofxamount_to_double(value);
629 data.markdown_valid = true;
630 }
631 else if (identifier == "MARKUP")
632 {
633 data.markup = ofxamount_to_double(value);
634 data.markup_valid = true;
635 }
636 else if (identifier == "NUMERATOR")
637 {
638 data.numerator = ofxamount_to_double(value);
639 data.numerator_valid = true;
640 }
641 else if (identifier == "OPTACTION")
642 {
643 if (value == "EXERCISE")
644 {
645 data.opt_action = data.OFX_OPTACTION_EXERCISE;
646 data.opt_action_valid = true;
647 }
648 else if (value == "ASSIGN")
649 {
650 data.opt_action = data.OFX_OPTACTION_ASSIGN;
651 data.opt_action_valid = true;
652 }
653 else if (value == "EXPIRE")
654 {
655 data.opt_action = data.OFX_OPTACTION_EXPIRE;
656 data.opt_action_valid = true;
657 }
658 }
659 else if (identifier == "PENALTY")
660 {
661 data.penalty = ofxamount_to_double(value);
662 data.penalty_valid = true;
663 }
664 else if (identifier == "POSTYPE")
665 {
666 if (value == "LONG")
667 {
668 data.pos_type = data.OFX_POSTYPE_LONG;
669 data.pos_type_valid = true;
670 }
671 else if (value == "SHORT")
672 {
673 data.pos_type = data.OFX_POSTYPE_SHORT;
674 data.pos_type_valid = true;
675 }
676 }
677 else if (identifier == "PRIORYEARCONTRIB")
678 {
679 if (value == "Y")
680 {
681 data.prior_year_contrib = true;
682 data.prior_year_contrib_valid = true;
683 }
684 else if (value == "N")
685 {
686 data.prior_year_contrib = false;
687 data.prior_year_contrib_valid = true;
688 }
689 }
690 else if (identifier == "RELFITID")
691 {
692 strncpy(data.related_fi_tid, value.c_str(), sizeof(data.related_fi_tid));
693 data.related_fi_tid_valid = true;
694 }
695 else if (identifier == "RELTYPE")
696 {
697 if (value == "SPREAD")
698 {
699 data.related_type = data.OFX_RELTYPE_SPREAD;
700 data.related_type_valid = true;
701 }
702 else if (value == "STRADDLE")
703 {
704 data.related_type = data.OFX_RELTYPE_STRADDLE;
705 data.related_type_valid = true;
706 }
707 else if (value == "NONE")
708 {
709 data.related_type = data.OFX_RELTYPE_NONE;
710 data.related_type_valid = true;
711 }
712 else if (value == "OTHER")
713 {
714 data.related_type = data.OFX_RELTYPE_OTHER;
715 data.related_type_valid = true;
716 }
717 }
718 else if (identifier == "SECURED")
719 {
720 if (value == "NAKED")
721 {
722 data.option_secured = data.OFX_SECURED_NAKED;
723 data.option_secured_valid = true;
724 }
725 else if (value == "COVERED")
726 {
727 data.option_secured = data.OFX_SECURED_COVERED;
728 data.option_secured_valid = true;
729 }
730 }
731 else if (identifier == "SELLREASON")
732 {
733 if (value == "CALL")
734 {
735 data.sell_reason = data.OFX_SELLREASON_CALL;
736 data.sell_reason_valid = true;
737 }
738 else if (value == "SELL")
739 {
740 data.sell_reason = data.OFX_SELLREASON_SELL;
741 data.sell_reason_valid = true;
742 }
743 else if (value == "MATURITY")
744 {
745 data.sell_reason = data.OFX_SELLREASON_MATURITY;
746 data.sell_reason_valid = true;
747 }
748 }
749 else if (identifier == "SELLTYPE" || identifier == "OPTSELLTYPE")
750 {
751 if (value == "SELL")
752 {
753 data.sell_type = data.OFX_SELL_TYPE_SELL;
754 data.sell_type_valid = true;
755 }
756 else if (value == "SELLSHORT")
757 {
758 data.sell_type = data.OFX_SELL_TYPE_SELLSHORT;
759 data.sell_type_valid = true;
760 }
761 else if (value == "SELLTOOPEN")
762 {
763 data.sell_type = data.OFX_SELL_TYPE_SELLTOOPEN;
764 data.sell_type_valid = true;
765 }
766 else if (value == "SELLTOCLOSE")
767 {
768 data.sell_type = data.OFX_SELL_TYPE_SELLTOCLOSE;
769 data.sell_type_valid = true;
770 }
771 }
772 else if (identifier == "SHPERCTRCT")
773 {
774 data.shares_per_cont = ofxamount_to_double(value);
775 data.shares_per_cont_valid = true;
776 }
777 else if (identifier == "STATEWITHHOLDING")
778 {
779 data.state_withholding = ofxamount_to_double(value);
780 data.state_withholding_valid = true;
781 }
782 else if (identifier == "SUBACCTFROM")
783 {
784 if (value == "CASH")
785 {
786 data.subacct_from = data.OFX_SUBACCT_CASH;
787 data.subacct_from_valid = true;
788 }
789 else if (value == "MARGIN")
790 {
791 data.subacct_from = data.OFX_SUBACCT_MARGIN;
792 data.subacct_from_valid = true;
793 }
794 else if (value == "SHORT")
795 {
796 data.subacct_from = data.OFX_SUBACCT_SHORT;
797 data.subacct_from_valid = true;
798 }
799 else if (value == "OTHER")
800 {
801 data.subacct_from = data.OFX_SUBACCT_OTHER;
802 data.subacct_from_valid = true;
803 }
804 }
805 else if (identifier == "SUBACCTFUND")
806 {
807 if (value == "CASH")
808 {
809 data.subacct_funding = data.OFX_SUBACCT_CASH;
810 data.subacct_funding_valid = true;
811 }
812 else if (value == "MARGIN")
813 {
814 data.subacct_funding = data.OFX_SUBACCT_MARGIN;
815 data.subacct_funding_valid = true;
816 }
817 else if (value == "SHORT")
818 {
819 data.subacct_funding = data.OFX_SUBACCT_SHORT;
820 data.subacct_funding_valid = true;
821 }
822 else if (value == "OTHER")
823 {
824 data.subacct_funding = data.OFX_SUBACCT_OTHER;
825 data.subacct_funding_valid = true;
826 }
827 }
828 else if (identifier == "SUBACCTSEC")
829 {
830 if (value == "CASH")
831 {
832 data.subacct_security = data.OFX_SUBACCT_CASH;
833 data.subacct_security_valid = true;
834 }
835 else if (value == "MARGIN")
836 {
837 data.subacct_security = data.OFX_SUBACCT_MARGIN;
838 data.subacct_security_valid = true;
839 }
840 else if (value == "SHORT")
841 {
842 data.subacct_security = data.OFX_SUBACCT_SHORT;
843 data.subacct_security_valid = true;
844 }
845 else if (value == "OTHER")
846 {
847 data.subacct_security = data.OFX_SUBACCT_OTHER;
848 data.subacct_security_valid = true;
849 }
850 }
851 else if (identifier == "SUBACCTTO")
852 {
853 if (value == "CASH")
854 {
855 data.subacct_to = data.OFX_SUBACCT_CASH;
856 data.subacct_to_valid = true;
857 }
858 else if (value == "MARGIN")
859 {
860 data.subacct_to = data.OFX_SUBACCT_MARGIN;
861 data.subacct_to_valid = true;
862 }
863 else if (value == "SHORT")
864 {
865 data.subacct_to = data.OFX_SUBACCT_SHORT;
866 data.subacct_to_valid = true;
867 }
868 else if (value == "OTHER")
869 {
870 data.subacct_to = data.OFX_SUBACCT_OTHER;
871 data.subacct_to_valid = true;
872 }
873 }
874 else if (identifier == "TAXES")
875 {
876 data.taxes = ofxamount_to_double(value);
877 data.taxes_valid = true;
878 }
879 else if (identifier == "TAXEXEMPT")
880 {
881 if (value == "Y")
882 {
883 data.tax_exempt = true;
884 data.tax_exempt_valid = true;
885 }
886 else if (value == "N")
887 {
888 data.tax_exempt = false;
889 data.tax_exempt_valid = true;
890 }
891 }
892 else if (identifier == "TFERACTION")
893 {
894 if (value == "IN")
895 {
896 data.transfer_action = data.OFX_TFERACTION_IN;
897 data.transfer_action_valid = true;
898 }
899 else if (value == "OUT")
900 {
901 data.transfer_action = data.OFX_TFERACTION_OUT;
902 data.transfer_action_valid = true;
903 }
904 }
905 else if (identifier == "UNITTYPE")
906 {
907 if (value == "SHARES")
908 {
909 data.unit_type = data.OFX_UNITTYPE_SHARES;
910 data.unit_type_valid = true;
911 }
912 else if (value == "CURRENCY")
913 {
914 data.unit_type = data.OFX_UNITTYPE_CURRENCY;
915 data.unit_type_valid = true;
916 }
917 }
918 else if (identifier == "WITHHOLDING")
919 {
920 data.withholding = ofxamount_to_double(value);
921 data.withholding_valid = true;
922 }
923 /* the following fields are <STMTTRN> elements for <INVBANKTRAN> */
924 else if ( identifier == "TRNTYPE")
925 {
926 data.transactiontype_valid = true;
927 if (value == "CREDIT")
928 {
929 data.transactiontype = OFX_CREDIT;
930 }
931 else if (value == "DEBIT")
932 {
933 data.transactiontype = OFX_DEBIT;
934 }
935 else if (value == "INT")
936 {
937 data.transactiontype = OFX_INT;
938 }
939 else if (value == "DIV")
940 {
941 data.transactiontype = OFX_DIV;
942 }
943 else if (value == "FEE")
944 {
945 data.transactiontype = OFX_FEE;
946 }
947 else if (value == "SRVCHG")
948 {
949 data.transactiontype = OFX_SRVCHG;
950 }
951 else if (value == "DEP")
952 {
953 data.transactiontype = OFX_DEP;
954 }
955 else if (value == "ATM")
956 {
957 data.transactiontype = OFX_ATM;
958 }
959 else if (value == "POS")
960 {
961 data.transactiontype = OFX_POS;
962 }
963 else if (value == "XFER")
964 {
965 data.transactiontype = OFX_XFER;
966 }
967 else if (value == "CHECK")
968 {
969 data.transactiontype = OFX_CHECK;
970 }
971 else if (value == "PAYMENT")
972 {
973 data.transactiontype = OFX_PAYMENT;
974 }
975 else if (value == "CASH")
976 {
977 data.transactiontype = OFX_CASH;
978 }
979 else if (value == "DIRECTDEP")
980 {
981 data.transactiontype = OFX_DIRECTDEP;
982 }
983 else if (value == "DIRECTDEBIT")
984 {
985 data.transactiontype = OFX_DIRECTDEBIT;
986 }
987 else if (value == "REPEATPMT")
988 {
989 data.transactiontype = OFX_REPEATPMT;
990 }
991 else if (value == "OTHER")
992 {
993 data.transactiontype = OFX_OTHER;
994 }
995 else
996 {
997 data.transactiontype_valid = false;
998 }
999 }//end TRANSTYPE
1000 else if (identifier == "TRNAMT")
1001 {
1002 data.amount = ofxamount_to_double(value);
1003 data.amount_valid = true;
1004 data.units = -data.amount;
1005 data.units_valid = true;
1006 data.unitprice = 1.00;
1007 data.unitprice_valid = true;
1008 }
1009 else if (identifier == "CHECKNUM")
1010 {
1011 strncpy(data.check_number, value.c_str(), sizeof(data.check_number));
1012 data.check_number_valid = true;
1013 }
1014 else if (identifier == "REFNUM")
1015 {
1016 strncpy(data.reference_number, value.c_str(), sizeof(data.reference_number));
1017 data.reference_number_valid = true;
1018 }
1019 else if (identifier == "SIC")
1020 {
1021 data.standard_industrial_code = atoi(value.c_str());
1022 data.standard_industrial_code_valid = true;
1023 }
1024 else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
1025 {
1026 strncpy(data.payee_id, value.c_str(), sizeof(data.payee_id));
1027 data.payee_id_valid = true;
1028 }
1029 else if (identifier == "NAME")
1030 {
1031 strncpy(data.name, value.c_str(), sizeof(data.name));
1032 data.name_valid = true;
1033 }
1034 else
1035 {
1036 /* Redirect unknown identifiers to the base class */
1037 OfxTransactionContainer::add_attribute(identifier, value);
1038 }
1039 }//end OfxInvestmentTransactionContainer::add_attribute
1040
OFX_INT
Definition: inc/libofx.h:626
OFX_OTHER
Definition: inc/libofx.h:640
OFX_RETOFCAP
Definition: inc/libofx.h:657
OfxAccountData
An abstraction of an account.
Definition: inc/libofx.h:276
OFX_JRNLSEC
Definition: inc/libofx.h:654
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
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
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
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.
ofx_containers.hh
LibOFX internal object code.
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
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
OFX_CASH
Definition: inc/libofx.h:636
LibofxContext
Definition: build/libofx-0.10.0/lib/context.hh:25
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
REPLACE
Definition: inc/libofx.h:672
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
OfxStatementData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:1072
OFX_BUYMF
Definition: inc/libofx.h:646
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
OFX_CREDIT
Definition: inc/libofx.h:624
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
OfxStatementData::account_ptr
struct OfxAccountData * account_ptr
Definition: inc/libofx.h:1074
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
OFX_BUYOPT
Definition: inc/libofx.h:647
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
OFX_SELLOPT
Definition: inc/libofx.h:660
OfxGenericContainer::type
string type
Definition: build/libofx-0.10.0/lib/ofx_containers.hh:36
OFX_REINVEST
Definition: inc/libofx.h:656
messages.hh
Message IO functionality.
OFX_DEBIT
Definition: inc/libofx.h:625
OFX_XFER
Definition: inc/libofx.h:633
ERROR
Definition: build/libofx-0.10.0/lib/messages.hh:34
OFX_DIV
Definition: inc/libofx.h:627
OFX_INVEXPENSE
Definition: inc/libofx.h:652
OfxStatementData::currency
char currency[OFX_CURRENCY_LENGTH]
Definition: inc/libofx.h:1069
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
OFX_DIRECTDEP
Definition: inc/libofx.h:637
OfxTransactionContainer::gen_event
virtual int gen_event()
Generate libofx.h events.
Definition: build/libofx-0.10.0/lib/ofx_container_transaction.cpp:69