from django import forms
from models import Transaction
from main.fields import CurrencyField

class TransactionForm(forms.ModelForm):
	""" ModelForm for :class:`Transactions <Transaction>` with a currency field """
	amount = CurrencyField(label='Betrag')
	class Meta:
		model = Transaction
		exclude = ('user', 'dateTime', 'checked')
	def clean_amount(self):
		data = self.cleaned_data['amount']
		return data
	def clean(self):
		cleaned_data = super(TransactionForm, self).clean()
		self.instance.checked = not cleaned_data['transactionType'].needsCheck
		return cleaned_data
