yavsc/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml

206 lines
5.9 KiB
Text
Raw Normal View History

2016-11-06 02:03:36 +01:00
@using Yavsc.Helpers
@using System.IO
2016-11-08 14:55:21 +01:00
@using System.Globalization
2016-11-09 14:03:57 +01:00
@model Estimate
2016-11-03 17:34:19 +01:00
@{
Layout = null;
2016-11-04 13:55:48 +01:00
var pro = Model.Query.PerformerProfile;
var from = Model.Query.PerformerProfile.Performer;
var to = Model.Query.Client;
var PostalAddress = to.PostalAddress?.Address.SplitAddressToTeX();
var proaddr = Model.Query.PerformerProfile.OrganizationAddress.Address.SplitAddressToTeX();
var proaddrm = new HtmlString(Model.Query.PerformerProfile.OrganizationAddress.Address);
var isestimate = !ViewBag.AsBill;
var prosign = new FileInfo($"{ViewBag.BillsDir}/estimate-prosign-{Model.Id}.png");
}
\documentclass[french,11pt]{article}
2016-11-08 14:55:21 +01:00
\usepackage{eurosym}
2015-11-17 22:22:59 +01:00
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}
\usepackage{units}
\usepackage{bera}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{fp}
\def\TVA{20} % Taux de la TVA
\def\TotalHT{0}
\def\TotalTVA{0}
\newcommand{\AjouterService}[3]{% Arguments : Désignation, quantité, prix
\FPround{\prix}{#3}{2}
\FPeval{\montant}{#2 * #3}
\FPround{\montant}{\montant}{2}
\FPadd{\TotalHT}{\TotalHT}{\montant}
\eaddto\ListeProduits{#1 & \prix & #2 & \montant \cr}
}
\newcommand{\AfficheResultat}{%
\ListeProduits
\FPeval{\TotalTVA}{\TotalHT * \TVA / 100}
\FPadd{\TotalTTC}{\TotalHT}{\TotalTVA}
\FPround{\TotalHT}{\TotalHT}{2}
\FPround{\TotalTVA}{\TotalTVA}{2}
\FPround{\TotalTTC}{\TotalTTC}{2}
\global\let\TotalHT\TotalHT
\global\let\TotalTVA\TotalTVA
\global\let\TotalTTC\TotalTTC
\cr
\hline
\textbf{Total} & & & \TotalHT
}
\newcommand*\eaddto[2]{% version développée de \addto
\edef\tmp{#2}%
\expandafter\addto
\expandafter#1%
\expandafter{\tmp}%
}
\newcommand{\ListeProduits}{}
%%%%%%%%%%%%%%%%%%%%% A MODIFIER DANS LA FACTURE %%%%%%%%%%%%%%%%%%%%%
2016-05-17 18:22:18 +02:00
\def\FactureNum {@Model.Id.ToString()} % Numéro de facture
\def\FactureAcquittee {@ViewBag.Acquitted?"oui":"non"} % Facture acquittée : oui/non
\def\FactureLieu {@proaddrm} % Lieu de l'édition de la facture
\def\FactureObjet {@(new HtmlString(isestimate?"Devis":"Facture")) : @TeXHelpers.ToTeX(Model.Title)} % Objet du document
2015-11-17 22:22:59 +01:00
% Description de la facture
2016-05-17 18:22:18 +02:00
\def\FactureDescr {
2016-11-10 01:03:49 +01:00
@TeXHelpers.ToTeX(Model.Description)
2015-11-17 22:22:59 +01:00
}
% Infos Client
2016-11-10 01:03:49 +01:00
\def\ClientNom{@TeXHelpers.ToTeX(to.UserName)} % Nom du client
2016-09-05 00:26:54 +02:00
2016-11-03 17:34:19 +01:00
\def\ClientAdresse{
% Adresse du client
@PostalAddress
@if (PostalAddress!=null) {<text>@PostalAddress</text>}
@if (!string.IsNullOrWhiteSpace(to.PhoneNumber)) {<text>@TeXHelpers.ToTeX(to.PhoneNumber)<text>\\</text>
2016-11-03 17:34:19 +01:00
</text>}
2016-11-10 01:03:49 +01:00
E-mail: @TeXHelpers.ToTeX(to.Email)
2015-11-17 22:22:59 +01:00
}
% Liste des produits facturés : Désignation, prix
2016-11-08 14:55:21 +01:00
@if (Model.Bill!=null) { foreach (CommandLine line in Model.Bill) {
2016-11-10 01:03:49 +01:00
<text>\AjouterService{@TeXHelpers.ToTeX(line.Description)}{@line.Count}{@line.UnitaryCost.ToString("F2",CultureInfo.InvariantCulture)}
2016-11-08 14:55:21 +01:00
</text>} }
2015-11-17 22:22:59 +01:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2016-11-03 17:34:19 +01:00
2015-11-17 22:22:59 +01:00
\geometry{verbose,tmargin=4em,bmargin=8em,lmargin=6em,rmargin=6em}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\thispagestyle{fancy}
\pagestyle{fancy}
\setlength{\parindent}{0pt}
\renewcommand{\headrulewidth}{0pt}
\cfoot{ @TeXHelpers.ToTeX(from.UserName) @if (proaddrm!=null) { <text> - @proaddrm </text> } \newline
2016-11-10 01:03:49 +01:00
\small{ E-mail: @TeXHelpers.ToTeX(from.Email) @if (!string.IsNullOrWhiteSpace(from.PhoneNumber)) { <text> - Téléphone fixe: @TeXHelpers.ToTeX(from.PhoneNumber) </text> }
2015-11-17 22:22:59 +01:00
}
}
\begin{document}
% Logo de la société
2016-11-10 01:03:49 +01:00
@if (from.Avatar != null) {
<text>\includegraphics[height=60pt]{@(ViewBag.AvatarsDir)/@(from.UserName).png}
2016-11-10 01:03:49 +01:00
</text>
} else {
<text>%\includegraphics{logo.png}
</text>
2016-11-04 13:55:48 +01:00
}
2015-11-17 22:22:59 +01:00
% Nom et adresse de la société
2016-11-10 01:03:49 +01:00
@TeXHelpers.ToTeX(from.UserName) \\
@proaddr
2015-11-17 22:22:59 +01:00
@(isestimate?"Devis":"Facture") n°\FactureNum
2015-11-17 22:22:59 +01:00
{\addtolength{\leftskip}{10.5cm} %in ERT
\textbf{\ClientNom} \\
\ClientAdresse \\
} %in ERT
\hspace*{10.5cm}
\FactureLieu, le \today
~\\~\\
\textbf{Objet : \FactureObjet \\}
\textnormal{\FactureDescr}
~\\
\begin{center}
\begin{tabular}{lrrr}
2016-11-08 14:55:21 +01:00
\textbf{Désignation ~~~~~~} & \textbf{Prix unitaire} & \textbf{Quantité} & \textbf{Montant (\euro)} \\
2015-11-17 22:22:59 +01:00
\hline
\AfficheResultat{}
\end{tabular}
\end{center}
\begin{flushright}
\textit{Auto entreprise en franchise de TVA}\\
\end{flushright}
~\\
@if (!isestimate) {
<text>
2015-11-17 22:22:59 +01:00
\ifthenelse{\equal{\FactureAcquittee}{oui}}{
Facture acquittée.
}{ </text>
2016-11-04 13:55:48 +01:00
var bi = from.BankInfo;
if (bi!=null) {
<text>À régler par chèque ou par virement bancaire :
2015-11-17 22:22:59 +01:00
\begin{center}
\begin{tabular}{|c c c c|}
2016-11-04 13:55:48 +01:00
@if (!string.IsNullOrWhiteSpace(bi.BankCode) && !string.IsNullOrWhiteSpace(bi.WicketCode)
&& !string.IsNullOrWhiteSpace(bi.AccountNumber) ) {
<text>\hline \textbf{Code banque} & \textbf{Code guichet} & \textbf{N° de Compte} & \textbf{Clé RIB} \\
@bi.BankCode & @bi.WicketCode & @bi.AccountNumber & @bi.BankedKey \\
</text>
2016-05-17 18:22:18 +02:00
}
2016-11-04 13:55:48 +01:00
@if (!string.IsNullOrWhiteSpace(@bi.IBAN) && !string.IsNullOrWhiteSpace(@bi.BIC)) {
<text>
\hline \textbf{IBAN N°} & \multicolumn{3}{|l|}{ @bi.IBAN } \\
\hline \textbf{Code BIC} & \multicolumn{3}{|l|}{ @bi.BIC }
</text>
2016-05-17 18:22:18 +02:00
} \\
2015-11-17 22:22:59 +01:00
\hline
\end{tabular}
2016-11-04 13:55:48 +01:00
\end{center}</text>
}
}
@if (!(Model.ProviderValidationDate==null)) {
<text>
\begin{flushright}
2017-06-08 00:26:29 +02:00
@(new HtmlString(isestimate?"Devis validé":"Facture validée")) le @TeXHelpers.ToTeX(Model.ProviderValidationDate.ToString("dddd dd MMMM yyyy"))
\end{flushright}
@if (prosign.Exists) {
<text>
\begin{center}
\hspace{263pt}
\includegraphics[height=60pt]{@(ViewBag.BillsDir)/estimate-prosign-@(Model.Id).png}
\end{center}
</text>
}
</text>
2015-11-17 22:22:59 +01:00
}
\end{document}