# Path: banking/budget/models.py
# class Budget(models.Model):
#     name = models.CharField(max_length=50)
#     slug = models.SlugField(unique=True)
# 
#     def __str__(self):
#         return self.slug
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         super(Budget, self).save()
# 
# class MonthlyBudget(models.Model):
#     budget = models.ForeignKey('Budget')
#     month = models.DateField()
#     planned = models.DecimalField(max_digits=65, decimal_places=2)
#     actual = models.DecimalField(max_digits=65, decimal_places=2, blank=True, null=True)
#     slug = models.SlugField(unique=True)
# 
#     def __str__(self):
#         return self.slug
# 
#     def save(self, *args, **kwargs):
#         forslug = "{0.budget}-{0.month}".format(self)
#         self.slug = slugify(forslug)
#         super(MonthlyBudget, self).save()
# 
# Path: banking/budget/forms.py
# class AddMonthlyBudget(forms.Form):
#     budget = forms.CharField(widget=forms.TextInput(attrs={'size': '15'}))
#     amount = forms.DecimalField(max_digits=65, decimal_places=2, widget=forms.TextInput(attrs={'size': '6'}))
#     starting_month = forms.DateField(widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'size': '10', 'data-start-week-day': "0"}))
#     duration = forms.ChoiceField(widget=forms.RadioSelect, choices=DURATION_CHOICES)
# 
# class FilterForm(forms.Form):
#     month = forms.DateField(widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'data-start-week-day': "0"}))


from django.shortcuts import render
from django.views.generic import View, CreateView, UpdateView
from django.db.models import Sum
from .models import Budget, MonthlyBudget
from transactions.models import Transaction
from .forms import AddMonthlyBudget, FilterForm
import datetime


class MonthlyBudgetOverview(View):

    def get(self, request):
        budget_form = AddMonthlyBudget(prefix='budget_form')
        filter_form = FilterForm(prefix='filter_form')
        now = datetime.datetime.now()

# Path: banking/budget/models.py
# class Budget(models.Model):
#     name = models.CharField(max_length=50)
#     slug = models.SlugField(unique=True)
# 
#     def __str__(self):
#         return self.slug
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         super(Budget, self).save()
# 
# class MonthlyBudget(models.Model):
#     budget = models.ForeignKey('Budget')
#     month = models.DateField()
#     planned = models.DecimalField(max_digits=65, decimal_places=2)
#     actual = models.DecimalField(max_digits=65, decimal_places=2, blank=True, null=True)
#     slug = models.SlugField(unique=True)
# 
#     def __str__(self):
#         return self.slug
# 
#     def save(self, *args, **kwargs):
#         forslug = "{0.budget}-{0.month}".format(self)
#         self.slug = slugify(forslug)
#         super(MonthlyBudget, self).save()
# 
# Path: banking/budget/forms.py
# class AddMonthlyBudget(forms.Form):
#     budget = forms.CharField(widget=forms.TextInput(attrs={'size': '15'}))
#     amount = forms.DecimalField(max_digits=65, decimal_places=2, widget=forms.TextInput(attrs={'size': '6'}))
#     starting_month = forms.DateField(widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'size': '10', 'data-start-week-day': "0"}))
#     duration = forms.ChoiceField(widget=forms.RadioSelect, choices=DURATION_CHOICES)
# 
# class FilterForm(forms.Form):
#     month = forms.DateField(widget=forms.TextInput(attrs={'class': 'ink-datepicker', 'data-start-week-day': "0"}))


# Path: banking/budget/views.py
from django.shortcuts import render
from django.views.generic import View, CreateView, UpdateView
from django.db.models import Sum
from .models import Budget, MonthlyBudget
from transactions.models import Transaction
from .forms import AddMonthlyBudget, FilterForm
import datetime



class MonthlyBudgetOverview(View):

    def get(self, request):
        budget_form = AddMonthlyBudget(prefix='budget_form')
        filter_form = FilterForm(prefix='filter_form')
        now = datetime.datetime.now()

        monthlybudgets = MonthlyBudget.objects.filter(month__year=now.year, month__month=now.month)