be gathered during reporting. Removed the references to accounts and such from the mask logic, which means that the value expression "acount =~ /foo/" is needed in place of just "/foo/".
78 lines
1.6 KiB
C++
78 lines
1.6 KiB
C++
#include "emacs.h"
|
|
|
|
namespace ledger {
|
|
|
|
void format_emacs_xacts::write_entry(entry_t& entry)
|
|
{
|
|
int idx = entry.src_idx;
|
|
foreach (const path& path, entry.journal->sources)
|
|
if (! idx--) {
|
|
out << "\"" << path << "\" ";
|
|
break;
|
|
}
|
|
|
|
out << (static_cast<unsigned long>(entry.beg_line) + 1) << " ";
|
|
|
|
tm when = gregorian::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_xacts::operator()(xact_t& xact)
|
|
{
|
|
if (! xact.has_xdata() ||
|
|
! xact.xdata().has_flags(XACT_EXT_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 << " (" << (static_cast<unsigned long>(xact.beg_line) + 1) << " ";
|
|
out << "\"" << xact.reported_account()->fullname() << "\" \""
|
|
<< xact.amount << "\"";
|
|
|
|
switch (xact.state) {
|
|
case xact_t::CLEARED:
|
|
out << " t";
|
|
break;
|
|
case xact_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;
|
|
|
|
xact.xdata().add_flags(XACT_EXT_DISPLAYED);
|
|
}
|
|
}
|
|
|
|
} // namespace ledger
|