from marshmallow import post_load from .transaction import Transaction, TransactionSchema from .transaction_type import TransactionType class Expense(Transaction): def __init__(self, description, amount): super(Expense, self).__init__(description, -abs(amount), TransactionType.EXPENSE) def __repr__(self): return '<Expense(name={self.description!r})>'.format(self=self) class ExpenseSchema(TransactionSchema): @post_load def make_expense(self, data): return Expense(**data)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter