stoptime/templates/invoice.tex.erb

163 lines
5.7 KiB
Plaintext

\documentclass[a4paper,oneside,dutch]{isodoc}
% rubber: clean <%=l @number %>.out
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage{pxfonts}
\setupdocument{
%% Language and style,
dutch,
fill,
%% Company info.
company=<%=l @company.name %>,
who=<%=l @company.contact_name %>,
street=<%=l @company.address_street %>,
zip=<%=l @company.address_postal_code %>,
city=<%=l @company.address_city %>,
country=<%=l @company.country %>,
countrycode=<%=l @company.country_code %>,
logoaddress={\hspace{-4.4em}
\begin{tabular}{l@{\ }l}
<% if @company.name.blank? %> \addresstext: & \who\\
<% else %> \addresstext: & \company \\
<% unless @company.contact_name.blank? %> \addresswhotext: & \who \\
<% end %><% end %> & \street\\
& \zip\ \city\\[.2em]
<% unless @company.phone.blank? %> \phonetext: & \phoneprefix\phone\\
<% end %><% unless @company.cell.blank? %> \cellphonetext: & \phoneprefix\cellphone\\
<% end %><% unless @company.email.blank? %> \emailtext: & \email\\[.2em]
<% end %><% unless @company.chamber.blank? %> \chambertext: & \chamber\\
<% end %><% unless @company.vatno.blank? %> \vatnotext: & \vatno
<% end %> \end{tabular}},
%% Footer.
<% unless @company.website.blank? %> footer,<%
end %> areacode=31,
phone=<%=l @company.phone %>,
cellphone=<%=l @company.cell %>,
email=<%=l @company.email %>,
website=<%=l @company.website %>,
%% Addressee info.
%foreign,
to={<%=l @customer.name %>\\<% unless @customer.financial_contact.blank?
%><%=l @customer.financial_contact
%>\\<% end %><%=l @customer.address_street%>\\
<%=l @customer.address_postal_code %> <%=l @customer.address_city %>},
% Headlines.
date=<%=l @invoice.created_at.to_formatted_s(:day_code) %>,
ourref=<%=l @number %>,
<% period = @period.map { |p| I18n.l p, :format => :month_and_year }.uniq
case period.length
when 1 %> subject=Factuur <%=l period.first %>,<%
when 2 %> subject=Factuur <%=l period.join(" t/m ") %>,<%
end %>
yourref=,
%% Payment data.
term=30,
accountname=<%=l @company.accountname %>,
<% unless @company.accountiban.blank? %> iban=<%=l @company.accountiban %>,
<% end %><% unless @company.bank_bic.blank? %> bic=<%=l @company.bank_bic %>,
<% end %><% unless @company.vatno.blank? %> vatno=<%=l @company.vatno %>,
<% end %><% unless @company.chamber.blank? %> chamber=<%=l @company.chamber %>
<% end %>}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\medskipamount}
<% if @company.bank_name.present? %>
\renewcommand{\accountnotext}{<%=l @company.bank_name %> rekeningnr}
<% end %>\newcommand{\addresstext}{adres}
\newcommand{\addresswhotext}{t.n.v.}
\renewcommand{\chambertext}{KvK-nr}
\renewcommand{\datetext}{Factuurdatum}
\renewcommand{\emailtext}{e-mail}
\renewcommand{\invoicetext}{\Large\textbf{Factuur}}
\renewcommand{\ourreftext}{Factuurnummer}
\renewcommand{\referencetext}{factuurnummer}
\renewcommand{\vatnotext}{btw-nr}
\renewcommand{\websitetext}{website}
\newenvironment{ihtable}%
{\vskip1em\tabularx{\linewidth}{@{}X|@{\quad}r|@{\quad}r|@{\quad}r@{}}
\descriptiontext&Aantal uur&Uurtarief&\amounttext\ML}%
{\endtabularx}
\newcommand{\ihitem}[4]{#1&#2&\currency~#3&\currency~#4\\}
\newcommand{\ifcitem}[3]{#1&#2&--&\currency~#3\\}
\newcommand{\ihsubtotal}[1]{\cmidrule[.0em]{4-4}%
\textit{Subtotaal}&&&\currency~#1\\}
\newcommand{\ihnosubtotal}[1]{\cmidrule[.0em]{4-4}&&&\\}
\newcommand{\ihvat}[2]{\textit{Btw-heffing #1}&&&\currency~#2\\}
\newcommand{\ihtotal}[1]{\cmidrule[.05em]{4-4}%
\textbf{\totaltext}&&&\textbf{\currency~#1}}
\newenvironment{istable}%
{\vskip1em\tabularx{\linewidth}{@{}X@{\quad}l@{\qquad}r@{}}
\descriptiontext&Datum&Aantal uur\ML}%
{\endtabularx}
\newcommand{\istask}[1]{\textbf{#1}\\}
\newcommand{\isitem}[3]{\quad #1&#2&#3\\}
\begin{document}
\invoice{
\hypersetup{pdftitle=\invoicetext\ naar\ \toname\ gedateerd \date\ (\ourref)}
\begin{ihtable}
<% subtotal = 0.0
@tasks.each do |task, line|
if line[1].blank?
%> \ifcitem{<%=l task.comment_or_name %>}%
{<%=l number_with_precision(line[0]) %>}%
{<%=l number_with_precision(line[2]) %>}
<% else
%> \ihitem{<%=l task.comment_or_name %>}%
{<%=l number_with_precision(line[0]) %>}%
{<%=l number_with_precision(line[1]) %>}%
{<%=l number_with_precision(line[2]) %>}
<% end
subtotal += line[2]
end
vattotal = 0.0
if @company.vatno.blank?
%> \ihnosubtotal{} <%
else
%> \ihsubtotal{<%=l number_with_precision(subtotal) %>}<%
@vat.keys.sort.each do |rate|
vattotal += @vat[rate] %>
\ihvat{<%= "%d\\%%" % rate %>}{<%=l number_with_precision(@vat[rate]) %>}<%
end
end %>
\ihtotal{<%=l number_with_precision(subtotal + vattotal) %>}
\end{ihtable}
\vspace{2em}
<% if @invoice.include_specification?
%> Zie bijlage op de volgende pagina voor een nadere specificatie.\\[1em]<%end %>
Ik verzoek u vriendelijk het verschuldigde bedrag binnen 30 dagen na
factuurdatum over te maken onder vermelding van het factuurnummer. \\
\accountdata
}
<% if @invoice.include_specification? %>{
\newpage
{\bfseries\scshape\Large Specificatie}
Hieronder volgt een specificatie van gemaakte uren per taak per
uitgevoerde activiteit.
\begin{istable}
<% @invoice.tasks.each do |task|
%> \istask{<%=l task.comment_or_name %>}<%
task.time_entries.each do |time_entry| %>
\isitem{<%=l time_entry.comment || "Geen opmerking" %>}%
{<%=l time_entry.date.to_date %>}%
{<%=l number_with_precision(time_entry.hours_total) %>}<%
end %>\\[\medskipamount]<%
end %>
\end{istable}
\label{LastPageOf\thelettercount}
}<% end %>
\end{document}