File diff 63c7b70000da → 6f2c875c7b76
accounting/transport.py
Show inline comments
 
from datetime import datetime
 

	
 
from flask import json
 

	
 
from accounting import Amount, Transaction, Posting, Account
...
 
@@ -30,6 +32,11 @@ class AccountingEncoder(json.JSONEncoder):
 
                amount=o.amount,
 
                symbol=o.symbol
 
            )
 
        elif isinstance(o, Exception):
 
            return dict(
 
                __type__=o.__class__.__name__,
 
                args=o.args
 
            )
 

	
 
        return json.JSONEncoder.default(self, o)
 

	
...
 
@@ -46,4 +53,7 @@ class AccountingDecoder(json.JSONDecoder):
 

	
 
        _type = d.pop('__type__')
 

	
 
        if _type == 'Transaction':
 
            d['date'] = datetime.strptime(d['date'], '%Y-%m-%d')
 

	
 
        return types[_type](**d)