diff --git a/dasettings/forms.py b/dasettings/forms.py
index 0e31586..009b71a 100644
--- a/dasettings/forms.py
+++ b/dasettings/forms.py
@@ -59,13 +59,12 @@ class AgencyBillPlan(forms.ModelForm):
"agb" : "AGB akzeptieren",
"contract" : "Auftragsdatenverarbeitung akzeptieren"
}
- fields = ['name','inhaber','agency_email', 'phone', 'street', 'plz', 'city', 'paymentplan', 'agb', 'contract', 'lexofficeid', 'firstbillid']
+ fields = ['name','inhaber','agency_email', 'phone', 'street', 'plz', 'city', 'paymentplan', 'agb', 'contract', 'lexofficeid']
def __init__(self, *args, **kwargs):
super(AgencyBillPlan, self).__init__(*args, **kwargs)
self.fields['paymentplan'] = forms.CharField(initial=6, required=True, widget=forms.HiddenInput())
self.fields['lexofficeid'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
- self.fields['firstbillid'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
self.fields['name'] = forms.CharField(required=True)
diff --git a/dasettings/templates/dasettings/calc_content.html b/dasettings/templates/dasettings/calc_content.html
index 5ed2d7a..a3ae038 100644
--- a/dasettings/templates/dasettings/calc_content.html
+++ b/dasettings/templates/dasettings/calc_content.html
@@ -35,15 +35,15 @@
Ihre Zahlungsweise
{% getNextMonth request.user.profile.agency as nextMonth %}
- {{request.user.profile.agency.firstbillid}}
-
+
Ihre Agentur wurde am {{ request.user.profile.agency.registerdate|date:"d.m.Y" }} registriert.
- {% if paymentplan == None and request.user.profile.agency.firstbillid == None %}
+ {% if paymentplan == "" or request.user.profile.agency.lexofficeid == "" %}
Es wurde noch keine Zahlungsweise ausgewählt. Sie können die Digitale Agentur bis zum {{nextMonth|date:"d.m.Y"}} kostenlos nutzen. Möchten Sie die Digitale Agentur auch nach diesem Zeitraum nutzen, wählen Sie bitte einen Zahlplan aus.
Zahlplan jetzt auswählen
{% else %}
- Zahlungsweise: TODO
+
Ausgewählter Zahlungsplan: {{request.user.profile.agency.paymentplan}} Monat{% if request.user.profile.agency.paymentplan > 1 %}e{% endif %}
+ Zahlplan abbestellen
{% endif %}
Fragen, Hilfe, Kündigung
@@ -72,7 +72,9 @@
diff --git a/dasettings/urls.py b/dasettings/urls.py
index 5ea4fbb..af110d4 100644
--- a/dasettings/urls.py
+++ b/dasettings/urls.py
@@ -35,4 +35,6 @@ urlpatterns = [
path('abcatadd/', AbsenceReasonAddView.as_view(), name="abcat-add"),
path('ag/billmail/update/', permission_required('users.agencyinfo')(BillMailUpdate.as_view()), name='ag-billmailupdate'),
path('ag/billplan/', permission_required('users.agencyinfo')(BillPlanUpdate.as_view()), name='ag-billplanupdate'),
+ #path('ag/getbill/', permission_required('users.agencyinfo')(GetBill), name='ag-getbill'),
+
]
\ No newline at end of file
diff --git a/dasettings/views.py b/dasettings/views.py
index 968cef0..384a0b9 100644
--- a/dasettings/views.py
+++ b/dasettings/views.py
@@ -15,7 +15,7 @@ from django.template.loader import render_to_string
from users.usersforms import UsersPermForm
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import CreateView
-from users.models import Profile, UserNotifications, UserTime
+from users.models import Profile, UserNotifications, UserTime, AgencyBills
from areas.models import Areas
from tasks.models import Tasks
import webcolors
@@ -257,12 +257,15 @@ def DASettings(request):
json_data = json.dumps(lexdata)
- r = requests.get("https://api.lexoffice.io/v1/invoices/ad75e041-1657-43a3-b3cb-7349aa00a94f", data=json_data, headers=headers)
+
+ # Alle Rechnungen der Agentur abfragen
+ context.update({"bills" : AgencyBills.objects.filter(agency=request.user.profile.agency)})
+
+
+ #r = requests.get("https://api.lexoffice.io/v1/invoices/" + AgencyBills.objects.filter(agency=request.user.profile.agency)[0].lexid, data=json_data, headers=headers)
-
-
return render(request, 'dasettings/settings.html', context)
'''
@@ -1477,8 +1480,19 @@ class BillMailUpdate(UpdateView):
context = super().get_context_data(**kwargs)
context.update({'active_link' : 'dasettings'})
return context
+'''
+def getBill(request, billid):
+ if(request.method == "GET"):
+ Bill = AgencyBills.objects.get(billid=billid)
+
+ response = HttpResponse(content_type='text/pdf')
+ response['Content-Disposition'] = 'attachment; filename="RechnungPLATZHALTER.pdf"'
-
+
+ return response
+ else:
+ pass
+'''
from dateutil.relativedelta import *
class BillPlanUpdate(UpdateView):
@@ -1595,7 +1609,8 @@ class BillPlanUpdate(UpdateView):
# Response in JSON umwandeln
response_text = json.loads(r.text)
# Rechnungsidee speichern
- self.object.firstbillid = response_text["id"]
+
+
# HEADERS CURL
headers = {
'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19',
@@ -1604,14 +1619,20 @@ class BillPlanUpdate(UpdateView):
}
json_data = json.dumps(lexdata)
+ newbill_id = response_text["id"]
+
+ # OrganizationId berechnen, wenn noch nicht gesetzt
+ r = requests.get("https://api.lexoffice.io/v1/invoices/" + response_text["id"], data=json_data, headers=headers)
+ response_text = json.loads(r.text)
if len(agency.lexofficeid) == 0:
- # OrganizationId berechnen, wenn noch nicht gesetzt
- r = requests.get("https://api.lexoffice.io/v1/invoices/" + response_text["id"], data=json_data, headers=headers)
-
- response_text = json.loads(r.text)
self.object.lexofficeid = response_text["organizationId"]
+
+
+ newbill = AgencyBills(agency=agency, lexid=newbill_id, billtype="invoice", billnumber=response_text["voucherNumber"])
+ newbill.save()
+
self.object.save()
else:
diff --git a/users/admin.py b/users/admin.py
index 0918076..4cd030c 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -1,5 +1,5 @@
from django.contrib import admin
-from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications
+from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications, AgencyBills
from .priomodel import Prio
from standards.models import StandardCommentRate, StandardComments
from django.contrib.auth.models import Permission
@@ -31,3 +31,4 @@ admin.site.register(FreeDays)
admin.site.register(UserYearAbsenceInfo)
admin.site.register(ChatRoom)
admin.site.register(UserNotifications)
+admin.site.register(AgencyBills)
diff --git a/users/models.py b/users/models.py
index afc0666..f28957a 100644
--- a/users/models.py
+++ b/users/models.py
@@ -98,9 +98,6 @@ class Agency(models.Model):
# ID für die Verbindung mit Lexoffice
lexofficeid = models.CharField(default="", max_length=200, blank=True)
- # First Bill id to retrieve office-organization-id
- firstbillid = models.CharField(default=None, max_length=200, blank=True, null=True)
-
# Bezahlplan 3,6,12 Monate
paymentplan = models.IntegerField(default=None, null=True, blank=True)
@@ -135,11 +132,6 @@ class Agency(models.Model):
vve = models.CharField(default="", max_length=200, blank=True)
-
-
-
-
-
def __str__(self):
return f'{self.name}'
@@ -154,6 +146,19 @@ class Agency(models.Model):
else:
return settings.MEDIA_URL + "ag_default.jpg"
+# Speichern der Rechnungs-ID von LexOffice
+class AgencyBills(models.Model):
+ lexid = models.CharField(max_length=200, default="", null=True, blank=True)
+ agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
+ billtype = models.CharField(default="", max_length=200)
+ billdate = models.DateField(default=timezone.now)
+ billnumber = models.CharField(default="", max_length=200)
+ # TODO: Rechnungsstatus dazu ob offen oder nicht
+
+ def __str__(self):
+ return f'{self.lexid}'
+
+
'''
Class AgencyJob