diff --git a/dasettings/forms.py b/dasettings/forms.py index b85775c..0e31586 100644 --- a/dasettings/forms.py +++ b/dasettings/forms.py @@ -58,13 +58,15 @@ class AgencyBillPlan(forms.ModelForm): "phone" : "Telefon", "agb" : "AGB akzeptieren", "contract" : "Auftragsdatenverarbeitung akzeptieren" - } - fields = ['name','inhaber','agency_email', 'phone', 'street', 'plz', 'city', 'paymentplan', 'agb', 'contract'] + fields = ['name','inhaber','agency_email', 'phone', 'street', 'plz', 'city', 'paymentplan', 'agb', 'contract', 'lexofficeid', 'firstbillid'] 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) self.fields['inhaber'] = forms.CharField(required=True) diff --git a/dasettings/templates/dasettings/calc_content.html b/dasettings/templates/dasettings/calc_content.html index 37bb399..5ed2d7a 100644 --- a/dasettings/templates/dasettings/calc_content.html +++ b/dasettings/templates/dasettings/calc_content.html @@ -35,10 +35,10 @@
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 %} + {% if paymentplan == None and request.user.profile.agency.firstbillid == None %} 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 diff --git a/dasettings/templates/dasettings/dasettings_billplan.html b/dasettings/templates/dasettings/dasettings_billplan.html index 9d22ced..05e6eb3 100644 --- a/dasettings/templates/dasettings/dasettings_billplan.html +++ b/dasettings/templates/dasettings/dasettings_billplan.html @@ -25,20 +25,26 @@

Wählen Sie aus, für welchen Zeitraum die Abrechnung Ihrer Digitalen Agentur durchgeführt werden soll.

- + +
+
+ +
- 6 Monate
- -
diff --git a/dasettings/views.py b/dasettings/views.py index cbc9760..968cef0 100644 --- a/dasettings/views.py +++ b/dasettings/views.py @@ -242,6 +242,27 @@ def DASettings(request): agencyform = AgencyUpdateForm(instance=request.user.profile.agency) context.update({'agencyform' : agencyform}) + # Abrechnung BILLS + + # TEST ID + # TODO: Hier Rechnungen der Agentur laden + lexdata = {} + + # HEADERS CURL + headers = { + 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + + json_data = json.dumps(lexdata) + + r = requests.get("https://api.lexoffice.io/v1/invoices/ad75e041-1657-43a3-b3cb-7349aa00a94f", data=json_data, headers=headers) + + + + + return render(request, 'dasettings/settings.html', context) ''' @@ -1470,13 +1491,6 @@ class BillPlanUpdate(UpdateView): def form_valid(self, form): agency = self.request.user.profile.agency - # HEADERS CURL - headers = { - 'Authorization': 'Bearer 33bfb1b9-2994-4fd4-b447-1f4754a5c7cb', - 'Content-Type': 'application/json', - 'Accept': 'application/json', - } - month = agency.registerdate next_month = month + relativedelta(months=1) @@ -1490,11 +1504,41 @@ class BillPlanUpdate(UpdateView): else: usercount = usercount - 3 + # HEADERS CURL + headers = { + 'Authorization': 'Bearer 8f9ba01f-9e84-42c7-9548-48c254f14c19', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + + plan = int(form.cleaned_data['paymentplan']) + + start_date = month + start_date_string = month.strftime("%d.%m.%Y") + end_date = month + relativedelta(months=plan) + end_date_string= end_date.strftime("%d.%m.%Y") + + # TODO: Nachgebuchte Mitarbeiter + # TODO: Was passiert bei Änderungen der Agenturdaten? + # TODO: Kündigungsmöglichkeit, den Zahlplan zu beenden # DataJSON + ''' + + Bei Beschreibung noch Zeitraum vom XX.XX.XXXX bis XX.XX.XXXX + + ''' + monthword = "Monate" + if form.cleaned_data['paymentplan'] == "1": + monthword = "Monat" + + lexdata = { - "voucherDate": voucher_date + "T00:00:00.000+01:00", + "voucherDate": voucher_date + "T00:00:00.000+00:00", "address" : { "name" : agency.name, + "street": agency.street, + "zip": agency.plz, + "city": agency.city, "countryCode" : "DE" }, "totalPrice" : { @@ -1503,46 +1547,76 @@ class BillPlanUpdate(UpdateView): "lineItems" : [ { "type" : "custom", - "name" : "Monatsbeitrag", - "quantity" : form.cleaned_data['paymentplan'], - "unitName" : "Stück", + "name" : "Digitale Agentur: Grundbetrag für " + str(plan) + " " + monthword, + "quantity" : 1, + "unitName" : "Anzahl", + "description" : "Zeitraum " + start_date_string + " - " + end_date_string, "unitPrice" : { "currency" : "EUR", - "netAmount" : 21.00, - "taxRatePercentage" : 19 + "netAmount" : 21.00 * int(form.cleaned_data['paymentplan']), + "taxRatePercentage" : 16 }, }, { "type" : "custom", - "name" : "Weitere Mitarbeiter", + "name" : "Digitale Agentur: Zusätzliche Mitarbeiter", + "description" : "Zeitraum " + start_date_string + " - " + end_date_string, "quantity" : usercount, - "unitName" : "Stück", + "unitName" : "Anzahl", "unitPrice" : { "currency" : "EUR", - "netAmount" : 3, - "taxRatePercentage" : 19 + "netAmount" : 3 * int(form.cleaned_data['paymentplan']), + "taxRatePercentage" : 16 }, } ], "taxConditions": { "taxType": "net" }, + "paymentConditions": { + "paymentTermLabel": "Bitte zahlen Sie innerhalb von 14 Tagen.", + "paymentTermDuration": 14, + }, "shippingConditions": { - "shippingDate": voucher_date + "T00:00:00.000+01:00", + "shippingDate": voucher_date + "T00:00:00.000+00:00", "shippingType": "service" }, } json_data = json.dumps(lexdata) - r = requests.post("https://api.lexoffice.io/v1/vouchers", data=json_data, headers=headers) + self.object = form.save(commit=False) - if(r.status_code != 200): + r = requests.post("https://api.lexoffice.io/v1/invoices", data=json_data, headers=headers) + + if(r.status_code == 201): + messages.success(self.request, f"Rechnung erstellt!") + # 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', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + + json_data = json.dumps(lexdata) + + 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"] + + self.object.save() + + else: messages.warning(self.request, f"Fehlercode "+str(r.status_code)+". Es wurde keine Rechnung erstellt. Bitte wenden Sie sich an den Support!") - print(r.status_code) - return super().form_valid(form) diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 189a530..e30a75d 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -1081,7 +1081,18 @@ $(document).ready(function() { $('#id_content').summernote({ height: 400, lang: "de-DE", - disableDragAndDrop: true + disableDragAndDrop: true, + /* TASK: Hier Fontsize zzgl zu den anderen machen, damit das auch geht */ + /* + toolbar: [ + ['style', ['style']], + ['text', ['bold', 'italic', 'underline', 'color', 'clear']], + ['para', ['ul', 'ol', 'paragraph']], + ['height', ['height']], + ['fontsize', ['fontsize']], + ['font', ['fontname']], + ], + */ }); }); diff --git a/standards/templates/standards/standards_update.html b/standards/templates/standards/standards_update.html index e3685d0..d8cfd7d 100644 --- a/standards/templates/standards/standards_update.html +++ b/standards/templates/standards/standards_update.html @@ -827,7 +827,7 @@ $("#id_area").change(function () { $(document).ready(function() { $('#id_content').summernote({ lang: "de-DE", - height: 400, + height: 100, disableDragAndDrop: true }); }); diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index d239154..beb32a1 100644 Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index d889e4e..1c8f2ae 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -715,7 +715,7 @@ def loadMWST(user): else: usercount = usercount - 3 - mwst = (21.0 + usercount*3)/100 * 19 + mwst = (21.0 + usercount*3)/100 * 16 return mwst @@ -728,8 +728,7 @@ def loadFinalMoney(user): else: usercount = usercount - 3 - finalMoney = ((21.0 + usercount*3)/100 * 19) + 21.0 + usercount*3 - + finalMoney = (21.0 + usercount*3) * 1.16 return finalMoney diff --git a/users/models.py b/users/models.py index 0034b03..afc0666 100644 --- a/users/models.py +++ b/users/models.py @@ -98,6 +98,9 @@ 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) diff --git a/users/urls.py b/users/urls.py index cfb2149..890fde2 100644 --- a/users/urls.py +++ b/users/urls.py @@ -39,6 +39,7 @@ urlpatterns = [ path('changeonlinestat/', views.changeonlinestat, name="users-updateonlinestat"), path('dacron/', views.cronactions, name="cronmain"), path('dacrondaily/', views.cronactionsdaily, name="cronmaindaily"), + path('isalive/', views.isAlive, name="isalive") ] diff --git a/users/views.py b/users/views.py index af907e9..4d4d6c4 100644 --- a/users/views.py +++ b/users/views.py @@ -1148,3 +1148,6 @@ def sendMailNoti(notificationtext, user_touched, linktarget=""): html_message=msg_html, fail_silently=True ) + +def isAlive(request): + return JsonResponse({"status" : True})