{% load i18n %}
{% language 'fr' %}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Invoice Template
% LaTeX Template
% Version 1.0 (3/11/12)
%% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Trey Hunner (http://www.treyhunner.com/)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
% Important note:
% This template requires the invoice.cls file to be in the same directory as
% the .tex file. The invoice.cls file provides the style used for structuring the
% document.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%       DOCUMENT CONFIGURATION
%----------------------------------------------------------------------------------------

\documentclass[12pt]{article} % Use the custom invoice class (invoice.cls)
\usepackage[utf8]{inputenc}
\usepackage[letterpaper,hmargin=0.79in,vmargin=0.79in]{geometry}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{eurosym}
\usepackage{multicol}

\pagestyle{empty} % No page numbers
\linespread{1.5} % Line spacing

\newcommand{\doublehline}{\noalign{\hrule height 1pt}}
\setlength{\parindent}{0cm}



\begin{document}

    %----------------------------------------------------------------------------------------
    %   HEADING SECTION
    %----------------------------------------------------------------------------------------
    \begin{center}
        {\Huge\bf {{asso_name|safe}}  } % Company providing the invoice
    \end{center}

    \bigskip
    \hrule
    \smallskip

    {\setlength{\tabcolsep}{0pt} % Make table columns tighter, usefull for postionning
        \begin{tabular}{l l}
            {\bf Adresse :}~ & {{line1|safe}} \\
                             & {{line2|safe}} \\
        \end{tabular}
        \hfill
        \begin{tabular}{r}
            {\bf Téléphone :} {{phone}} \\
            {\bf Mail :} {{email|safe}} \\
        \end{tabular}
    }
    \\
    {\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 %} & \\
        {% if fid is not None %}
        {% if is_estimate %}
        {\bf Devis n\textsuperscript{o} :} {{ fid }} & \\
        {% else %}
        {\bf Facture n\textsuperscript{o} :} {{ fid }} & \\
        {% endif %}
        {% endif %}
    \end{tabular*}
    \\


    %----------------------------------------------------------------------------------------
    %   TABLE OF EXPENSES
    %----------------------------------------------------------------------------------------

    \begin{tabularx}{\textwidth}{|X|r|r|r|}

        \hline
        \textbf{Désignation} & \textbf{Prix Unit.} \euro & \textbf{Quantité} & \textbf{Prix total} \euro\\
        \doublehline

        {% for a in article %}
        {{a.name}} & {{a.price}} \euro & {{a.quantity}} & {{a.total_price}} \euro\\
        \hline
        {% endfor %}

    \end{tabularx}

    \vspace{1cm}

    \hfill
        \begin{tabular}{|l|r|}
            \hline
            \textbf{Total} & {{total|floatformat:2}} \euro \\
            {% if not is_estimate %}
            \textbf{Votre règlement} & {% if paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro \\
            \doublehline
            \textbf{À PAYER} & {% if not paid %}{{total|floatformat:2}}{% else %} 00,00 {% endif %} \euro\\
            {% endif %}
            \hline
        \end{tabular}

    \vspace{1cm}
    \begin{tabularx}{\textwidth}{r X}
        \hline
        \textbf{Moyen de paiement} & {{payment_method|default:"Non spécifié"}} \\
        \hline
        {% if remark %}
        \textbf{Remarque} & {{remark|safe}} \\
        \hline
        {% endif %}
        {% if end_validity %}
        \textbf{Validité} & Jusqu'au {{end_validity}} \\
        \hline
        {% endif %}
    \end{tabularx}


    \vfill


    %----------------------------------------------------------------------------------------
    %   FOOTNOTE
    %----------------------------------------------------------------------------------------

    \hrule
    \smallskip
    \footnotesize{TVA non applicable, art. 293 B du CGI}

    %----------------------------------------------------------------------------------------

\end{document}

{% endlanguage %}
