summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristopherlam <christopher.lck@gmail.com>2017-02-05 12:53:25 +0800
committerGitHub <noreply@github.com>2017-02-05 12:53:25 +0800
commit9de29f5e062e9fcdb05d3b5a2e33cd59c6890df9 (patch)
tree1f13d8994c55d0f15623aaf5c5be3c268e4279d7
parentfbc8db00538deb8f885268f5c9e7793c2e0e16f9 (diff)
Update gnucashxml.py
- Improve ledger output - Add post_date which improves compatibility with https://github.com/sdementen/piecash
-rw-r--r--gnucashxml.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/gnucashxml.py b/gnucashxml.py
index 8450dc2..83be8c2 100644
--- a/gnucashxml.py
+++ b/gnucashxml.py
@@ -61,21 +61,21 @@ class Book(object):
outp.append('\tnamespace {}'.format(comm.space))
outp.append('')
- for account, children, splits in self.walk():
- if account.fullname():
- outp.append('account {}'.format(account.fullname()))
- if account.description:
- outp.append('\tnote {}'.format(account.description))
- outp.append('\tcheck commodity == "{}"'.format(account.commodity))
- outp.append('')
+ for account in self.accounts:
+ outp.append('account {}'.format(account.fullname()))
+ if account.description:
+ outp.append('\tnote {}'.format(account.description))
+ outp.append('\tcheck commodity == "{}"'.format(account.commodity))
+ outp.append('')
for trn in sorted(self.transactions):
outp.append('{:%Y/%m/%d} * {}'.format(trn.date, trn.description))
for spl in trn.splits:
- outp.append('\t{:50} {:12.2f} {} ;{}'.format(spl.account.fullname(), spl.value, spl.account.commodity, spl.memo or ' '))
+ outp.append('\t{:50} {:12.2f} {} {}'.format(spl.account.fullname(), spl.value,
+ spl.account.commodity,
+ '; '+spl.memo if spl.memo else ''))
outp.append('')
-
return '\n'.join(outp)
class Commodity(object):
@@ -166,6 +166,7 @@ class Transaction(object):
self.guid = guid
self.currency = currency
self.date = date
+ self.post_date = date # for compatibility with piecash
self.date_entered = date_entered
self.description = description
self.splits = splits or []