Skip to content
Snippets Groups Projects
Commit e819f322 authored by Frank Poetzsch-Heffter's avatar Frank Poetzsch-Heffter
Browse files

view and template for reports, some changes in models, view booking archive

parent 5d2c658d
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -27,11 +27,11 @@ class CheckBookingForm(forms.ModelForm):
fields = ('account', )
class BookBookingForm(forms.ModelForm):
accounts = Account.objects.filter().order_by('costcenter','name')
user = User.objects.filter()
description = forms.CharField(label='Beschreibung')
planned_amount = forms.IntegerField(label='Erwarteter Betrag (ganze Euro)')
justification = forms.CharField(label='Begründung', required=False)
accounts = Account.objects.filter().order_by('costcenter','name')
user = User.objects.filter()
description = forms.CharField(label='Beschreibung')
planned_amount = forms.IntegerField(label='Erwarteter Betrag (ganze Euro)')
justification = forms.CharField(label='Begründung', required=False)
account = forms.ModelChoiceField(queryset=accounts, label='Buchungskonto')
contact = forms.ModelChoiceField(queryset=user, label='Kontakt')
invoice_date = forms.DateField(label='Rechnungsdatum')
......@@ -57,7 +57,7 @@ class BookBookingForm(forms.ModelForm):
class Meta:
model = Booking
fields = ('id', 'description', 'planned_amount', 'justification','account', 'contact', 'invoice_date',
fields = ('id', 'description', 'planned_amount', 'justification', 'account', 'contact', 'invoice_date',
'invoice_number', 'firma', 'amount', 'submission_date', 'payout_number', 'booking_date',
'maturity', 'upload', 'status')
......@@ -74,16 +74,17 @@ class EditCostcenterForm(forms.ModelForm):
class EditAccountForm(forms.ModelForm):
name = forms.CharField(max_length=30, label='Buchungskonto')
costcenterlist = Costcenter.objects.filter()
costcenter = forms.ModelChoiceField(queryset=costcenterlist, label='Kostenstelle')
budget = forms.IntegerField(label='Budget')
name = forms.CharField(max_length=30, label='Buchungskonto')
costcenterlist = Costcenter.objects.filter()
costcenter = forms.ModelChoiceField(queryset=costcenterlist, label='Kostenstelle')
income = forms.BooleanField(label='Budget-/Einnanhmekonto', required=False)
budget = forms.IntegerField(label='Budget')
layout = Layout(Row('name', 'costcenter', 'budget'))
layout = Layout(Row('name', 'costcenter', 'income', 'budget'))
class Meta:
model = Account
fields = ('id', 'name', 'costcenter', 'budget')
fields = ('id', 'name', 'costcenter', 'income', 'budget')
#
......
from django.db import models
from django.contrib.auth.models import User
YEARLIST = [(2019,'2019'),
(2020,'2020'),
YEARLIST = [(2020,'2020'),
(2021,'2021'),
(2022,'2022'),
(2023,'2023')]
......@@ -20,7 +19,8 @@ status_list = [
Status(name='beantragt', style_class='red'),
Status(name='bewilligt', style_class='orange'),
Status(name='abgelehnt', style_class='black'),
Status(name='bestellt', style_class='yellow'),
Status(name='bestellt', style_class='darkyellow'),
Status(name='eingereicht', style_class='blue'),
Status(name='bezahlt', style_class='green'),
]
......@@ -29,7 +29,7 @@ status_choices = [(x, val.name) for x, val in enumerate(status_list)]
class Costcenter(models.Model):
# Kostenstellen z.B. Schoolträger-konsumtiv, Schulträger-investiv, Elternberein, ...
# Kostenstellen z.B. Schulträger-konsumtiv, Schulträger-investiv, Elternverein, ...
name = models.CharField(max_length=30)
year = models.IntegerField(default=2019, choices=YEARLIST, verbose_name="Jahr")
def __str__(self):
......@@ -44,6 +44,7 @@ class Account(models.Model):
# Buchungskonten, z.B. Fachschaften, Sekretariat, Schulleiter, Kopieren, Tafelnutzung
name = models.CharField(max_length=20, default='')
costcenter = models.ForeignKey(to=Costcenter, on_delete=models.CASCADE, default='')
income = models.BooleanField(default=False) # True, wenn es sich um ein Einnahmekonto handelt
budget = models.DecimalField(max_digits=9, decimal_places=2, default=0.00)
saldo = models.DecimalField(max_digits=9, decimal_places=2, default=0.00)
rest = models.DecimalField(max_digits=9, decimal_places=2, default=0.00)
......
......@@ -7,7 +7,7 @@
{% block content %}
<h4>Buchungskonten</h4>
<h4>Neues Buchungskonto</h4>
<form method="POST" style="border-width: 5px; background: #eee;">
{% csrf_token %}
{% form form=form %}
......@@ -21,10 +21,15 @@
<div class="collection">
{% for account in accounts %}
<div class="collection-item row">
<span class="col s12 m6">{{ account.name }}</span>
<span class="col s12 m2">{{ account.costcenter }}</span>
<span class="col s12 m2 right-align">{{ account.budget }}</span>
<span class="col s12 m2 right-align">
<span class="col s6 m6">{{ account.name }}</span>
<span class="col s2 m2">{{ account.costcenter }}</span>
{% if account.income %}
<span class="col s1 m1 right-align">{{ account.budget }}</span>
<span class="col s1 m1 right-align"></span>
{% else %}
<span class="col s2 m2 right-align">{{ account.budget }}</span>
{% endif %}
<span class="col s2 m2 right-align">
<form action="{% url 'account_edit' account.id %}" class="left">
{% csrf_token %}
<input type="hidden" value="{{ account.id }}" name="account-id">
......
......@@ -13,7 +13,7 @@
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Änderungen übernehmen
</button>
<a href="{% url 'booking' %}">
<a href="{% url 'booking' 0 %}">
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
......
......@@ -3,11 +3,17 @@
<main>
{% block content %}
<a href="{% url 'new_booking' %}" class="waves-effect waves-light btn green right">Neue Buchung anlegen</a>
<span class="right" style="width: 20px;">&nbsp;</span>
{% if archiv %}
<a href="{% url 'booking' 0 %}" class="waves-effect waves-light btn grey right">Zur aktuellen Übersicht</a>
{% else %}
<a href="{% url 'booking' 1 %}" class="waves-effect waves-light btn grey right">Zum Archiv</a>
{% endif %}
<h4>Buchungen</h4>
<div class="collection">
{% for booking in bookings %}
<a href="/fibu/booking/{{ booking.id }}" class="collection-item row">
<a href="/fibu/booking/book/{{ booking.id }}" class="collection-item row">
<span class="col s5 m5">{{ booking.description }}</span>
<span class="col s1 m1 right-align">{{ booking.planned_amount }} €</span>
<span class="col s3 m3">{{ booking.account }}</span>
......
{% include 'partials/header.html' %}
{% load material_form %}
<main>
<h4>Neue Buchung</h4>
<form method="POST" style="background: #eee">
{% csrf_token %}
{% form form=form %}
{% endform %}
<span class="right">
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Buchung anlegen
</button>
<a href="{% url 'booking' %}">
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
</a>
</span>
</form>
</main>
{% include 'partials/footer.html' %}
......@@ -5,7 +5,7 @@
{% block content %}
<h4>Kostenstellen</h4>
<h4>Neue Kostenstelle</h4>
<form method="POST" style="border-width: 5px; background: #eee;">
{% csrf_token %}
{% form form=form %}
......
......@@ -12,18 +12,24 @@
<h5 class="collection-item">{{ costcenter }}</h5>
<div class="collection">
<div class="collection-item row">
<span class="col s4 m4 ">Buchungskonto</span>
<span class="col s2 m2 right-align">zugeteiltes Budget</span>
<span class="col s2 m2 right-align">bisherige Ausgaben</span>
<span class="col s2 m2 right-align">verfügbare Reste</span>
<div class="row">
<span class="col s5 m5 white-text grey">Buchungskonto</span>
<span class="col s2 m2 white-text grey right-align">Budget</span>
<span class="col s1 m1 white-text grey right-align">Einnahmen</span>
<span class="col s1 m1 white-text grey right-align">Ausgaben</span>
<span class="col s1 m1 white-text grey right-align">Reste</span>
</div>
{% for account in accounts %}
<div class="collection-item row">
<span class="col s4 m4">{{ account.name }}</span>
<span class="col s5 m5">{{ account.name }}</span>
<span class="col s2 m2 right-align">{{ account.budget }}</span>
<span class="col s2 m2 right-align">{{ account.saldo }}</span>
<span class="col s2 m2 right-align">{{ account.rest }}</span>
<span class="col s1 m1 right-align">
{% if account.income %}{{ account.saldo }}{% endif %}
</span>
<span class="col s1 m1 right-align">
{% if not account.income %}{{ account.saldo }}{% endif %}
</span>
<span class="col s1 m1 right-align">{{ account.rest }}</span>
</div>
{% endfor %}
</div>
......
{% include 'partials/header.html' %}
{% load material_form %}
<main>
{% block content %}
<h4>Berichte</h4>
<div class="collection">
<a href="reports/expenses" class="collection-item">Ausgaben</a>
</div>
{% endblock %}
</main>
{% include 'partials/footer.html' %}
......@@ -6,13 +6,15 @@ urlpatterns = [
path('', views.index, name='fibu_index'),
path('booking/check', views.check, name='booking_check'),
path('booking/edit/<int:id>', views.edit, name='booking_edit'),
path('booking', views.booking, name='booking'),
path('booking/<int:id>', views.book, name='booking_book'),
path('booking/new', views.new_booking, name='new_booking'),
path('booking/<int:archiv>', views.booking, name='booking'),
path('booking/book/<int:id>', views.book, name='booking_book'),
path('costcenter', views.costcenter, name='costcenter'),
path('costcenter/edit/<int:id>', views.costcenter_edit, name='costcenter_edit'),
path('account', views.account, name='account'),
path('account/edit/<int:id>', views.account_edit, name='account_edit'),
path('account/final', views.final_account, name='final_account'),
path('reports', views.reports, name='reports'),
path('reports/expenses', views.expenses, name='expenses'),
# path('make_booking', views.make_booking, name='fibu_make_booking'),
# path('edit/<int:id>', views.edit, name='booking_edit'),
]
......@@ -49,7 +49,8 @@ def index(request):
# a.save()
# return redirect('fibu_make_booking')
return redirect('fibu_index')
bookings = Booking.objects.filter()
bookings = Booking.objects.filter().order_by('status')
context = {'bookings': bookings, 'form': form}
return render(request, 'fibu/index.html', context)
......@@ -110,9 +111,12 @@ def check(request):
@login_required
# @permission_required('fibu.book_booking')
def booking(request):
bookings = Booking.objects.filter()
context = {'bookings': bookings}
def booking(request, archiv):
if archiv:
bookings = Booking.objects.filter(status=5).order_by('-status')
else:
bookings = Booking.objects.filter(status__lt=5).order_by('-status')
context = {'bookings': bookings, 'archiv': archiv}
return render(request, 'fibu/booking/index.html', context)
@login_required
......@@ -134,6 +138,24 @@ def book(request, id):
context = {'form': form}
return render(request, template, context)
@login_required
#@permission_required('fibu.book_booking')
def new_booking(request):
form = BookBookingForm()
template = 'fibu/booking/new.html'
if request.method == 'POST':
form = BookBookingForm(request.POST, request.FILES)
if form.is_valid():
form.save()
# a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung verändert",
# description="Sie haben Ihren Antrag auf Unterrichtsbefreiung " +
# "für den Zeitraum von {} bis {} bearbeitet.".format(
# aub.from_date, aub.to_date), app=AubConfig.verbose_name)
# a.save()
return redirect(reverse('booking'))
context = {'form': form}
return render(request, template, context)
@login_required
#@permission_required('fibu.view_booking')
......@@ -221,8 +243,9 @@ def account(request):
if form.is_valid():
name = form.cleaned_data['name']
costcenter = form.cleaned_data['costcenter']
income = form.cleaned_data['income']
budget = form.cleaned_data['budget']
account = Account(name=name, costcenter=costcenter, budget=budget)
account = Account(name=name, costcenter=costcenter, income=income, budget=budget)
account.save()
# a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt",
......@@ -261,7 +284,12 @@ def account_edit(request, id):
@login_required
#@permission_required('fibu.view_booking')
def final_account(request):
def reports(request):
return render(request, 'fibu/reports/index.html')
@login_required
#@permission_required('fibu.view_booking')
def expenses(request):
costcenterlist = Costcenter.objects.filter()
costcenter_accounts = {}
account_rests = {}
......@@ -271,12 +299,15 @@ def final_account(request):
for account in accounts:
saldo = Booking.objects.filter(account=account).aggregate(Sum('amount'))
saldo = saldo['amount__sum']
rest = account.budget - saldo
try:
rest = account.budget - saldo
except:
rest = 0
try:
Account.objects.filter(id=account.id).update(saldo=saldo, rest=rest)
except:
Account.objects.filter(id=account.id).update(saldo=0, rest=0)
costcenter_accounts[costcenter.name] = list(Account.objects.filter(costcenter=costcenter))
costcenter_accounts[costcenter.name] = list(Account.objects.filter(costcenter=costcenter).order_by('-income'))
context = {'costcenter_accounts': costcenter_accounts, 'account_rests': account_rests}
return render(request, 'fibu/account/final.html', context)
return render(request, 'fibu/reports/expenses.html', context)
......@@ -187,8 +187,8 @@
<li class="url-booking_check">
<a href="{% url 'booking_check' %}"><i class="material-icons">done</i>Anträge</a>
</li>
<li class="url-booking_book">
<a href="{% url 'booking' %}"><i class="material-icons">done</i>Buchungen</a>
<li class="url-booking">
<a href="{% url 'booking' 0 %}"><i class="material-icons">done</i>Buchungen</a>
</li>
<li class="url-costcenter">
<a href="{% url 'costcenter' %}"><i class="material-icons">done</i>Kostenstellen</a>
......@@ -196,8 +196,8 @@
<li class="url-account">
<a href="{% url 'account' %}"><i class="material-icons">done</i>Buchungskonten</a>
</li>
<li class="url-accountindex">
<a href="{% url 'final_account' %}"><i class="material-icons">done</i>Schlussrechnung</a>
<li class="url-reports url-expenses">
<a href="{% url 'reports' %}"><i class="material-icons">done</i>Berichte</a>
</li>
</ul>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment