LibOFX

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, std::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 ASSIGN_STRNCPY(data.account_id, std::string(parent_statement->data.account_id));
61 }
62 }
63 OfxTransactionContainer::~OfxTransactionContainer()
64 {
65
66 }
67
68 int OfxTransactionContainer::gen_event()
69 {
70 if (data.unique_id_valid == true && MainContainer != NULL)
71 {
72 data.security_data_ptr = MainContainer->find_security(data.unique_id);
73 if (data.security_data_ptr != NULL)
74 {
75 data.security_data_valid = true;
76 }
77 }
78 libofx_context->transactionCallback(data);
79 return true;
80 }
81
82 int OfxTransactionContainer::add_to_main_tree()
83 {
84
85 if (MainContainer != NULL)
86 {
87 return MainContainer->add_container(this);
88 }
89 else
90 {
91 return false;
92 }
93 }
94
95
96 void OfxTransactionContainer::add_attribute(const std::string identifier, const std::string value)
97 {
98
99 if (identifier == "DTPOSTED")
100 {
101 ASSIGN(data.date_posted, ofxdate_to_time_t(value));
102 }
103 else if (identifier == "DTUSER")
104 {
105 ASSIGN(data.date_initiated, ofxdate_to_time_t(value));
106 }
107 else if (identifier == "DTAVAIL")
108 {
109 ASSIGN(data.date_funds_available, ofxdate_to_time_t(value));
110 }
111 else if (identifier == "FITID")
112 {
113 ASSIGN_STRNCPY(data.fi_id, value);
114 }
115 else if (identifier == "CORRECTFITID")
116 {
117 ASSIGN_STRNCPY(data.fi_id_corrected, value);
118 }
119 else if (identifier == "CORRECTACTION")
120 {
121 data.fi_id_correction_action_valid = true;
122 if (value == "REPLACE")
123 {
124 data.fi_id_correction_action = REPLACE;
125 }
126 else if (value == "DELETE")
127 {
128 data.fi_id_correction_action = DELETE;
129 }
130 else
131 {
132 data.fi_id_correction_action_valid = false;
133 }
134 }
135 else if ((identifier == "SRVRTID") || (identifier == "SRVRTID2"))
136 {
137 ASSIGN_STRNCPY(data.server_transaction_id, value);
138 }
139 else if (identifier == "MEMO" || identifier == "MEMO2")
140 {
141 ASSIGN_STRNCPY(data.memo, value);
142 }
143 else if (identifier == "CURRENCY")
144 {
145 ASSIGN(data.amounts_are_foreign_currency, false);
146 }
147 else if (identifier == "ORIGCURRENCY")
148 {
149 ASSIGN(data.amounts_are_foreign_currency, true);
150 }
151 else
152 {
153 /* Redirect unknown identifiers to the base class */
154 OfxGenericContainer::add_attribute(identifier, value);
155 }
156 }// end OfxTransactionContainer::add_attribute()
157
158 void OfxTransactionContainer::add_account(OfxAccountData * account_data)
159 {
160 if (account_data->account_id_valid == true)
161 {
162 data.account_ptr = account_data;
163 ASSIGN_STRNCPY(data.account_id, std::string(account_data->account_id));
164 }
165 }
166
167 /***************************************************************************
168 * OfxBankTransactionContainer *
169 ***************************************************************************/
170
171 OfxBankTransactionContainer::OfxBankTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, std::string para_tag_identifier):
172 OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
173 {
174 ;
175 }
176 void OfxBankTransactionContainer::add_attribute(const std::string identifier, const std::string value)
177 {
178 if ( identifier == "TRNTYPE")
179 {
180 data.transactiontype_valid = true;
181 if (value == "CREDIT")
182 {
183 data.transactiontype = OFX_CREDIT;
184 }
185 else if (value == "DEBIT")
186 {
187 data.transactiontype = OFX_DEBIT;
188 }
189 else if (value == "INT")
190 {
191 data.transactiontype = OFX_INT;
192 }
193 else if (value == "DIV")
194 {
195 data.transactiontype = OFX_DIV;
196 }
197 else if (value == "FEE")
198 {
199 data.transactiontype = OFX_FEE;
200 }
201 else if (value == "SRVCHG")
202 {
203 data.transactiontype = OFX_SRVCHG;
204 }
205 else if (value == "DEP")
206 {
207 data.transactiontype = OFX_DEP;
208 }
209 else if (value == "ATM")
210 {
211 data.transactiontype = OFX_ATM;
212 }
213 else if (value == "POS")
214 {
215 data.transactiontype = OFX_POS;
216 }
217 else if (value == "XFER")
218 {
219 data.transactiontype = OFX_XFER;
220 }
221 else if (value == "CHECK")
222 {
223 data.transactiontype = OFX_CHECK;
224 }
225 else if (value == "PAYMENT")
226 {
227 data.transactiontype = OFX_PAYMENT;
228 }
229 else if (value == "CASH")
230 {
231 data.transactiontype = OFX_CASH;
232 }
233 else if (value == "DIRECTDEP")
234 {
235 data.transactiontype = OFX_DIRECTDEP;
236 }
237 else if (value == "DIRECTDEBIT")
238 {
239 data.transactiontype = OFX_DIRECTDEBIT;
240 }
241 else if (value == "REPEATPMT")
242 {
243 data.transactiontype = OFX_REPEATPMT;
244 }
245 else if (value == "OTHER")
246 {
247 data.transactiontype = OFX_OTHER;
248 }
249 else
250 {
251 data.transactiontype_valid = false;
252 }
253 }//end TRANSTYPE
254 else if (identifier == "TRNAMT")
255 {
256 ASSIGN(data.amount, ofxamount_to_double(value));
257 ASSIGN(data.units, -data.amount);
258 ASSIGN(data.unitprice, 1.00);
259 }
260 else if (identifier == "CHECKNUM")
261 {
262 ASSIGN_STRNCPY(data.check_number, value);
263 }
264 else if (identifier == "REFNUM")
265 {
266 ASSIGN_STRNCPY(data.reference_number, value);
267 }
268 else if (identifier == "SIC")
269 {
270 ASSIGN(data.standard_industrial_code, atoi(value.c_str()));
271 }
272 else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
273 {
274 ASSIGN_STRNCPY(data.payee_id, value);
275 }
276 else if (identifier == "NAME")
277 {
278 ASSIGN_STRNCPY(data.name, value);
279 }
280 else
281 {
282 /* Redirect unknown identifiers to base class */
283 OfxTransactionContainer::add_attribute(identifier, value);
284 }
285 }//end OfxBankTransactionContainer::add_attribute
286
287
288 /***************************************************************************
289 * OfxInvestmentTransactionContainer *
290 ***************************************************************************/
291
292 OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, std::string para_tag_identifier):
293 OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
294 {
295 type = "INVESTMENT";
296 ASSIGN(data.transactiontype, OFX_OTHER);
297
298 data.invtransactiontype_valid = true;
299 if (para_tag_identifier == "BUYDEBT")
300 {
301 data.invtransactiontype = OFX_BUYDEBT;
302 }
303 else if (para_tag_identifier == "BUYMF")
304 {
305 data.invtransactiontype = OFX_BUYMF;
306 }
307 else if (para_tag_identifier == "BUYOPT")
308 {
309 data.invtransactiontype = OFX_BUYOPT;
310 }
311 else if (para_tag_identifier == "BUYOTHER")
312 {
313 data.invtransactiontype = OFX_BUYOTHER;
314 }
315 else if (para_tag_identifier == "BUYSTOCK")
316 {
317 data.invtransactiontype = OFX_BUYSTOCK;
318 }
319 else if (para_tag_identifier == "CLOSUREOPT")
320 {
321 data.invtransactiontype = OFX_CLOSUREOPT;
322 }
323 else if (para_tag_identifier == "INCOME")
324 {
325 data.invtransactiontype = OFX_INCOME;
326 }
327 else if (para_tag_identifier == "INVEXPENSE")
328 {
329 data.invtransactiontype = OFX_INVEXPENSE;
330 }
331 else if (para_tag_identifier == "JRNLFUND")
332 {
333 data.invtransactiontype = OFX_JRNLFUND;
334 }
335 else if (para_tag_identifier == "JRNLSEC")
336 {
337 data.invtransactiontype = OFX_JRNLSEC;
338 }
339 else if (para_tag_identifier == "MARGININTEREST")
340 {
341 data.invtransactiontype = OFX_MARGININTEREST;
342 }
343 else if (para_tag_identifier == "REINVEST")
344 {
345 data.invtransactiontype = OFX_REINVEST;
346 }
347 else if (para_tag_identifier == "RETOFCAP")
348 {
349 data.invtransactiontype = OFX_RETOFCAP;
350 }
351 else if (para_tag_identifier == "SELLDEBT")
352 {
353 data.invtransactiontype = OFX_SELLDEBT;
354 }
355 else if (para_tag_identifier == "SELLMF")
356 {
357 data.invtransactiontype = OFX_SELLMF;
358 }
359 else if (para_tag_identifier == "SELLOPT")
360 {
361 data.invtransactiontype = OFX_SELLOPT;
362 }
363 else if (para_tag_identifier == "SELLOTHER")
364 {
365 data.invtransactiontype = OFX_SELLOTHER;
366 }
367 else if (para_tag_identifier == "SELLSTOCK")
368 {
369 data.invtransactiontype = OFX_SELLSTOCK;
370 }
371 else if (para_tag_identifier == "SPLIT")
372 {
373 data.invtransactiontype = OFX_SPLIT;
374 }
375 else if (para_tag_identifier == "TRANSFER")
376 {
377 data.invtransactiontype = OFX_TRANSFER;
378 }
379 else if (para_tag_identifier == "INVBANKTRAN")
380 {
381 data.invtransactiontype = OFX_INVBANKTRAN;
382 }
383 else
384 {
385 message_out(ERROR, "This should not happen, " + para_tag_identifier + " is an unknown investment transaction type");
386 data.invtransactiontype_valid = false;
387 }
388 }
389
390 void OfxInvestmentTransactionContainer::add_attribute(const std::string identifier, const std::string value)
391 {
392 if (identifier == "UNIQUEID")
393 {
394 ASSIGN_STRNCPY(data.unique_id, value);
395 }
396 else if (identifier == "UNIQUEIDTYPE")
397 {
398 ASSIGN_STRNCPY(data.unique_id_type, value);
399 }
400 else if (identifier == "UNITS")
401 {
402 ASSIGN(data.units, ofxamount_to_double(value));
403 }
404 else if (identifier == "UNITPRICE")
405 {
406 ASSIGN(data.unitprice, ofxamount_to_double(value));
407 }
408 else if (identifier == "MKTVAL")
409 {
410 ASSIGN(data.market_value, ofxamount_to_double(value));
411 }
412 else if (identifier == "TOTAL")
413 {
414 ASSIGN(data.amount, ofxamount_to_double(value));
415 }
416 else if (identifier == "CURRATE")
417 {
418 ASSIGN(data.currency_ratio, ofxamount_to_double(value));
419 }
420 else if (identifier == "CURSYM")
421 {
422 ASSIGN_STRNCPY(data.currency, value);
423 }
424 else if (identifier == "DTSETTLE")
425 {
426 ASSIGN(data.date_posted, ofxdate_to_time_t(value));
427 }
428 else if (identifier == "DTTRADE")
429 {
430 ASSIGN(data.date_initiated, ofxdate_to_time_t(value));
431 }
432 else if (identifier == "COMMISSION")
433 {
434 ASSIGN(data.commission, ofxamount_to_double(value));
435 }
436 else if (identifier == "FEES")
437 {
438 ASSIGN(data.fees, ofxamount_to_double(value));
439 }
440 else if (identifier == "OLDUNITS")
441 {
442 ASSIGN(data.oldunits, ofxamount_to_double(value));
443 }
444 else if (identifier == "NEWUNITS")
445 {
446 ASSIGN(data.newunits, ofxamount_to_double(value));
447 }
448 else if (identifier == "ACCRDINT")
449 {
450 ASSIGN(data.accrued_interest, ofxamount_to_double(value));
451 }
452 else if (identifier == "AVGCOSTBASIS")
453 {
454 ASSIGN(data.avg_cost_basis, ofxamount_to_double(value));
455 }
456 else if (identifier == "BUYTYPE" || identifier == "OPTBUYTYPE")
457 {
458 if (value == "BUY")
459 {
460 ASSIGN(data.buy_type, data.OFX_BUY_TYPE_BUY);
461 }
462 else if (value == "BUYTOCOVER")
463 {
464 ASSIGN(data.buy_type, data.OFX_BUY_TYPE_BUYTOCOVER);
465 }
466 else if (value == "BUYTOOPEN")
467 {
468 ASSIGN(data.buy_type, data.OFX_BUY_TYPE_BUYTOOPEN);
469 }
470 else if (value == "BUYTOCLOSE")
471 {
472 ASSIGN(data.buy_type, data.OFX_BUY_TYPE_BUYTOCLOSE);
473 }
474 }
475 else if (identifier == "DENOMINATOR")
476 {
477 ASSIGN(data.denominator, ofxamount_to_double(value));
478 }
479 else if (identifier == "DTPAYROLL")
480 {
481 ASSIGN(data.date_payroll, ofxdate_to_time_t(value));
482 }
483 else if (identifier == "DTPURCHASE")
484 {
485 ASSIGN(data.date_purchase, ofxdate_to_time_t(value));
486 }
487 else if (identifier == "GAIN")
488 {
489 ASSIGN(data.gain, ofxamount_to_double(value));
490 }
491 else if (identifier == "FRACCASH")
492 {
493 ASSIGN(data.cash_for_fractional, ofxamount_to_double(value));
494 }
495 else if (identifier == "INCOMETYPE")
496 {
497 if (value == "CGLONG")
498 {
499 ASSIGN(data.income_type, data.OFX_CGLONG);
500 }
501 else if (value == "CGSHORT")
502 {
503 ASSIGN(data.income_type, data.OFX_CGSHORT);
504 }
505 else if (value == "DIV")
506 {
507 ASSIGN(data.income_type, data.OFX_DIVIDEND);
508 }
509 else if (value == "INTEREST")
510 {
511 ASSIGN(data.income_type, data.OFX_INTEREST);
512 }
513 else if (value == "MISC")
514 {
515 ASSIGN(data.income_type, data.OFX_MISC);
516 }
517 }
518 else if (identifier == "INV401KSOURCE")
519 {
520 if (value == "PRETAX")
521 {
522 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_PRETAX);
523 }
524 else if (value == "AFTERTAX")
525 {
526 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_AFTERTAX);
527 }
528 else if (value == "MATCH")
529 {
530 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_MATCH);
531 }
532 else if (value == "PROFITSHARING")
533 {
534 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_PROFITSHARING);
535 }
536 else if (value == "ROLLOVER")
537 {
538 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_ROLLOVER);
539 }
540 else if (value == "OTHERVEST")
541 {
542 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_OTHERVEST);
543 }
544 else if (value == "OTHERNONVEST")
545 {
546 ASSIGN(data.inv_401k_source, data.OFX_401K_SOURCE_OTHERNONVEST);
547 }
548 }
549 else if (identifier == "LOAD")
550 {
551 ASSIGN(data.load, ofxamount_to_double(value));
552 }
553 else if (identifier == "LOANID")
554 {
555 ASSIGN_STRNCPY(data.loan_id, value);
556 }
557 else if (identifier == "LOANINTEREST")
558 {
559 ASSIGN(data.loan_interest, ofxamount_to_double(value));
560 }
561 else if (identifier == "LOANPRINCIPAL")
562 {
563 ASSIGN(data.loan_principal, ofxamount_to_double(value));
564 }
565 else if (identifier == "MARKDOWN")
566 {
567 ASSIGN(data.markdown, ofxamount_to_double(value));
568 }
569 else if (identifier == "MARKUP")
570 {
571 ASSIGN(data.markup, ofxamount_to_double(value));
572 }
573 else if (identifier == "NUMERATOR")
574 {
575 ASSIGN(data.numerator, ofxamount_to_double(value));
576 }
577 else if (identifier == "OPTACTION")
578 {
579 if (value == "EXERCISE")
580 {
581 ASSIGN(data.opt_action, data.OFX_OPTACTION_EXERCISE);
582 }
583 else if (value == "ASSIGN")
584 {
585 ASSIGN(data.opt_action, data.OFX_OPTACTION_ASSIGN);
586 }
587 else if (value == "EXPIRE")
588 {
589 ASSIGN(data.opt_action, data.OFX_OPTACTION_EXPIRE);
590 }
591 }
592 else if (identifier == "PENALTY")
593 {
594 ASSIGN(data.penalty, ofxamount_to_double(value));
595 }
596 else if (identifier == "POSTYPE")
597 {
598 if (value == "LONG")
599 {
600 ASSIGN(data.pos_type, data.OFX_POSTYPE_LONG);
601 }
602 else if (value == "SHORT")
603 {
604 ASSIGN(data.pos_type, data.OFX_POSTYPE_SHORT);
605 }
606 }
607 else if (identifier == "PRIORYEARCONTRIB")
608 {
609 if (value == "Y")
610 {
611 ASSIGN(data.prior_year_contrib, true);
612 }
613 else if (value == "N")
614 {
615 ASSIGN(data.prior_year_contrib, false);
616 }
617 }
618 else if (identifier == "RELFITID")
619 {
620 ASSIGN_STRNCPY(data.related_fi_tid, value);
621 }
622 else if (identifier == "RELTYPE")
623 {
624 if (value == "SPREAD")
625 {
626 ASSIGN(data.related_type, data.OFX_RELTYPE_SPREAD);
627 }
628 else if (value == "STRADDLE")
629 {
630 ASSIGN(data.related_type, data.OFX_RELTYPE_STRADDLE);
631 }
632 else if (value == "NONE")
633 {
634 ASSIGN(data.related_type, data.OFX_RELTYPE_NONE);
635 }
636 else if (value == "OTHER")
637 {
638 ASSIGN(data.related_type, data.OFX_RELTYPE_OTHER);
639 }
640 }
641 else if (identifier == "SECURED")
642 {
643 if (value == "NAKED")
644 {
645 ASSIGN(data.option_secured, data.OFX_SECURED_NAKED);
646 }
647 else if (value == "COVERED")
648 {
649 ASSIGN(data.option_secured, data.OFX_SECURED_COVERED);
650 }
651 }
652 else if (identifier == "SELLREASON")
653 {
654 if (value == "CALL")
655 {
656 ASSIGN(data.sell_reason, data.OFX_SELLREASON_CALL);
657 }
658 else if (value == "SELL")
659 {
660 ASSIGN(data.sell_reason, data.OFX_SELLREASON_SELL);
661 }
662 else if (value == "MATURITY")
663 {
664 ASSIGN(data.sell_reason, data.OFX_SELLREASON_MATURITY);
665 }
666 }
667 else if (identifier == "SELLTYPE" || identifier == "OPTSELLTYPE")
668 {
669 if (value == "SELL")
670 {
671 ASSIGN(data.sell_type, data.OFX_SELL_TYPE_SELL);
672 }
673 else if (value == "SELLSHORT")
674 {
675 ASSIGN(data.sell_type, data.OFX_SELL_TYPE_SELLSHORT);
676 }
677 else if (value == "SELLTOOPEN")
678 {
679 ASSIGN(data.sell_type, data.OFX_SELL_TYPE_SELLTOOPEN);
680 }
681 else if (value == "SELLTOCLOSE")
682 {
683 ASSIGN(data.sell_type, data.OFX_SELL_TYPE_SELLTOCLOSE);
684 }
685 }
686 else if (identifier == "SHPERCTRCT")
687 {
688 ASSIGN(data.shares_per_cont, ofxamount_to_double(value));
689 }
690 else if (identifier == "STATEWITHHOLDING")
691 {
692 ASSIGN(data.state_withholding, ofxamount_to_double(value));
693 }
694 else if (identifier == "SUBACCTFROM")
695 {
696 if (value == "CASH")
697 {
698 ASSIGN(data.subacct_from, data.OFX_SUBACCT_CASH);
699 }
700 else if (value == "MARGIN")
701 {
702 ASSIGN(data.subacct_from, data.OFX_SUBACCT_MARGIN);
703 }
704 else if (value == "SHORT")
705 {
706 ASSIGN(data.subacct_from, data.OFX_SUBACCT_SHORT);
707 }
708 else if (value == "OTHER")
709 {
710 ASSIGN(data.subacct_from, data.OFX_SUBACCT_OTHER);
711 }
712 }
713 else if (identifier == "SUBACCTFUND")
714 {
715 if (value == "CASH")
716 {
717 ASSIGN(data.subacct_funding, data.OFX_SUBACCT_CASH);
718 }
719 else if (value == "MARGIN")
720 {
721 ASSIGN(data.subacct_funding, data.OFX_SUBACCT_MARGIN);
722 }
723 else if (value == "SHORT")
724 {
725 ASSIGN(data.subacct_funding, data.OFX_SUBACCT_SHORT);
726 }
727 else if (value == "OTHER")
728 {
729 ASSIGN(data.subacct_funding, data.OFX_SUBACCT_OTHER);
730 }
731 }
732 else if (identifier == "SUBACCTSEC")
733 {
734 if (value == "CASH")
735 {
736 ASSIGN(data.subacct_security, data.OFX_SUBACCT_CASH);
737 }
738 else if (value == "MARGIN")
739 {
740 ASSIGN(data.subacct_security, data.OFX_SUBACCT_MARGIN);
741 }
742 else if (value == "SHORT")
743 {
744 ASSIGN(data.subacct_security, data.OFX_SUBACCT_SHORT);
745 }
746 else if (value == "OTHER")
747 {
748 ASSIGN(data.subacct_security, data.OFX_SUBACCT_OTHER);
749 }
750 }
751 else if (identifier == "SUBACCTTO")
752 {
753 if (value == "CASH")
754 {
755 ASSIGN(data.subacct_to, data.OFX_SUBACCT_CASH);
756 }
757 else if (value == "MARGIN")
758 {
759 ASSIGN(data.subacct_to, data.OFX_SUBACCT_MARGIN);
760 }
761 else if (value == "SHORT")
762 {
763 ASSIGN(data.subacct_to, data.OFX_SUBACCT_SHORT);
764 }
765 else if (value == "OTHER")
766 {
767 ASSIGN(data.subacct_to, data.OFX_SUBACCT_OTHER);
768 }
769 }
770 else if (identifier == "TAXES")
771 {
772 ASSIGN(data.taxes, ofxamount_to_double(value));
773 }
774 else if (identifier == "TAXEXEMPT")
775 {
776 if (value == "Y")
777 {
778 ASSIGN(data.tax_exempt, true);
779 }
780 else if (value == "N")
781 {
782 ASSIGN(data.tax_exempt, false);
783 }
784 }
785 else if (identifier == "TFERACTION")
786 {
787 if (value == "IN")
788 {
789 ASSIGN(data.transfer_action, data.OFX_TFERACTION_IN);
790 }
791 else if (value == "OUT")
792 {
793 ASSIGN(data.transfer_action, data.OFX_TFERACTION_OUT);
794 }
795 }
796 else if (identifier == "UNITTYPE")
797 {
798 if (value == "SHARES")
799 {
800 ASSIGN(data.unit_type, data.OFX_UNITTYPE_SHARES);
801 }
802 else if (value == "CURRENCY")
803 {
804 ASSIGN(data.unit_type, data.OFX_UNITTYPE_CURRENCY);
805 }
806 }
807 else if (identifier == "WITHHOLDING")
808 {
809 ASSIGN(data.withholding, ofxamount_to_double(value));
810 }
811 /* the following fields are <STMTTRN> elements for <INVBANKTRAN> */
812 else if ( identifier == "TRNTYPE")
813 {
814 data.transactiontype_valid = true;
815 if (value == "CREDIT")
816 {
817 data.transactiontype = OFX_CREDIT;
818 }
819 else if (value == "DEBIT")
820 {
821 data.transactiontype = OFX_DEBIT;
822 }
823 else if (value == "INT")
824 {
825 data.transactiontype = OFX_INT;
826 }
827 else if (value == "DIV")
828 {
829 data.transactiontype = OFX_DIV;
830 }
831 else if (value == "FEE")
832 {
833 data.transactiontype = OFX_FEE;
834 }
835 else if (value == "SRVCHG")
836 {
837 data.transactiontype = OFX_SRVCHG;
838 }
839 else if (value == "DEP")
840 {
841 data.transactiontype = OFX_DEP;
842 }
843 else if (value == "ATM")
844 {
845 data.transactiontype = OFX_ATM;
846 }
847 else if (value == "POS")
848 {
849 data.transactiontype = OFX_POS;
850 }
851 else if (value == "XFER")
852 {
853 data.transactiontype = OFX_XFER;
854 }
855 else if (value == "CHECK")
856 {
857 data.transactiontype = OFX_CHECK;
858 }
859 else if (value == "PAYMENT")
860 {
861 data.transactiontype = OFX_PAYMENT;
862 }
863 else if (value == "CASH")
864 {
865 data.transactiontype = OFX_CASH;
866 }
867 else if (value == "DIRECTDEP")
868 {
869 data.transactiontype = OFX_DIRECTDEP;
870 }
871 else if (value == "DIRECTDEBIT")
872 {
873 data.transactiontype = OFX_DIRECTDEBIT;
874 }
875 else if (value == "REPEATPMT")
876 {
877 data.transactiontype = OFX_REPEATPMT;
878 }
879 else if (value == "OTHER")
880 {
881 data.transactiontype = OFX_OTHER;
882 }
883 else
884 {
885 data.transactiontype_valid = false;
886 }
887 }//end TRANSTYPE
888 else if (identifier == "TRNAMT")
889 {
890 ASSIGN(data.amount, ofxamount_to_double(value));
891 ASSIGN(data.units, -data.amount);
892 ASSIGN(data.unitprice, 1.00);
893 }
894 else if (identifier == "CHECKNUM")
895 {
896 ASSIGN_STRNCPY(data.check_number, value);
897 }
898 else if (identifier == "REFNUM")
899 {
900 ASSIGN_STRNCPY(data.reference_number, value);
901 }
902 else if (identifier == "SIC")
903 {
904 ASSIGN(data.standard_industrial_code, atoi(value.c_str()));
905 }
906 else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2"))
907 {
908 ASSIGN_STRNCPY(data.payee_id, value);
909 }
910 else if (identifier == "NAME")
911 {
912 ASSIGN_STRNCPY(data.name, value);
913 }
914 else
915 {
916 /* Redirect unknown identifiers to the base class */
917 OfxTransactionContainer::add_attribute(identifier, value);
918 }
919 }//end OfxInvestmentTransactionContainer::add_attribute
920
OfxTransactionData::fi_id
char fi_id[OFX_FITID_LENGTH]
Definition: inc/libofx.h:737
OfxTransactionData::gain
double gain
Definition: inc/libofx.h:879
OfxGenericContainer::type
std::string type
Definition: ofx_containers.hh:41
OfxTransactionData::unitprice
double unitprice
Definition: inc/libofx.h:727
ASSIGN
#define ASSIGN(DEST, VALUE)
Definition: ofx_utilities.hh:45
OfxTransactionData::markup
double markup
Definition: inc/libofx.h:924
OfxTransactionData::commission
double commission
Definition: inc/libofx.h:819
OfxTransactionData::account_ptr
struct OfxAccountData * account_ptr
Definition: inc/libofx.h:704
OfxTransactionContainer::gen_event
virtual int gen_event()
Generate libofx.h events.
Definition: ofx_container_transaction.cpp:68
OFX_BUYSTOCK
@ OFX_BUYSTOCK
Definition: inc/libofx.h:660
OfxTransactionData::fees
double fees
Definition: inc/libofx.h:822
OFX_CLOSUREOPT
@ OFX_CLOSUREOPT
Definition: inc/libofx.h:661
ASSIGN_STRNCPY
#define ASSIGN_STRNCPY(DEST, VALUE)
Definition: ofx_utilities.hh:52
OfxTransactionContainer::add_to_main_tree
virtual int add_to_main_tree()
Add this container to the main tree.
Definition: ofx_container_transaction.cpp:82
OfxAccountData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:301
OfxTransactionData::shares_per_cont
double shares_per_cont
Definition: inc/libofx.h:997
OFX_FEE
@ OFX_FEE
Definition: inc/libofx.h:639
OfxTransactionData::payee_id
char payee_id[OFX_SVRTID2_LENGTH]
Definition: inc/libofx.h:809
OfxAccountData
An abstraction of an account.
Definition: inc/libofx.h:287
OfxMainContainer
The root container. Created by the <OFX> OFX element or by the export functions.
Definition: ofx_containers.hh:289
OfxTransactionData::market_value
double market_value
Definition: inc/libofx.h:832
OFX_DEP
@ OFX_DEP
Definition: inc/libofx.h:641
OfxTransactionData::amount
double amount
Definition: inc/libofx.h:731
OfxTransactionData::state_withholding
double state_withholding
Definition: inc/libofx.h:1001
OfxTransactionData::OFX_INTEREST
@ OFX_INTEREST
Definition: inc/libofx.h:891
OFX_POS
@ OFX_POS
Definition: inc/libofx.h:643
ERROR
@ ERROR
Definition: messages.hh:41
OFX_RETOFCAP
@ OFX_RETOFCAP
Definition: inc/libofx.h:668
OFX_XFER
@ OFX_XFER
Definition: inc/libofx.h:644
OFX_DEBIT
@ OFX_DEBIT
Definition: inc/libofx.h:636
OfxTransactionData::cash_for_fractional
double cash_for_fractional
Definition: inc/libofx.h:882
OFX_INT
@ OFX_INT
Definition: inc/libofx.h:637
OfxTransactionData::penalty
double penalty
Definition: inc/libofx.h:939
OfxTransactionData::OFX_SELLREASON_CALL
@ OFX_SELLREASON_CALL
Definition: inc/libofx.h:979
OfxTransactionData::fi_id_correction_action
FiIdCorrectionAction fi_id_correction_action
Definition: inc/libofx.h:786
OfxTransactionData::server_transaction_id
char server_transaction_id[OFX_SVRTID2_LENGTH]
Definition: inc/libofx.h:791
OfxTransactionData::prior_year_contrib
int prior_year_contrib
Definition: inc/libofx.h:951
OfxTransactionData::name
char name[OFX_TRANSACTION_NAME_LENGTH]
Definition: inc/libofx.h:812
OFX_REPEATPMT
@ OFX_REPEATPMT
Definition: inc/libofx.h:650
OfxTransactionData::fi_id_corrected
char fi_id_corrected[OFX_FITID_LENGTH]
Definition: inc/libofx.h:781
OFX_JRNLFUND
@ OFX_JRNLFUND
Definition: inc/libofx.h:664
OfxTransactionData::newunits
double newunits
Definition: inc/libofx.h:828
OFX_SELLDEBT
@ OFX_SELLDEBT
Definition: inc/libofx.h:669
OfxTransactionData::date_posted
time_t date_posted
Definition: inc/libofx.h:758
OfxTransactionData::tax_exempt
int tax_exempt
Definition: inc/libofx.h:1022
OfxTransactionData::oldunits
double oldunits
Definition: inc/libofx.h:825
OFX_SELLOTHER
@ OFX_SELLOTHER
Definition: inc/libofx.h:672
OFX_CHECK
@ OFX_CHECK
Definition: inc/libofx.h:645
OFX_CREDIT
@ OFX_CREDIT
Definition: inc/libofx.h:635
ofx_utilities.hh
Various simple functions for type conversion & al.
OFX_SELLMF
@ OFX_SELLMF
Definition: inc/libofx.h:670
DELETE
@ DELETE
Definition: inc/libofx.h:681
OFX_BUYDEBT
@ OFX_BUYDEBT
Definition: inc/libofx.h:656
OfxTransactionData::currency_ratio
double currency_ratio
Definition: inc/libofx.h:840
OfxGenericContainer
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
Definition: ofx_containers.hh:31
OfxGenericContainer::add_attribute
virtual void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
Definition: ofx_container_generic.cpp:57
OfxStatementData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:1083
ofxamount_to_double
double ofxamount_to_double(const std::string ofxamount)
Convert OFX amount of money to double float.
Definition: ofx_utilities.cpp:130
OfxTransactionData::numerator
double numerator
Definition: inc/libofx.h:927
OFX_INCOME
@ OFX_INCOME
Definition: inc/libofx.h:662
OfxTransactionData::avg_cost_basis
double avg_cost_basis
Definition: inc/libofx.h:856
OfxTransactionData::account_id
char account_id[OFX_ACCOUNT_ID_LENGTH]
Definition: inc/libofx.h:701
LibofxContext
Definition: context.hh:23
OfxTransactionData::loan_principal
double loan_principal
Definition: inc/libofx.h:918
OfxBankTransactionContainer::add_attribute
void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
Definition: ofx_container_transaction.cpp:176
ofx_containers.hh
LibOFX internal object code.
message_out
int message_out(OfxMsgType error_type, const std::string message)
Message output function.
Definition: messages.cpp:67
OFX_CASH
@ OFX_CASH
Definition: inc/libofx.h:647
OfxTransactionData::memo
char memo[OFX_MEMO2_LENGTH]
Definition: inc/libofx.h:816
OFX_BUYOTHER
@ OFX_BUYOTHER
Definition: inc/libofx.h:659
OfxTransactionData::denominator
double denominator
Definition: inc/libofx.h:870
OfxTransactionData::withholding
double withholding
Definition: inc/libofx.h:1042
OfxTransactionData::OFX_CGSHORT
@ OFX_CGSHORT
Definition: inc/libofx.h:889
ofxdate_to_time_t
time_t ofxdate_to_time_t(const std::string &ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
Definition: ofx_utilities.cpp:68
OfxTransactionData::security_data_valid
int security_data_valid
Definition: inc/libofx.h:756
REPLACE
@ REPLACE
Definition: inc/libofx.h:683
OfxTransactionData::currency
char currency[OFX_CURRENCY_LENGTH]
Definition: inc/libofx.h:836
OfxTransactionData::reference_number
char reference_number[OFX_REFERENCE_NUMBER_LENGTH]
Definition: inc/libofx.h:802
OfxTransactionData::unique_id_type
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
Definition: inc/libofx.h:751
OFX_INVEXPENSE
@ OFX_INVEXPENSE
Definition: inc/libofx.h:663
OfxTransactionData::amounts_are_foreign_currency
int amounts_are_foreign_currency
Definition: inc/libofx.h:846
OfxTransactionData::taxes
double taxes
Definition: inc/libofx.h:1018
OFX_SELLSTOCK
@ OFX_SELLSTOCK
Definition: inc/libofx.h:673
OfxTransactionData::OFX_DIVIDEND
@ OFX_DIVIDEND
Definition: inc/libofx.h:890
OfxInvestmentTransactionContainer::add_attribute
void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
Definition: ofx_container_transaction.cpp:390
OFX_DIV
@ OFX_DIV
Definition: inc/libofx.h:638
OfxTransactionData::OFX_MISC
@ OFX_MISC
Definition: inc/libofx.h:892
OFX_TRANSFER
@ OFX_TRANSFER
Definition: inc/libofx.h:675
OFX_BUYMF
@ OFX_BUYMF
Definition: inc/libofx.h:657
OFX_MARGININTEREST
@ OFX_MARGININTEREST
Definition: inc/libofx.h:666
OfxTransactionData::date_initiated
time_t date_initiated
Definition: inc/libofx.h:765
OfxStatementContainer
Represents a statement for either a bank account or a credit card account.
Definition: ofx_containers.hh:155
OfxTransactionData::OFX_SELLREASON_SELL
@ OFX_SELLREASON_SELL
Definition: inc/libofx.h:980
OfxTransactionData::standard_industrial_code
long int standard_industrial_code
Definition: inc/libofx.h:805
OfxTransactionData::transactiontype_valid
int transactiontype_valid
Definition: inc/libofx.h:709
OFX_DIRECTDEP
@ OFX_DIRECTDEP
Definition: inc/libofx.h:648
OfxTransactionData::accrued_interest
double accrued_interest
Definition: inc/libofx.h:853
OfxTransactionData::loan_id
char loan_id[OFX_LOANID_LENGTH]
Definition: inc/libofx.h:912
OFX_INVBANKTRAN
@ OFX_INVBANKTRAN
Definition: inc/libofx.h:676
OFX_DIRECTDEBIT
@ OFX_DIRECTDEBIT
Definition: inc/libofx.h:649
OFX_ATM
@ OFX_ATM
Definition: inc/libofx.h:642
OFX_JRNLSEC
@ OFX_JRNLSEC
Definition: inc/libofx.h:665
OfxTransactionContainer
Represents a generic transaction.
Definition: ofx_containers.hh:243
OFX_BUYOPT
@ OFX_BUYOPT
Definition: inc/libofx.h:658
OfxTransactionData::OFX_CGLONG
@ OFX_CGLONG
Definition: inc/libofx.h:888
OfxTransactionData::loan_interest
double loan_interest
Definition: inc/libofx.h:915
OfxTransactionData::load
double load
Definition: inc/libofx.h:909
OfxTransactionData::check_number
char check_number[OFX_CHECK_NUMBER_LENGTH]
Definition: inc/libofx.h:797
OFX_REINVEST
@ OFX_REINVEST
Definition: inc/libofx.h:667
OFX_SPLIT
@ OFX_SPLIT
Definition: inc/libofx.h:674
OFX_SRVCHG
@ OFX_SRVCHG
Definition: inc/libofx.h:640
OfxTransactionData::units
double units
Definition: inc/libofx.h:724
OfxTransactionData::date_funds_available
time_t date_funds_available
Definition: inc/libofx.h:773
OfxTransactionData::unique_id
char unique_id[OFX_UNIQUE_ID_LENGTH]
Definition: inc/libofx.h:749
OFX_OTHER
@ OFX_OTHER
Definition: inc/libofx.h:651
OFX_SELLOPT
@ OFX_SELLOPT
Definition: inc/libofx.h:671
OfxTransactionData::date_payroll
time_t date_payroll
Definition: inc/libofx.h:873
OfxTransactionData::date_purchase
time_t date_purchase
Definition: inc/libofx.h:876
OfxTransactionData::markdown
double markdown
Definition: inc/libofx.h:921
OfxTransactionData::OFX_SELLREASON_MATURITY
@ OFX_SELLREASON_MATURITY
Definition: inc/libofx.h:981
messages.hh
Message IO functionality.
OfxTransactionData::related_fi_tid
char related_fi_tid[OFX_FITID_LENGTH]
Definition: inc/libofx.h:955
OfxTransactionContainer::add_attribute
virtual void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
Definition: ofx_container_transaction.cpp:96
OFX_PAYMENT
@ OFX_PAYMENT
Definition: inc/libofx.h:646