blob: 44b372fe3826a6a1c9995c9b5df2bb352d97484f (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include "emacs.h"
namespace ledger {
void format_emacs_transactions::write_entry(entry_t& entry)
{
int idx = entry.src_idx;
for (paths_list::const_iterator i = entry.journal->sources.begin();
i != entry.journal->sources.end();
i++)
if (! idx--) {
out << "\"" << *i << "\" ";
break;
}
out << (((unsigned long)entry.beg_line) + 1) << " ";
tm when = boost::posix_time::to_tm(entry.date());
std::time_t date = std::mktime(&when); // jww (2008-04-20): Is this GMT or local?
out << "(" << (date / 65536) << " " << (date % 65536) << " 0) ";
if (! entry.code)
out << "nil ";
else
out << "\"" << *entry.code << "\" ";
if (entry.payee.empty())
out << "nil";
else
out << "\"" << entry.payee << "\"";
out << "\n";
}
void format_emacs_transactions::operator()(transaction_t& xact)
{
if (! transaction_has_xdata(xact) ||
! (transaction_xdata_(xact).dflags & TRANSACTION_DISPLAYED)) {
if (! last_entry) {
out << "((";
write_entry(*xact.entry);
}
else if (xact.entry != last_entry) {
out << ")\n (";
write_entry(*xact.entry);
}
else {
out << "\n";
}
out << " (" << (((unsigned long)xact.beg_line) + 1) << " ";
out << "\"" << xact_account(xact)->fullname() << "\" \""
<< xact.amount << "\"";
switch (xact.state) {
case transaction_t::CLEARED:
out << " t";
break;
case transaction_t::PENDING:
out << " pending";
break;
default:
out << " nil";
break;
}
if (xact.cost)
out << " \"" << *xact.cost << "\"";
if (xact.note)
out << " \"" << *xact.note << "\"";
out << ")";
last_entry = xact.entry;
transaction_xdata(xact).dflags |= TRANSACTION_DISPLAYED;
}
}
} // namespace ledger
|