fixes to main.py
This commit is contained in:
parent
79b664f6f0
commit
a2bbd7dc8f
3 changed files with 47 additions and 4 deletions
18
journal.cc
18
journal.cc
|
|
@ -578,6 +578,9 @@ void export_journal()
|
||||||
class_< transaction_t > ("Transaction")
|
class_< transaction_t > ("Transaction")
|
||||||
.def(init<account_t *, amount_t, optional<unsigned int, std::string> >())
|
.def(init<account_t *, amount_t, optional<unsigned int, std::string> >())
|
||||||
|
|
||||||
|
.def(self == self)
|
||||||
|
.def(self != self)
|
||||||
|
|
||||||
.add_property("entry",
|
.add_property("entry",
|
||||||
make_getter(&transaction_t::entry,
|
make_getter(&transaction_t::entry,
|
||||||
return_value_policy<reference_existing_object>()))
|
return_value_policy<reference_existing_object>()))
|
||||||
|
|
@ -593,6 +596,9 @@ void export_journal()
|
||||||
|
|
||||||
class_< account_t >
|
class_< account_t >
|
||||||
("Account", init<optional<account_t *, std::string, std::string> >())
|
("Account", init<optional<account_t *, std::string, std::string> >())
|
||||||
|
.def(self == self)
|
||||||
|
.def(self != self)
|
||||||
|
|
||||||
.def_readwrite("parent", &account_t::parent)
|
.def_readwrite("parent", &account_t::parent)
|
||||||
.def_readwrite("name", &account_t::name)
|
.def_readwrite("name", &account_t::name)
|
||||||
.def_readwrite("note", &account_t::note)
|
.def_readwrite("note", &account_t::note)
|
||||||
|
|
@ -615,11 +621,18 @@ void export_journal()
|
||||||
;
|
;
|
||||||
|
|
||||||
class_< journal_t > ("Journal")
|
class_< journal_t > ("Journal")
|
||||||
|
.def(self == self)
|
||||||
|
.def(self != self)
|
||||||
|
|
||||||
.def_readonly("sources", &journal_t::sources)
|
.def_readonly("sources", &journal_t::sources)
|
||||||
|
|
||||||
.def("__len__", entries_len)
|
.def("__len__", entries_len)
|
||||||
|
#if 0
|
||||||
.def("__getitem__", entries_getitem, return_internal_reference<1>())
|
.def("__getitem__", entries_getitem, return_internal_reference<1>())
|
||||||
|
#else
|
||||||
|
.def("__getitem__", entries_getitem,
|
||||||
|
return_value_policy<reference_existing_object>())
|
||||||
|
#endif
|
||||||
.def("add_account", &journal_t::add_account)
|
.def("add_account", &journal_t::add_account)
|
||||||
.def("remove_account", &journal_t::remove_account)
|
.def("remove_account", &journal_t::remove_account)
|
||||||
.def("find_account", py_find_account_1, return_internal_reference<1>())
|
.def("find_account", py_find_account_1, return_internal_reference<1>())
|
||||||
|
|
@ -634,6 +647,9 @@ void export_journal()
|
||||||
;
|
;
|
||||||
|
|
||||||
scope in_entry = class_< entry_t > ("Entry")
|
scope in_entry = class_< entry_t > ("Entry")
|
||||||
|
.def(self == self)
|
||||||
|
.def(self != self)
|
||||||
|
|
||||||
.def_readwrite("date", &entry_t::date)
|
.def_readwrite("date", &entry_t::date)
|
||||||
.def_readwrite("state", &entry_t::state)
|
.def_readwrite("state", &entry_t::state)
|
||||||
.def_readwrite("code", &entry_t::code)
|
.def_readwrite("code", &entry_t::code)
|
||||||
|
|
|
||||||
28
ledger.h
28
ledger.h
|
|
@ -62,6 +62,13 @@ class transaction_t
|
||||||
delete cost;
|
delete cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const transaction_t& xact) {
|
||||||
|
return this == &xact;
|
||||||
|
}
|
||||||
|
bool operator!=(const transaction_t& xact) {
|
||||||
|
return ! (*this == xact);
|
||||||
|
}
|
||||||
|
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -96,6 +103,13 @@ class entry_t
|
||||||
(*i)->~transaction_t();
|
(*i)->~transaction_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const entry_t& entry) {
|
||||||
|
return this == &entry;
|
||||||
|
}
|
||||||
|
bool operator!=(const entry_t& entry) {
|
||||||
|
return ! (*this == entry);
|
||||||
|
}
|
||||||
|
|
||||||
void add_transaction(transaction_t * xact);
|
void add_transaction(transaction_t * xact);
|
||||||
bool remove_transaction(transaction_t * xact);
|
bool remove_transaction(transaction_t * xact);
|
||||||
|
|
||||||
|
|
@ -129,6 +143,13 @@ class account_t
|
||||||
|
|
||||||
~account_t();
|
~account_t();
|
||||||
|
|
||||||
|
bool operator==(const account_t& account) {
|
||||||
|
return this == &account;
|
||||||
|
}
|
||||||
|
bool operator!=(const account_t& account) {
|
||||||
|
return ! (*this == account);
|
||||||
|
}
|
||||||
|
|
||||||
std::string fullname() const;
|
std::string fullname() const;
|
||||||
|
|
||||||
void add_account(account_t * acct) {
|
void add_account(account_t * acct) {
|
||||||
|
|
@ -183,6 +204,13 @@ class journal_t
|
||||||
}
|
}
|
||||||
~journal_t();
|
~journal_t();
|
||||||
|
|
||||||
|
bool operator==(const journal_t& journal) {
|
||||||
|
return this == &journal;
|
||||||
|
}
|
||||||
|
bool operator!=(const journal_t& journal) {
|
||||||
|
return ! (*this == journal);
|
||||||
|
}
|
||||||
|
|
||||||
void add_account(account_t * acct) {
|
void add_account(account_t * acct) {
|
||||||
master->add_account(acct);
|
master->add_account(acct);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
main.py
5
main.py
|
|
@ -106,7 +106,8 @@ class FormatTransaction (TransactionHandler):
|
||||||
self.output.flush ()
|
self.output.flush ()
|
||||||
|
|
||||||
def __call__ (self, xact):
|
def __call__ (self, xact):
|
||||||
if self.nformatter is not None and xact.entry is self.last_entry:
|
if self.nformatter is not None and self.last_entry is not None and \
|
||||||
|
xact.entry.payee == self.last_entry.payee:
|
||||||
self.output.write(self.nformatter.format(xact))
|
self.output.write(self.nformatter.format(xact))
|
||||||
else:
|
else:
|
||||||
self.output.write(self.formatter.format(xact))
|
self.output.write(self.formatter.format(xact))
|
||||||
|
|
@ -150,9 +151,7 @@ if 0:
|
||||||
else:
|
else:
|
||||||
# These for loops are equivalent to `walk_entries', but far slower
|
# These for loops are equivalent to `walk_entries', but far slower
|
||||||
for entry in journal:
|
for entry in journal:
|
||||||
#print "1:", entry
|
|
||||||
for xact in entry:
|
for xact in entry:
|
||||||
#print "2:", xact.entry
|
|
||||||
handler (xact)
|
handler (xact)
|
||||||
|
|
||||||
handler.flush ()
|
handler.flush ()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue