def add_expense(amount, description): expense = ExpenseSchema().load(amount=amount, description=description) db.session.add(expense.data) db.session.commit()
def get_expenses(): schema = ExpenseSchema(many=True) expenses = schema.dump(Expense.query.all()) return expenses.data
def get_expenses(): schema = ExpenseSchema(many=True) expenses = schema.dump( filter(lambda t: t.type == TransactionType.EXPENSE, transactions) ) return jsonify(expenses.data)
def add_expense(): expense = ExpenseSchema().load(request.get_json()) transactions.append(expense.data) return '', 204
def add_expense(): expense = ExpenseSchema().load(request.get_json()) transactions.append(expense) return jsonify({"updated": "true"})