Abrechnung
This commit is contained in:
parent
4e3f916ffb
commit
8b106c569c
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@
|
|||
<h5 class="card-title">Ihre Zahlungsweise</h5>
|
||||
|
||||
{% 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.
|
||||
<br />
|
||||
<a href="{% url 'ag-billplanupdate' request.user.profile.agency.pk %}" class="btn btn-primary btn mt-2" onclick="">Zahlplan jetzt auswählen</a>
|
||||
{% else %}
|
||||
Zahlungsweise: TODO
|
||||
<br />Ausgewählter Zahlungsplan: {{request.user.profile.agency.paymentplan}} Monat{% if request.user.profile.agency.paymentplan > 1 %}e{% endif %} <br />
|
||||
<a href="#" class="btn btn-primary btn mt-2" onclick="">Zahlplan abbestellen</a>
|
||||
{% endif %}
|
||||
<hr>
|
||||
<h5 class="card-title.">Fragen, Hilfe, Kündigung</h5>
|
||||
|
|
@ -72,7 +72,9 @@
|
|||
<div class="card d-block mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Rechnungen</h5>
|
||||
|
||||
{% for bill in bills %}
|
||||
<a href="{{bill.lexid}}">Rechnung vom {{bill.billdate|date:"d.m.Y"}} (Nr. {{bill.billnumber}})</a><br />
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ urlpatterns = [
|
|||
path('abcatadd/', AbsenceReasonAddView.as_view(), name="abcat-add"),
|
||||
path('ag/billmail/update/<int:pk>', permission_required('users.agencyinfo')(BillMailUpdate.as_view()), name='ag-billmailupdate'),
|
||||
path('ag/billplan/<int:pk>', permission_required('users.agencyinfo')(BillPlanUpdate.as_view()), name='ag-billplanupdate'),
|
||||
#path('ag/getbill/<slug:billid>', permission_required('users.agencyinfo')(GetBill), name='ag-getbill'),
|
||||
|
||||
]
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue