summaryrefslogtreecommitdiff
path: root/register.cc
blob: 3e75eb1324a7075ef5437d1d7849200ca09d483d (plain)
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
#include "register.h"
#include "journal.h"

namespace ledger {

void register_command::print_document(std::ostream&	out,
				      xml::document_t * doc)
{
  value_t nodelist = xml::xpath_t::eval("//transaction", doc);

  value_t::sequence_t * xact_list = nodelist.to_sequence();
  assert(xact_list);

  for (value_t::sequence_t::iterator i = xact_list->begin();
       i != xact_list->end();
       i++) {
    xml::node_t * node = (*i).to_xml_node();
    assert(node);

    xml::transaction_node_t * xact_node =
      dynamic_cast<xml::transaction_node_t *>(node);
    assert(xact_node);

    transaction_t * xact = xact_node->transaction;
    assert(xact);

    std::cout << xact->entry->date() << ' '
	      << std::setw(21) << std::left
	      << abbreviate(xact->entry->payee, 21) << ' '
	      << std::setw(21) << std::left
	      << abbreviate(xact->account->fullname(), 21,
			    ABBREVIATE, true) << ' '
	      << std::setw(12) << std::right
	      << xact->amount
	      << std::endl;
  }
}

} // namespace ledger