From 9de29f5e062e9fcdb05d3b5a2e33cd59c6890df9 Mon Sep 17 00:00:00 2001 From: christopherlam Date: Sun, 5 Feb 2017 12:53:25 +0800 Subject: Update gnucashxml.py - Improve ledger output - Add post_date which improves compatibility with https://github.com/sdementen/piecash --- gnucashxml.py | 19 ++++++++++--------- 1 file 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 [] -- cgit v1.2.3