E-Mail-Adresse
- Ihre Rechnungen werden automatisch an folgende E-Mailadresse gesendet.
+ Informationen über neue Rechnungen werden automatisch an folgende E-Mailadresse gesendet.
{% if request.user.profile.agency.payment_address == None %}
Es wurde keine Adresse hinterlegt. Die Adresse wird an die Agenturadresse versendet: {{request.user.profile.agency.agency_email}}
{% else %}
@@ -74,6 +76,9 @@
Rechnungen
+ {% if bills|length == 0 %}
+ Es liegen keine Rechnungen vor.
+ {% endif %}
{% for bill in bills %}
Rechnung vom {{bill.billdate|date:"d.m.Y"}} ({{bill.billnumber}}) - {% if bill.billstatus == "open" %} Offen {% elif bill.billstatus == "paid" %} Bezahlt {% endif %}
{% endfor %}
diff --git a/dasettings/templates/dasettings/dasettings_billplan.html b/dasettings/templates/dasettings/dasettings_billplan.html
index 05e6eb3..fc24071 100644
--- a/dasettings/templates/dasettings/dasettings_billplan.html
+++ b/dasettings/templates/dasettings/dasettings_billplan.html
@@ -54,6 +54,7 @@
Mit Klick auf dem Button Jetzt kostenpflichtig bestellen wird eine Rechnung für Ihre Agentur generiert und per E-Mail an die hinterlegte Rechnungs-E-Mailadresse oder an die Agentur-E-Mailadresse versendet. Der Rechnungsbetrag muss innerhalb von 14 Tagen beglichen werden.
+
Beginn des Leistungszeitraums: {{start|date:"d.m.Y"}}
{% loadFinalMoney user as fm %}
Rechnungsbetrag: {{fm|floatformat:2|intcomma}} €
diff --git a/dasettings/urls.py b/dasettings/urls.py
index 6fbd7f6..b169384 100644
--- a/dasettings/urls.py
+++ b/dasettings/urls.py
@@ -3,7 +3,7 @@ from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required, permission_required
from . import views
from .views import FreeDayDeleteView, AbsenceReasonDeleteView, AbsenceReasonUpdateView, AbsenceReasonAddView
-from .views import NewUserFirstStep, UserProfileUpdate, UserChangeMain, BillMailUpdate, BillPlanUpdate, GetBill, GetBillPDF
+from .views import NewUserFirstStep, UserProfileUpdate, UserChangeMain, BillMailUpdate, BillPlanUpdate, GetBill, GetBillPDF, BillPlanEnd
'''
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
'''
@@ -37,5 +37,6 @@ urlpatterns = [
path('ag/billplan/
', permission_required('users.agencyinfo')(BillPlanUpdate.as_view()), name='ag-billplanupdate'),
path('ag/getbill/', permission_required('users.agencyinfo')(GetBill), name='ag-getbill'),
path('ag/getbillpdf/', permission_required('users.agencyinfo')(GetBillPDF), name='ag-getbillpdf'),
+ path('ag/billplanend/', permission_required('users.agencyinfo')(BillPlanEnd.as_view()), name='ag-billplanend'),
]
\ No newline at end of file
diff --git a/dasettings/views.py b/dasettings/views.py
index f9c7898..9f9947f 100644
--- a/dasettings/views.py
+++ b/dasettings/views.py
@@ -1,7 +1,7 @@
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
-from .forms import UsersSelfChangeForm, UsersNotificationFormStandard, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm, UsersNotificationFormNews, UsersNotificationFormFiles, UsersNotificationFormMessages ,UsersNotificationFormOrganizer, UsersNotificationFormChat, UsersNotificationFormAbTime, UsersNotificationFormGroups, UsersNotificationFormAgn, UsersNotificationFormTasks, AgencyBillMail, AgencyBillPlan
+from .forms import UsersSelfChangeForm, UsersNotificationFormStandard, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm, UsersNotificationFormNews, UsersNotificationFormFiles, UsersNotificationFormMessages ,UsersNotificationFormOrganizer, UsersNotificationFormChat, UsersNotificationFormAbTime, UsersNotificationFormGroups, UsersNotificationFormAgn, UsersNotificationFormTasks, AgencyBillMail, AgencyBillPlan, AgencyEndBillPlan
from django.contrib import messages
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.forms import PasswordChangeForm
@@ -33,6 +33,8 @@ from timemanagement.forms import AddFreeDayForm
from django.urls import reverse_lazy
import re
import json
+from django.conf import settings # import the settings file
+
def randomString(stringLength=10):
"""Generate a random string of fixed length """
@@ -250,7 +252,7 @@ def DASettings(request):
# HEADERS CURL
headers = {
- 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
+ 'Authorization': 'Bearer ' + settings.LEX_API,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
@@ -270,7 +272,7 @@ from django.http import FileResponse, Http404
def GetBill(request, pk):
# HEADERS CURL
headers = {
- 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
+ 'Authorization': 'Bearer ' + settings.LEX_API,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
@@ -288,18 +290,15 @@ def GetBill(request, pk):
return render(request, 'dasettings/bill_single.html', context)
-from fpdf import FPDF, HTMLMixin
-class HtmlPdf(FPDF, HTMLMixin):
- pass
-
import io as BytesIO
import base64
from django.http import HttpResponse
+
@login_required
def GetBillPDF(request, pk):
headers = {
- 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
+ 'Authorization': 'Bearer ' + settings.LEX_API,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
@@ -1548,6 +1547,17 @@ def getBill(request, billid):
else:
pass
'''
+class BillPlanEnd(UpdateView):
+ model = Agency
+ success_url = reverse_lazy('dasettings')
+ form_class = AgencyEndBillPlan
+ template_name = "dasettings/bill_removepayplan.html"
+
+ def form_valid(self, form):
+ self.object.paymentplan = None
+ messages.success(self.request, f"Zahlplan abbestellt!")
+
+ return super().form_valid(form)
from dateutil.relativedelta import *
class BillPlanUpdate(UpdateView):
@@ -1561,6 +1571,11 @@ class BillPlanUpdate(UpdateView):
agency = self.request.user.profile.agency
month = agency.registerdate
+
+ # Wenn die Agentur noch KEINE Lexoffice-ID hat, dann ist der Freimonat noch nicht durch.
+ if agency.lexofficeid == "":
+ month = month + relativedelta(months=1)
+
next_month = month + relativedelta(months=1)
voucher_date = next_month.strftime("%Y-%m-%d")
@@ -1575,7 +1590,7 @@ class BillPlanUpdate(UpdateView):
# HEADERS CURL
headers = {
- 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
+ 'Authorization': 'Bearer ' + settings.LEX_API,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
@@ -1591,14 +1606,8 @@ class BillPlanUpdate(UpdateView):
voucher_date_today = date.today().strftime("%Y-%m-%d")
# TODO: Nachgebuchte Mitarbeiter
# TODO: Was passiert bei Änderungen der Agenturdaten?
- # TODO: Kündigungsmöglichkeit, den Zahlplan zu beenden
- # TODO: voucherDate muss HEUTE sein, Leistungszeitraum aber das von der Agenturregistrierung
+
# DataJSON
- '''
-
- Bei Beschreibung noch Zeitraum vom XX.XX.XXXX bis XX.XX.XXXX
-
- '''
monthword = "Monate"
if form.cleaned_data['paymentplan'] == "1":
monthword = "Monat"
@@ -1670,7 +1679,7 @@ class BillPlanUpdate(UpdateView):
# HEADERS CURL
headers = {
- 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
+ 'Authorization': 'Bearer ' + settings.LEX_API,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
@@ -1697,7 +1706,19 @@ class BillPlanUpdate(UpdateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context.update({'active_link' : 'dasettings'})
+
+ # Rechnungsbegin setzen
+ agency = self.request.user.profile.agency
+
+ month = agency.registerdate
+
+ # Wenn die Agentur noch KEINE Lexoffice-ID hat, dann ist der Freimonat noch nicht durch.
+ if agency.lexofficeid == "":
+ month = month + relativedelta(months=1)
+
+
+ context.update({'active_link' : 'dasettings', 'start' : month})
+
return context