diff --git a/adm/templates/adm/adm_bills.html b/adm/templates/adm/adm_bills.html
index 710ac96..f60cec2 100644
--- a/adm/templates/adm/adm_bills.html
+++ b/adm/templates/adm/adm_bills.html
@@ -32,8 +32,12 @@
{{ele.start|date:"d.m.Y"}} |
{{ele.end|date:"d.m.Y"}} |
- {% loadFinalMoneyByAgency ele.agency as fm %}
- {{fm|floatformat:2|intcomma}} €
+ {% loadBillValue ele as fm %}
+ {% if fm != False %}
+ {{fm|floatformat:2|intcomma}} €
+ {% else %}
+ Fehler bei Rechnungsabfrage (ID {{ele.pk}})
+ {% endif %}
|
{% if ele.billstatus == "open" %} {% elif ele.billstatus == "paid" %} {% endif %}
diff --git a/adm/templates/adm/adm_main.html b/adm/templates/adm/adm_main.html
index 1ecc459..22ddcc8 100644
--- a/adm/templates/adm/adm_main.html
+++ b/adm/templates/adm/adm_main.html
@@ -14,6 +14,26 @@
+
+Monatliche Umsätze
+
+
+ | Monat |
+ Umsatz |
+
+ {% for m in money %}
+
+ |
+ {{m.salesmonthdate|date:"m/Y"}}
+ |
+
+ {{m.value}} €
+ |
+
+ {% endfor %}
+
+
+
Zahlenübersicht stand jetzt
diff --git a/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc b/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc
index 926b2d5..f89fc6b 100644
Binary files a/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc and b/adm/templatetags/__pycache__/adm_tags.cpython-38.pyc differ
diff --git a/adm/templatetags/adm_tags.py b/adm/templatetags/adm_tags.py
index f40c4de..b90475e 100644
--- a/adm/templatetags/adm_tags.py
+++ b/adm/templatetags/adm_tags.py
@@ -11,8 +11,9 @@ from datetime import date
import datetime
from adm.models import MainStatistic
register = template.Library()
-
-
+import requests
+from django.conf import settings
+import json
'''
Agenturdaten zurückgeben
@@ -43,3 +44,33 @@ def getAgencyGroupName(group):
@register.simple_tag
def loadAboCount():
return len(Agency.objects.filter(paymentplan=1))
+
+# Return an Tax-Free Value of bill
+@register.simple_tag
+def loadBillValue(bill):
+ headers = {
+ 'Authorization': 'Bearer ' + settings.LEX_API,
+ 'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ }
+
+ lexdata = {
+ "renderType" : "pdf"
+ }
+
+ json_data = json.dumps(lexdata)
+
+ returnvalue = False
+ try:
+ r_final = requests.get("https://api.lexoffice.io/v1/invoices/"+bill.lexid, data=json_data, headers=headers)
+ billdata = json.loads(r_final.text)
+ returnvalue = billdata['totalPrice']['totalNetAmount']
+ except:
+ pass
+
+ return returnvalue
+
+
+
+
+
diff --git a/adm/views.py b/adm/views.py
index 27474d2..548a99f 100644
--- a/adm/views.py
+++ b/adm/views.py
@@ -4,7 +4,7 @@ from django.shortcuts import render, redirect, reverse
from django.urls import reverse_lazy
from django.conf import settings
from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
-from .models import MainStatistic
+from .models import MainStatistic, MainSalesMonth
from django.contrib.auth.models import User
from chat.models import ChatMessage
from users.models import Agency, AgencyBills, RegNotfallhilfe
@@ -28,6 +28,7 @@ import requests
from django.template.loader import render_to_string
from cloud.models import DataFile
import math
+import requests
'''
Prüfung, ob angemeldeter User Mitarbeiterstatus hat. IMMER PER DISPATCH EINBAUEN!
'''
@@ -106,7 +107,8 @@ class AdmMain(TemplateView):
"agencycount" : len(Agency.objects.all()),
"usercount" : len(User.objects.all().exclude(is_staff=True, is_superuser=True)),
"standardcount" : len(Standards.objects.all()),
- "chatmessagescount" : len(ChatMessage.objects.all())
+ "chatmessagescount" : len(ChatMessage.objects.all()),
+ "money" : MainSalesMonth.objects.all(),
})
return context
@@ -489,17 +491,16 @@ def statisticCronJob(request, code):
# COUNT INVOICES WHEN FIRST DAY OF MONTH
lastmonth = today - timedelta(days=today.day)
-
- #if today.day == 1:
- if today.day == 28:
+ monthvalue = 0.0
+ if today.day == 1:
for bill in AgencyBills.objects.filter(billdate__month=lastmonth.month):
- pass
- # TASK: Hier den Rechungsbeitrag abfragen und aufaddieren, dazu bitte einmal Rechnungen aus der Prod abfragen ;)
-
-
-
-
+
+ newvalue = getLexOfficeBill(bill.lexid)
+ if newvalue != False:
+ monthvalue += newvalue
+ nm = MainSalesMonth(value=monthvalue)
+ nm.save()
newMainS = MainStatistic(agencys=agencycount,users=usercount,standards=standardcount,chatmessages=chatmesscount, active_abos=abocount, absenceobjects=absenceobjects, user_active_timemanagement=user_active_timemanagement, organizerobjects=organizerobjects, agency_recoverobjects=agency_recoverobjects, allfiles=allfiles, allfiles_storage=allfiles_storage, logins=logins)
newMainS.save()
@@ -509,7 +510,29 @@ def statisticCronJob(request, code):
data.update({"status" : "failed"})
return JsonResponse(data)
-
+# Return an Tax-Free Value of bill
+def getLexOfficeBill(billid):
+ headers = {
+ 'Authorization': 'Bearer ' + settings.LEX_API,
+ 'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ }
+
+ lexdata = {
+ "renderType" : "pdf"
+ }
+
+ json_data = json.dumps(lexdata)
+
+ returnvalue = False
+ try:
+ r_final = requests.get("https://api.lexoffice.io/v1/invoices/"+billid, data=json_data, headers=headers)
+ billdata = json.loads(r_final.text)
+ returnvalue = billdata['totalPrice']['totalNetAmount']
+ except:
+ pass
+
+ return returnvalue
diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc
index c76f70b..a766d22 100644
Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ
diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc
index e62d98e..ea266a4 100644
Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ
|