Split backend in applications

This commit is contained in:
Edgar P. Burkhart 2023-04-22 11:16:42 +02:00
parent a0d0b5d594
commit b05c3e6760
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
47 changed files with 1463 additions and 866 deletions

View file

@ -0,0 +1,44 @@
from category.models import Category
from main.forms import NummiFileInput, NummiForm
from Statement.models import Statement
from .models import Invoice, Transaction
class TransactionForm(NummiForm):
class Meta:
model = Transaction
fields = [
"statement",
"name",
"value",
"date",
"real_date",
"category",
"trader",
"payment",
"description",
]
def __init__(self, *args, **kwargs):
_user = kwargs.get("user")
_disable_statement = kwargs.pop("disable_statement", False)
super().__init__(*args, **kwargs)
self.fields["category"].queryset = Category.objects.filter(user=_user)
self.fields["statement"].queryset = Statement.objects.filter(user=_user)
if _disable_statement:
self.fields["statement"].disabled = True
class InvoiceForm(NummiForm):
prefix = "invoice"
class Meta:
model = Invoice
fields = [
"name",
"file",
]
widgets = {
"file": NummiFileInput,
}