diff options
-rw-r--r-- | gnucashxml.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gnucashxml.py b/gnucashxml.py index 9014d29..0d51300 100644 --- a/gnucashxml.py +++ b/gnucashxml.py @@ -88,8 +88,18 @@ class Account(object): self.splits = [] self.slots = slots or {} + def fullname(self): + if self.parent: + pfn = self.parent.fullname() + if pfn: + return '{}:{}'.format(pfn, self.name) + else: + return self.name + else: + return '' + def __repr__(self): - return "<Account {}>".format(self.guid) + return "<Account '{}' {}...>".format(self.name, self.guid[:10]) def walk(self): """ @@ -137,7 +147,7 @@ class Transaction(object): self.slots = slots or {} def __repr__(self): - return u"<Transaction {}>".format(self.guid) + return "<Transaction on {} '{}' {}...>".format(self.date, self.description, self.guid[:6]) def __lt__(self, other): # For sorted() only @@ -167,7 +177,11 @@ class Split(object): self.slots = slots def __repr__(self): - return "<Split {}>".format(self.guid) + return "<Split {} '{}' {} {} {}...>".format(self.transaction.date, + self.transaction.description, + self.transaction.currency, + self.value, + self.guid[:6]) def __lt__(self, other): # For sorted() only @@ -237,7 +251,7 @@ def _book_from_tree(tree): root_account = acc accountdict[acc.guid] = acc parentdict[acc.guid] = parent_guid - for acc in accountdict.values(): + for acc in list(accountdict.values()): if acc.parent is None and acc.actype != 'ROOT': parent = accountdict[parentdict[acc.guid]] acc.parent = parent @@ -411,8 +425,8 @@ def _slots_from_tree(tree): key = elt.find(slot + "key").text value = elt.find(slot + "value") type_ = value.get('type', 'string') - if type_ == 'integer': - slots[key] = long(value.text) + if type_ in ('integer', 'double'): + slots[key] = int(value.text) elif type_ == 'numeric': slots[key] = _parse_number(value.text) elif type_ in ('string', 'guid'): |