Rechnungen an API abfragen, Monatliche Statistik für Umsatz
This commit is contained in:
parent
9ae3d75fe0
commit
9034360452
|
|
@ -32,8 +32,12 @@
|
||||||
<td>{{ele.start|date:"d.m.Y"}}</td>
|
<td>{{ele.start|date:"d.m.Y"}}</td>
|
||||||
<td>{{ele.end|date:"d.m.Y"}}</td>
|
<td>{{ele.end|date:"d.m.Y"}}</td>
|
||||||
<td>
|
<td>
|
||||||
{% loadFinalMoneyByAgency ele.agency as fm %}
|
{% loadBillValue ele as fm %}
|
||||||
{{fm|floatformat:2|intcomma}} €
|
{% if fm != False %}
|
||||||
|
{{fm|floatformat:2|intcomma}} €
|
||||||
|
{% else %}
|
||||||
|
Fehler bei Rechnungsabfrage (ID {{ele.pk}})
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if ele.billstatus == "open" %} <i class="far fa-times-circle" style="color: red"></i> {% elif ele.billstatus == "paid" %} <i class="far fa-check-circle" style="color: green"></i> {% endif %}
|
{% if ele.billstatus == "open" %} <i class="far fa-times-circle" style="color: red"></i> {% elif ele.billstatus == "paid" %} <i class="far fa-check-circle" style="color: green"></i> {% endif %}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,26 @@
|
||||||
<div class="chart-container" style="">
|
<div class="chart-container" style="">
|
||||||
<canvas id="all_stats"></canvas>
|
<canvas id="all_stats"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<h5>Monatliche Umsätze</h5>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<td style="min-width: 80px;">Monat</td>
|
||||||
|
<td>Umsatz</td>
|
||||||
|
</thead>
|
||||||
|
{% for m in money %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{m.salesmonthdate|date:"m/Y"}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{m.value}} €
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<h5>Zahlenübersicht stand jetzt</h5>
|
<h5>Zahlenübersicht stand jetzt</h5>
|
||||||
<table>
|
<table>
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -11,8 +11,9 @@ from datetime import date
|
||||||
import datetime
|
import datetime
|
||||||
from adm.models import MainStatistic
|
from adm.models import MainStatistic
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
import requests
|
||||||
|
from django.conf import settings
|
||||||
|
import json
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Agenturdaten zurückgeben
|
Agenturdaten zurückgeben
|
||||||
|
|
@ -43,3 +44,33 @@ def getAgencyGroupName(group):
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def loadAboCount():
|
def loadAboCount():
|
||||||
return len(Agency.objects.filter(paymentplan=1))
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
47
adm/views.py
47
adm/views.py
|
|
@ -4,7 +4,7 @@ from django.shortcuts import render, redirect, reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
|
from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
|
||||||
from .models import MainStatistic
|
from .models import MainStatistic, MainSalesMonth
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from chat.models import ChatMessage
|
from chat.models import ChatMessage
|
||||||
from users.models import Agency, AgencyBills, RegNotfallhilfe
|
from users.models import Agency, AgencyBills, RegNotfallhilfe
|
||||||
|
|
@ -28,6 +28,7 @@ import requests
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from cloud.models import DataFile
|
from cloud.models import DataFile
|
||||||
import math
|
import math
|
||||||
|
import requests
|
||||||
'''
|
'''
|
||||||
Prüfung, ob angemeldeter User Mitarbeiterstatus hat. IMMER PER DISPATCH EINBAUEN!
|
Prüfung, ob angemeldeter User Mitarbeiterstatus hat. IMMER PER DISPATCH EINBAUEN!
|
||||||
'''
|
'''
|
||||||
|
|
@ -106,7 +107,8 @@ class AdmMain(TemplateView):
|
||||||
"agencycount" : len(Agency.objects.all()),
|
"agencycount" : len(Agency.objects.all()),
|
||||||
"usercount" : len(User.objects.all().exclude(is_staff=True, is_superuser=True)),
|
"usercount" : len(User.objects.all().exclude(is_staff=True, is_superuser=True)),
|
||||||
"standardcount" : len(Standards.objects.all()),
|
"standardcount" : len(Standards.objects.all()),
|
||||||
"chatmessagescount" : len(ChatMessage.objects.all())
|
"chatmessagescount" : len(ChatMessage.objects.all()),
|
||||||
|
"money" : MainSalesMonth.objects.all(),
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
@ -489,17 +491,16 @@ def statisticCronJob(request, code):
|
||||||
|
|
||||||
# COUNT INVOICES WHEN FIRST DAY OF MONTH
|
# COUNT INVOICES WHEN FIRST DAY OF MONTH
|
||||||
lastmonth = today - timedelta(days=today.day)
|
lastmonth = today - timedelta(days=today.day)
|
||||||
|
monthvalue = 0.0
|
||||||
#if today.day == 1:
|
if today.day == 1:
|
||||||
if today.day == 28:
|
|
||||||
for bill in AgencyBills.objects.filter(billdate__month=lastmonth.month):
|
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 = 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()
|
newMainS.save()
|
||||||
|
|
@ -509,7 +510,29 @@ def statisticCronJob(request, code):
|
||||||
data.update({"status" : "failed"})
|
data.update({"status" : "failed"})
|
||||||
return JsonResponse(data)
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue