1

I need help fine tuning this document. I basically need three things:

  1. Get rid of the duplicate company information on top of "Client"
  2. Be able to stamp today's date automatically. I tried using "datetime" package but every time I run the script it collapses.
  3. Calculate the tax automatically (can that be done in LaTeX?)

PS: the example comes with an external file called "template.lco" Inside that file I found the following:

\ProvidesFile{template.loc}[]

% firstfootvpos has to have more space to the bottom
\@setplength{firstfootvpos}{\paperheight}
\@addtoplength[-]{firstfootvpos}{30mm}

And here's the code for the actual document:

\documentclass[DIN, pagenumber=false, parskip=half, 
fromalign=right, 
fromphone=true, 
fromfax=false,
fromrule=false]{scrlttr2}

\usepackage[spanish]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{eurosym}
\usepackage{datetime}

\LoadLetterOption{template}
\newcommand{\stdlohn}[0]{18 \% }
\renewcommand*{\raggedsignature}{\raggedright} 

\setkomavar{fromname}{Company}
\setkomavar{fromphone}{+49 (0) 123 / 1234 1234}
\setkomavar{fromaddress}{Address}
\setkomavar{frombank}{Bank info}

\setkomavar{subject}[]{Service description}
\setkomavar{yourmail}[Code]{BAG-EB-00001}
\setkomavar{date}[Date]{06 July 2015}

\firstfoot{
\parbox[t]{\textwidth}{\footnotesize 

\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Company:}}\\ 
Info \\
\end{tabular}
\hfill{}
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Bank:}}\\ 
Bank name\\
\end{tabular}
}}

\begin{document}

\begin{letter}{
\textbf{Client}\\ 
Name\\
}

\opening{\ }
\vspace{-1.9cm}

\begin{longtable}{p{7.8cm}p{1.0cm}p{1cm}p{2.7cm}p{2.5cm}}
\hline  
Description & Amount & U & Price & Total\\
\hline 

\textbf{Service}\\
Service & 1 & H & USD 60.00 {} & USD 60.00{}\\ \\
\hline\hline 
\end{longtable}

\begin{longtable}{p{5.5cm}p{3cm}p{3cm}}
\hline A & \stdlohn Tax & B\\
\hline 
USD 6,000.00{} & USD 6,000.00 & \textbf{USD 6,000.00}{}\\
\hline 
\hline  
\end{longtable}

\end{letter}
\end{document}
killthepixelnow
  • 454
  • 5
  • 14

2 Answers2

3

I will only answer the first two questions.

If you do not want the back address on top of the "Client" use the class option

backaddress=false

To set the to set the todays stamp automatically in spanish remove \usepackage{datetime} and remove \setkomavar{date}[Date]{06 July 2015}.

enter image description here

Code:

\begin{filecontents*}{template.lco}
\ProvidesFile{template.lco}[]

% firstfootvpos has to have more space to the bottom
\@setplength{firstfootvpos}{\paperheight}
\@addtoplength[-]{firstfootvpos}{30mm}
\end{filecontents*}

\documentclass[DIN, pagenumber=false, parskip=half, 
fromalign=right, 
fromphone=true, 
fromfax=false,
fromrule=false,
backaddress=false,
% numericaldate
]{scrlttr2}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{eurosym}
%\usepackage{datetime}% <- removed

\LoadLetterOption{template}
\newcommand{\stdlohn}[0]{18 \% }
\renewcommand*{\raggedsignature}{\raggedright} 

\setkomavar{fromname}{Company}
\setkomavar{fromphone}{+49 (0) 123 / 1234 1234}
\setkomavar{fromaddress}{Address}
\setkomavar{frombank}{Bank info}

\setkomavar{subject}[]{Service description}
\setkomavar{yourmail}[Code]{BAG-EB-00001}
%\setkomavar{date}[Date]{06 July 2015}% <-removed

\setkomavar{firstfoot}{% <- changed
\parbox[t]{\textwidth}{\footnotesize 

\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Company:}}\\ 
Info \\
\end{tabular}
\hfill{}
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Bank:}}\\ 
Bank name\\
\end{tabular}
}}

