mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-29 16:12:26 +00:00
Facture pdf depuis une facture
This commit is contained in:
parent
26f5965a6a
commit
61733e991c
5 changed files with 30 additions and 6 deletions
|
@ -14,6 +14,9 @@ class Facture(models.Model):
|
||||||
prix = Vente.objects.all().filter(facture=self).aggregate(models.Sum('prix'))['prix__sum']
|
prix = Vente.objects.all().filter(facture=self).aggregate(models.Sum('prix'))['prix__sum']
|
||||||
return prix
|
return prix
|
||||||
|
|
||||||
|
def prix_total(self):
|
||||||
|
return self.prix()*self.number
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
name = ' - '.join(vente.name for vente in Vente.objects.all().filter(facture=self))
|
name = ' - '.join(vente.name for vente in Vente.objects.all().filter(facture=self))
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<th>Moyen de paiement</th>
|
<th>Moyen de paiement</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for facture in facture_list %}
|
{% for facture in facture_list %}
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
<td>{{ facture.paiement }}</td>
|
<td>{{ facture.paiement }}</td>
|
||||||
<td>{{ facture.date }}</td>
|
<td>{{ facture.date }}</td>
|
||||||
<td>{% if is_cableur %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-facture' facture.id %}"><i class="glyphicon glyphicon-bitcoin"></i> Editer</a>{% endif %}</td>
|
<td>{% if is_cableur %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-facture' facture.id %}"><i class="glyphicon glyphicon-bitcoin"></i> Editer</a>{% endif %}</td>
|
||||||
|
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:facture-pdf' facture.id %}"><i class="glyphicon glyphicon-save"></i> PDF</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
\begin{titlepage}
|
\begin{titlepage}
|
||||||
%\begin{textblock}{4cm}(20mm,5mm)
|
%\begin{textblock}{4cm}(20mm,5mm)
|
||||||
%\includegraphics[scale=0.3]{% templatetag openbrace %}{{tpl_path}}/logo.png}
|
%\includegraphics[scale=0.3]{/static_files/rezo-logo.png}
|
||||||
%\end{textblock}
|
%\end{textblock}
|
||||||
\end{titlepage}
|
\end{titlepage}
|
||||||
\hfil{\Huge\bf {{asso_name}} }\hfil % Company providing the invoice
|
\hfil{\Huge\bf {{asso_name}} }\hfil % Company providing the invoice
|
||||||
|
@ -65,12 +65,12 @@
|
||||||
{{line2}} \hfill {{email}} \\
|
{{line2}} \hfill {{email}} \\
|
||||||
Siret : {{siret}}
|
Siret : {{siret}}
|
||||||
\\ \\
|
\\ \\
|
||||||
{\bf À :} \tab {{dest}} \\ % Invoice recipient
|
{\bf À :} \tab {{dest.name}} {{dest.surname}} \\ % Invoice recipient
|
||||||
|
{\bf Chambre :} \tab {% if dest.room = None %} Aucune chambre {% else %}{{dest.room}}{% endif %} \\
|
||||||
|
|
||||||
{\bf Date:} \tab {{DATE}} \\ % Invoice date
|
{\bf Date:} \tab {{DATE}} \\ % Invoice date
|
||||||
|
|
||||||
{\bf Objet:} \tab {{obj}} \\ % Objet
|
{\bf Facture \no :} \tab {{ fid }} \\ %
|
||||||
\tab \tab {{detail}} \\ % Details
|
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
% TABLE OF EXPENSES
|
% TABLE OF EXPENSES
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
|
@ -107,6 +107,7 @@ Siret : {{siret}}
|
||||||
|
|
||||||
\vspace{1.5cm} % Whitespace
|
\vspace{1.5cm} % Whitespace
|
||||||
\hrule % Horizontal line
|
\hrule % Horizontal line
|
||||||
|
\vspace{0.25cm}
|
||||||
\footnotesize{TVA non applicable, art. 293 B du CGI}
|
\footnotesize{TVA non applicable, art. 293 B du CGI}
|
||||||
|
|
||||||
{% endlanguage %}
|
{% endlanguage %}
|
||||||
|
|
|
@ -5,6 +5,7 @@ from . import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^new_facture/(?P<userid>[0-9]+)$', views.new_facture, name='new-facture'),
|
url(r'^new_facture/(?P<userid>[0-9]+)$', views.new_facture, name='new-facture'),
|
||||||
url(r'^edit_facture/(?P<factureid>[0-9]+)$', views.edit_facture, name='edit-facture'),
|
url(r'^edit_facture/(?P<factureid>[0-9]+)$', views.edit_facture, name='edit-facture'),
|
||||||
|
url(r'^facture_pdf/(?P<factureid>[0-9]+)$', views.facture_pdf, name='facture-pdf'),
|
||||||
url(r'^new_facture_pdf/$', views.new_facture_pdf, name='new-facture-pdf'),
|
url(r'^new_facture_pdf/$', views.new_facture_pdf, name='new-facture-pdf'),
|
||||||
url(r'^add_article/$', views.add_article, name='add-article'),
|
url(r'^add_article/$', views.add_article, name='add-article'),
|
||||||
url(r'^edit_article/(?P<articleid>[0-9]+)$', views.edit_article, name='edit-article'),
|
url(r'^edit_article/(?P<articleid>[0-9]+)$', views.edit_article, name='edit-article'),
|
||||||
|
|
|
@ -13,7 +13,7 @@ from .models import Facture, Article, Vente, Cotisation, Paiement, Banque
|
||||||
from .forms import NewFactureForm, EditFactureForm, ArticleForm, DelArticleForm, PaiementForm, DelPaiementForm, BanqueForm, DelBanqueForm, NewFactureFormPdf
|
from .forms import NewFactureForm, EditFactureForm, ArticleForm, DelArticleForm, PaiementForm, DelPaiementForm, BanqueForm, DelBanqueForm, NewFactureFormPdf
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from .tex import render_tex
|
from .tex import render_tex
|
||||||
from re2o.settings import ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE
|
from re2o.settings_local import ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -61,6 +61,7 @@ def new_facture(request, userid):
|
||||||
return form({'factureform': facture_form}, 'cotisations/facture.html', request)
|
return form({'factureform': facture_form}, 'cotisations/facture.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@permission_required('cableur')
|
||||||
def new_facture_pdf(request):
|
def new_facture_pdf(request):
|
||||||
facture_form = NewFactureFormPdf(request.POST or None)
|
facture_form = NewFactureFormPdf(request.POST or None)
|
||||||
if facture_form.is_valid():
|
if facture_form.is_valid():
|
||||||
|
@ -77,6 +78,22 @@ def new_facture_pdf(request):
|
||||||
return render_tex(request, 'cotisations/factures.tex', {'DATE' : timezone.now(),'dest':destinataire, 'obj':objet, 'detail':detail, 'article':tbl, 'total':prix_total, 'paid':paid, 'asso_name':ASSO_NAME, 'line1':ASSO_ADDRESS_LINE1, 'line2':ASSO_ADDRESS_LINE2, 'siret':ASSO_SIRET, 'email':ASSO_EMAIL, 'phone':ASSO_PHONE})
|
return render_tex(request, 'cotisations/factures.tex', {'DATE' : timezone.now(),'dest':destinataire, 'obj':objet, 'detail':detail, 'article':tbl, 'total':prix_total, 'paid':paid, 'asso_name':ASSO_NAME, 'line1':ASSO_ADDRESS_LINE1, 'line2':ASSO_ADDRESS_LINE2, 'siret':ASSO_SIRET, 'email':ASSO_EMAIL, 'phone':ASSO_PHONE})
|
||||||
return form({'factureform': facture_form}, 'cotisations/facture.html', request)
|
return form({'factureform': facture_form}, 'cotisations/facture.html', request)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def facture_pdf(request, factureid):
|
||||||
|
try:
|
||||||
|
facture = Facture.objects.get(pk=factureid)
|
||||||
|
except Facture.DoesNotExist:
|
||||||
|
messages.error(request, u"Facture inexistante" )
|
||||||
|
return redirect("/cotisations/")
|
||||||
|
if not request.user.has_perms(('cableur',)) and facture.user != request.user:
|
||||||
|
messages.error(request, "Vous ne pouvez pas afficher une facture ne vous appartenant pas sans droit cableur")
|
||||||
|
return redirect("/users/profil/" + str(request.user.id))
|
||||||
|
vente = Vente.objects.all().filter(facture=facture)
|
||||||
|
ventes = []
|
||||||
|
for v in vente:
|
||||||
|
ventes.append([v, facture.number, v.prix * facture.number])
|
||||||
|
return render_tex(request, 'cotisations/factures.tex', {'paid':True, 'fid':facture.id, 'DATE':facture.date,'dest':facture.user, 'article':ventes, 'total': facture.prix_total(), 'asso_name':ASSO_NAME, 'line1': ASSO_ADDRESS_LINE1, 'line2':ASSO_ADDRESS_LINE2, 'siret':ASSO_SIRET, 'email':ASSO_EMAIL, 'phone':ASSO_PHONE, 'tpl_path':LOGO_PATH})
|
||||||
|
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def edit_facture(request, factureid):
|
def edit_facture(request, factureid):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue