diff --git a/accounting/transport.py b/accounting/transport.py index 4e0e98e9d12ef7b297de2fdc5683dd5d7ed3bccd..d3970843bd17506bb59a3034f4d4ad63db1f1c1e 100644 --- a/accounting/transport.py +++ b/accounting/transport.py @@ -4,6 +4,7 @@ from flask import json from accounting.models import Amount, Transaction, Posting, Account + class AccountingEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, Account): @@ -16,6 +17,7 @@ class AccountingEncoder(json.JSONEncoder): elif isinstance(o, Transaction): return dict( __type__=o.__class__.__name__, + id=o.id, date=o.date.strftime('%Y-%m-%d'), payee=o.payee, postings=o.postings, @@ -42,6 +44,7 @@ class AccountingEncoder(json.JSONEncoder): return json.JSONEncoder.default(self, o) + class AccountingDecoder(json.JSONDecoder): def __init__(self): json.JSONDecoder.__init__(self, object_hook=self.dict_to_object) @@ -50,8 +53,8 @@ class AccountingDecoder(json.JSONDecoder): if '__type__' not in d: return d - types = {c.__name__ : c for c in [Amount, Transaction, Posting, - Account]} + types = {c.__name__: c for c in [Amount, Transaction, Posting, + Account]} _type = d.pop('__type__')