\begin{document}

\begin{letter}{
\textbf{Client}\\ 
Name\\
}

\opening{\ }
\vspace{-1.9cm}
\begin{longtable}{p{7.8cm}p{1.0cm}p{1cm}p{2.7cm}p{2.5cm}}
\hline  
Description & Amount & U & Price & Total\\
\hline 

\textbf{Service}\\
Service & 1 & H & USD 60.00 {} & USD 60.00{}\\ \\
\hline\hline 
\end{longtable}
\begin{longtable}{p{5.5cm}p{3cm}p{3cm}}
\hline A & \stdlohn Tax & B\\
\hline 
USD 6,000.00{} & USD 6,000.00 & \textbf{USD 6,000.00}{}\\
\hline 
\hline  
\end{longtable}
\end{letter}
\end{document}

Note that I have changed \firstfoot{...} to \setkomavar{firstfoot}{...}. That is the uptodate syntax.


If the language of your document is english you can change the babel option to english. Then use

\usepackage[english]{isodate}\cleanlookdateon

instead loading datetime and remove \setkomavar{date}[Date]{06 July 2015} to set the todays stamp automatically in the same format.

enter image description here

esdd
  • 85,675
1

EDIT: I changed the code to a MWE.

With the two commands you can print the taxes only or the sum of both values. You can place them wherever you want them to appear.

enter image description here

\documentclass{standalone}
\usepackage{pgf,pgfmath}

\pgfkeys{/pgf/number format/.cd,
    fixed,
    fixed zerofill,
    precision=2,
    set thousands separator={.},
    set decimal separator={,}
    }

\newcommand{\taxes}[2]{%
    \pgfmathparse{#1*#2/100}%
    \pgfmathprintnumber{\pgfmathresult}%
    }

\newcommand{\addtaxes}[2]{%
    \pgfmathparse{#1+#1*#2/100}%
    \pgfmathprintnumber{\pgfmathresult}%
    }

\def\taxval{18}
\def\money{4.5}

\begin{document}
\begin{tabular}{cr}
Worktime & \pgfmathprintnumber{\money} \\
Taxes (\taxval\,\%)& \taxes{\money}{\taxval} \\
Sum & \addtaxes{\money}{\taxval}
\end{tabular}
\end{document}
  • When I insert the script for "\pgfmathprintnumber" I receive the following error: ! Undefined control sequence. l.22 \pgfkeys {/pgf/number format/.cd, ? – killthepixelnow Jul 07 '15 at 10:50
  • apart from that, how do I apply that command to my document. That means, how do I calculate the tax automatically and also the final price of the invoice (Tax = A*1.18; B = A + Tax). I hope this makes things more clear. – killthepixelnow Jul 07 '15 at 10:53
  • 1
    @killthepixelnow I changed my answer to an working example. – Daniel Schlegel Jul 07 '15 at 11:11
  • Awesome! It worked perfectly. Just out of curiosity, when I enter a four digit figure (e.g. 7000) I receive an error. Why is that? – killthepixelnow Jul 07 '15 at 12:44
  • 1
    I didn't get that error before. But it appears to be a problem in the default math engine. A solution is described here: http://tex.stackexchange.com/a/54803/79099. Just add '\usepackage{pgfplots}' and '\pgfkeys{/pgf/fpu}' to your file and it should work. – Daniel Schlegel Jul 07 '15 at 13:44
  • Perfect! That solved the issue. One last thing, I tried formating my numbers like this: "1,000.00" by using: "set thousands separator={,},set decimal separator={.}" but I always get "1,000,00." Any idea how to change that? – killthepixelnow Jul 07 '15 at 14:06
  • 1
    I get the correct result when I change the separators. – Daniel Schlegel Jul 08 '15 at 06:02
  • Funny, when I use another character (for instance, an X) it appears as a separator (1,000X00. Only when I use a dot (".") it goes back to a comma (1,000,00). SOLVED: Modified the Babel package: "\usepackage[spanish,es-nodecimaldot]{babel} " at the beginning. Worked as a charm! – killthepixelnow Jul 09 '15 at 08:29