summaryrefslogtreecommitdiff
path: root/item.h
blob: f14e7f8e8b852521f5347299ce9f4fe030ea7b3f (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _REPORT_H
#define _REPORT_H

#include "ledger.h"
#include "balance.h"

#include <deque>

namespace ledger {

struct node_t;
struct item_t;
typedef std::deque<item_t *> items_deque;

struct item_t
{
  struct item_t *   parent;
  unsigned int      index;
  std::time_t       date;
  std::string       payee;
  const account_t * account;
  balance_pair_t    value;
  balance_pair_t    total;

  items_deque       subitems;

  item_t() : parent(NULL), index(0), date(-1), account(NULL) {}

  ~item_t() {
    for (items_deque::iterator i = subitems.begin();
	 i != subitems.end();
	 i++)
      delete *i;
  }

  void sort(const node_t * sort_order);
};

class constraints_t;

item_t * walk_accounts(const account_t *    account,
		       const constraints_t& constraints,
		       const bool           compute_subtotals);

item_t * walk_items(const item_t *	 top,
		    const account_t *	 account,
		    const constraints_t& constraints,
		    const bool		 compute_subtotals);

item_t * walk_entries(entries_list::const_iterator begin,
		      entries_list::const_iterator end,
		      const constraints_t&	   constraints,
		      const format_t&		   format);

} // namespace report

#endif // _REPORT_H