mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Fix 81 and Strip out facture.tex for readability
This commit is contained in:
parent
cd0e11815c
commit
d9c42e89db
4 changed files with 87 additions and 69 deletions
|
@ -158,12 +158,6 @@ class NewFactureFormPdf(Form):
|
||||||
dest = forms.CharField(required=True, max_length=255, label=_l("Recipient"))
|
dest = forms.CharField(required=True, max_length=255, label=_l("Recipient"))
|
||||||
# TODO : change chambre field to address
|
# TODO : change chambre field to address
|
||||||
chambre = forms.CharField(required=False, max_length=10, label=_l("Address"))
|
chambre = forms.CharField(required=False, max_length=10, label=_l("Address"))
|
||||||
# TODO : change fid field to invoice_id
|
|
||||||
fid = forms.CharField(
|
|
||||||
required=True,
|
|
||||||
max_length=10,
|
|
||||||
label=_l("Invoice number")
|
|
||||||
)
|
|
||||||
|
|
||||||
# TODO : change Facture to Invoice
|
# TODO : change Facture to Invoice
|
||||||
class EditFactureForm(FieldPermissionFormMixin, NewFactureForm):
|
class EditFactureForm(FieldPermissionFormMixin, NewFactureForm):
|
||||||
|
|
|
@ -32,76 +32,98 @@
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage{tabularx}
|
\usepackage{tabularx}
|
||||||
\usepackage{eurosym}
|
\usepackage{eurosym}
|
||||||
|
\usepackage{multicol}
|
||||||
|
|
||||||
\pagestyle{empty} % No page numbers
|
\pagestyle{empty} % No page numbers
|
||||||
\linespread{1.5} % Line spacing
|
\linespread{1.5} % Line spacing
|
||||||
|
|
||||||
\setlength{\doublerulesep}{\arrayrulewidth} % Double rules look like one thick one
|
\setlength{\doublerulesep}{\arrayrulewidth} % Double rules look like one thick one
|
||||||
\def \tab {\hspace*{3ex}} % Define \tab to create some horizontal white space
|
|
||||||
\setlength{\parindent}{0cm}
|
\setlength{\parindent}{0cm}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
%\newcommand{\product}[5][0][0][0][0][0]{
|
|
||||||
%\setlength{ptotal}{#3*\real{#4}}
|
|
||||||
%\addtolength{total}{#3*\real{#4}}
|
|
||||||
|
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
% HEADING SECTION
|
% HEADING SECTION
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
%\includegraphics[width=3.5cm]{% templatetag openbrace %}{{ tpl_path }}}
|
\begin{center}
|
||||||
\tab \tab \tab \tab \tab {\Huge\bf {{asso_name|safe}} }\hfil % Company providing the invoice
|
{\Huge\bf {{asso_name|safe}} } % Company providing the invoice
|
||||||
\bigskip\break % Whitespace
|
\end{center}
|
||||||
\hrule % Horizontal line \\
|
|
||||||
\vspace{0.5cm}
|
|
||||||
{\bf Adresse :} \tab \parbox [t] {0.5\textwidth}{ {{line1|safe}} \\ {{line2|safe}} } \hfill \parbox [t] {0.3\textwidth}{ {\bf Téléphone :} {{phone}} \\ {\bf Mail :} {{email|safe}} } \\ % Your address and contact information
|
|
||||||
\\
|
|
||||||
{\bf Siret :} \tab{{siret}}
|
|
||||||
\\ \\ \\
|
|
||||||
\\
|
|
||||||
\parbox [t] {0.5\textwidth}{ {\bf Pour :} {{dest.name|safe}} {{dest.surname|safe}} \\ {\bf Adresse :} \tab {% if dest.room == None %} Aucune adresse renseignée {% else %}{{dest.room}}{% endif %} } \hfill \parbox [t] {0.3\textwidth}{ {\bf Date :} {{DATE}} }
|
|
||||||
\\ \\
|
|
||||||
|
|
||||||
{\bf Facture \no :} \tab {{ fid }} \\\\
|
\bigskip
|
||||||
%----------------------------------------------------------------------------------------
|
\hrule
|
||||||
% TABLE OF EXPENSES
|
\smallskip
|
||||||
%----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
\begin{tabularx}{\textwidth}{|X|r|r|r|}
|
\begin{multicols}{2}
|
||||||
\hline
|
\begin{tabular}{@{\extracolsep{\fill}}l r}
|
||||||
\textbf{Désignation} & \textbf{Prix Unit.} \euro & \textbf{Quantité} & \textbf{Prix total} \euro\\
|
{\bf Adresse :} & {{line1|safe}} \\
|
||||||
\hline
|
& {{line2|safe}} \\
|
||||||
|
\end{tabular}
|
||||||
|
\columnbreak
|
||||||
|
\\
|
||||||
|
{\bf Téléphone :} {{phone}} \\
|
||||||
|
{\bf Mail :} {{email|safe}}
|
||||||
|
\end{multicols}
|
||||||
|
|
||||||
|
{\bf Siret :} {{siret|safe}}
|
||||||
|
|
||||||
|
\vspace{2cm}
|
||||||
|
|
||||||
|
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l r}
|
||||||
|
{\bf Pour :} {{recipient_name|safe}} & {\bf Date :} {{DATE}} \\
|
||||||
|
{\bf Adresse :} {% if address is None %}Aucune adresse renseignée{% else %}{{address}}{% endif %} & \\
|
||||||
|
\end{tabular*}
|
||||||
|
{% if fid is not None %}
|
||||||
|
{\bf Facture n\textsuperscript{o} :} {{ fid }} \\
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% for a in article %}
|
%----------------------------------------------------------------------------------------
|
||||||
\hline
|
% TABLE OF EXPENSES
|
||||||
{{a.0.name}} & {{a.0.prix}} \euro & {{a.1}} & {{a.2}} \euro\\
|
%----------------------------------------------------------------------------------------
|
||||||
\hline
|
|
||||||
{% endfor %}
|
\begin{tabularx}{\textwidth}{|X|r|r|r|}
|
||||||
|
|
||||||
\hline
|
\hline
|
||||||
\end{tabularx}
|
\textbf{Désignation} & \textbf{Prix Unit.} \euro & \textbf{Quantité} & \textbf{Prix total} \euro\\
|
||||||
|
\hline
|
||||||
|
\hline
|
||||||
|
|
||||||
\vspace{1cm}
|
{% for a in article %}
|
||||||
\hfill
|
{{a.0.name}} & {{a.0.prix}} \euro & {{a.1}} & {{a.2}} \euro\\
|
||||||
\begin{tabular}{|l|r|}
|
\hline
|
||||||
\hline
|
{% endfor %}
|
||||||
\textbf{Total} & {{total|floatformat:2}} \euro \\
|
|
||||||
\textbf{Votre règlement} & {% if paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro \\
|
|
||||||
\hline
|
|
||||||
\textbf{À PAYER} & {% if not paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro\\
|
|
||||||
\hline
|
|
||||||
\hline
|
|
||||||
|
|
||||||
\end{tabular}
|
\hline
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
\vspace{1.5cm} % Whitespace
|
\vspace{1cm}
|
||||||
\hrule % Horizontal line
|
|
||||||
\vspace{0.25cm}
|
|
||||||
\footnotesize{TVA non applicable, art. 293 B du CGI}
|
|
||||||
|
|
||||||
{% endlanguage %}
|
\hfill
|
||||||
%----------------------------------------------------------------------------------------
|
\begin{tabular}{|l|r|}
|
||||||
|
\hline
|
||||||
|
\textbf{Total} & {{total|floatformat:2}} \euro \\
|
||||||
|
\textbf{Votre règlement} & {% if paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro \\
|
||||||
|
\hline
|
||||||
|
\textbf{À PAYER} & {% if not paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro\\
|
||||||
|
\hline
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
%----------------------------------------------------------------------------------------
|
||||||
|
% FOOTNOTE
|
||||||
|
%----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
\hrule
|
||||||
|
\smallskip
|
||||||
|
\footnotesize{TVA non applicable, art. 293 B du CGI}
|
||||||
|
|
||||||
|
%----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
{% endlanguage %}
|
||||||
|
|
|
@ -48,7 +48,7 @@ def render_invoice(request, ctx={}):
|
||||||
filename = '_'.join([
|
filename = '_'.join([
|
||||||
'invoice',
|
'invoice',
|
||||||
slugify(ctx['asso_name']),
|
slugify(ctx['asso_name']),
|
||||||
slugify(ctx['dest'].pseudo),
|
slugify(ctx['recipient_name']),
|
||||||
str(ctx['DATE'].year),
|
str(ctx['DATE'].year),
|
||||||
str(ctx['DATE'].month),
|
str(ctx['DATE'].month),
|
||||||
str(ctx['DATE'].day),
|
str(ctx['DATE'].day),
|
||||||
|
|
|
@ -201,20 +201,18 @@ def new_facture_pdf(request):
|
||||||
invoice_form = NewFactureFormPdf(request.POST or None)
|
invoice_form = NewFactureFormPdf(request.POST or None)
|
||||||
if invoice_form.is_valid():
|
if invoice_form.is_valid():
|
||||||
tbl = []
|
tbl = []
|
||||||
article = facture_form.cleaned_data['article']
|
article = invoice_form.cleaned_data['article']
|
||||||
quantity = facture_form.cleaned_data['number']
|
quantity = invoice_form.cleaned_data['number']
|
||||||
paid = facture_form.cleaned_data['paid']
|
paid = invoice_form.cleaned_data['paid']
|
||||||
recipient = facture_form.cleaned_data['dest']
|
recipient = invoice_form.cleaned_data['dest']
|
||||||
room = facture_form.cleaned_data['chambre']
|
address = invoice_form.cleaned_data['chambre']
|
||||||
invoice_id = facture_form.cleaned_data['fid']
|
|
||||||
for art in article:
|
for art in article:
|
||||||
tbl.append([art, quantity, art.prix * quantity])
|
tbl.append([art, quantity, art.prix * quantity])
|
||||||
total_price = sum(a[2] for a in tbl)
|
total_price = sum(a[2] for a in tbl)
|
||||||
user = {'name': recipient, 'room': room}
|
|
||||||
return render_invoice(request, {
|
return render_invoice(request, {
|
||||||
'DATE': timezone.now(),
|
'DATE': timezone.now(),
|
||||||
'dest': user,
|
'recipient_name': recipient,
|
||||||
'fid': invoice_id,
|
'address': address,
|
||||||
'article': tbl,
|
'article': tbl,
|
||||||
'total': total_price,
|
'total': total_price,
|
||||||
'paid': paid,
|
'paid': paid,
|
||||||
|
@ -251,7 +249,11 @@ def facture_pdf(request, facture, factureid):
|
||||||
'paid': True,
|
'paid': True,
|
||||||
'fid': facture.id,
|
'fid': facture.id,
|
||||||
'DATE': facture.date,
|
'DATE': facture.date,
|
||||||
'dest': facture.user,
|
'recipient_name': "{} {}".format(
|
||||||
|
facture.user.name,
|
||||||
|
facture.user.surname
|
||||||
|
),
|
||||||
|
'addresse': facture.user.room,
|
||||||
'article': purchases,
|
'article': purchases,
|
||||||
'total': facture.prix_total(),
|
'total': facture.prix_total(),
|
||||||
'asso_name': AssoOption.get_cached_value('name'),
|
'asso_name': AssoOption.get_cached_value('name'),
|
||||||
|
|
Loading…
Reference in a new issue