# Path: banking/transactions/models.py
# class Category(models.Model):
#     name = models.CharField(max_length=50)
#     budget = models.ForeignKey('budget.Budget')
#     slug = models.SlugField(unique=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         super(Category, self).save()
# 
#     def __str__(self):
#         return self.slug


from django import forms
from .models import Category
from budget.models import Budget, MonthlyBudget
import datetime


DIRECTION_CHOICES=(
    ("O", "Out"),
    ("I", "In"),
)

class AddTransactionForm(forms.Form):
    date = forms.DateField( widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'size': '10', 'data-start-week-day': "0"}))
    budget = forms.CharField()
    beneficiary = forms.CharField()
    category = forms.CharField()
    amount = forms.DecimalField(max_digits=65, decimal_places=2, localize=True, widget=forms.TextInput(attrs={'size': '6'}))
    direction = forms.ChoiceField(widget=forms.RadioSelect, choices=DIRECTION_CHOICES, initial="O")

    def __init__(self, *args, **kwargs): #Need to overide the init so that the modelchoice queryset will update each time the form loads
        super(AddTransactionForm, self).__init__(*args, **kwargs)
        self.fields['budget'] = forms.ModelChoiceField(queryset=Budget.objects.all(), required=False)

# Path: banking/transactions/models.py
# class Category(models.Model):
#     name = models.CharField(max_length=50)
#     budget = models.ForeignKey('budget.Budget')
#     slug = models.SlugField(unique=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         super(Category, self).save()
# 
#     def __str__(self):
#         return self.slug


# Path: banking/transactions/forms.py
from django import forms
from .models import Category
from budget.models import Budget, MonthlyBudget
import datetime



DIRECTION_CHOICES=(
    ("O", "Out"),
    ("I", "In"),
)

class AddTransactionForm(forms.Form):
    date = forms.DateField( widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'size': '10', 'data-start-week-day': "0"}))
    budget = forms.CharField()
    beneficiary = forms.CharField()
    category = forms.CharField()
    amount = forms.DecimalField(max_digits=65, decimal_places=2, localize=True, widget=forms.TextInput(attrs={'size': '6'}))
    direction = forms.ChoiceField(widget=forms.RadioSelect, choices=DIRECTION_CHOICES, initial="O")

    def __init__(self, *args, **kwargs): #Need to overide the init so that the modelchoice queryset will update each time the form loads
        super(AddTransactionForm, self).__init__(*args, **kwargs)
        self.fields['budget'] = forms.ModelChoiceField(queryset=Budget.objects.all(), required=False)

        self.fields['category'] = forms.ModelChoiceField(queryset=Category.objects.all(), required=False)