def current_month(): """Shows transactions for current month. So gets or creates month-the-transaction-container.""" month = transactions_utils.get_or_create_current_month(request.user) transactions = month.get_transactions() plus_transactions = float(sum([x.amount for x in \ filter(lambda x: unicode(x.type) == TRANSACTION_TYPE_PLUS, transactions)])) minus_transactions = float(sum([x.amount for x in \ filter(lambda x: unicode(x.type) == TRANSACTION_TYPE_MINUS, transactions)])) balance = plus_transactions - minus_transactions return render_template('transactions/current_month.html', \ month=month, \ transactions=month.get_transactions(), \ balance=balance)
def add_transaction(self, user): """""" month = transactions_utils.get_or_create_current_month(user) month.add_transaction(self.data)