| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- from django import forms
- from django.contrib.auth.models import User
- from django.core.exceptions import ValidationError
- from expenses.models import (
- Category,
- Expense,
- MultiplePaymentExepense,
- LoneExpense,
- RawExpense,
- )
- class CategoryForm(forms.ModelForm):
- class Meta:
- model = Category
- fields = "__all__"
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- class ExpenseForm(forms.Form):
- is_multiple_payment = forms.BooleanField(
- label="Is mulptiple payment", initial=False
- )
- class MultiplePaymentExepenseForm(forms.ModelForm):
- class Meta:
- model = MultiplePaymentExepense
- fields = (
- "name",
- "date",
- "amount",
- "number_of_payment",
- "category",
- "source",
- )
- first_payment_amount = forms.DecimalField(max_digits=10, decimal_places=2)
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- class SubExpenseForm(forms.ModelForm):
- class Meta:
- model = RawExpense
- fields = ("amount",)
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- class LoneExpenseForm(forms.ModelForm):
- class Meta:
- model = LoneExpense
- fields = (
- "name",
- "date",
- "amount",
- "category",
- "source",
- )
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
|