This commit is contained in:
2023-02-27 13:01:15 +01:00
parent 4fdf873b41
commit 8774ca46df
8 changed files with 194 additions and 43 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.aux *.aux
*.log *.log
*.pdf *.pdf
.venv/
__pycache__/

36
generate.py Normal file
View File

@ -0,0 +1,36 @@
import argparse
import json
from Cheetah.Template import Template
import importlib
parser = argparse.ArgumentParser(description='LetterGenerator')
parser.add_argument('--input', '-i',
help = 'Input file in JSON format',
required = True)
parser.add_argument('--template', '-t',
help = 'Template file in Cheetah format',
required = True)
parser.add_argument('--output', '-o',
help = 'Output file',
required = True)
parser.add_argument('--preprocessor', '-p',
help = 'Preprocessor module',
required = False)
args = parser.parse_args()
inputFile = args.input
templateFile = args.template
outputFile = args.output
preprocessor = args.preprocessor
with open(inputFile) as f:
inputData = json.load(f)
if preprocessor:
preprocessorMod = importlib.import_module(preprocessor)
inputData = preprocessorMod.perform(inputData)
tmpl = Template(file=templateFile, searchList=[ inputData ])
with open(outputFile, 'w') as f:
f.write(str(tmpl))

60
rechnung.tex Normal file
View File

@ -0,0 +1,60 @@
\documentclass[12pt]{dinbrief}
\usepackage{german}
\usepackage{eurosym}
\usepackage{longtable}
\address{Ingenieurbüro\\
Wolfgang Hottgenroth\\
Eupenstr. 20\\
45259 Essen}
\backaddress{Ingenieurbüro W.\ Hottgenroth, Eupenstr. 20, 45259 Essen}
\signature{W.\ Hottgenroth} %% Hier Unterschrift einfuegen
\nowindowrules
% \yourmail{yourmail}
% \sign{sign}
\writer{wh} %% Hier eigenen Namen oder Kuerzel einfuegen
\phone{0174}{3072474} %% Hier eigene Telefon einfuegen
\bottomtext{\sffamily\footnotesize wh@ib-hottgenroth.de\\
Bankverbindung: IBAN DE96 3505 0105 0001 5037 05, Sparkasse Essen}
\begin{document}
%% Hier Adresse des Empfaengers einfuegen
\begin{letter}{Herrn Max Mustermann\\Dingsstr.\ 1\\12345 Dorf}
%% Hier Betreff einfuegen
\subject{Rechnung Nr. 2023-1}
%% Hier Anrede einfuegen
\opening{Hallo Max,}
für Ingenieurdienstleistungen erlaube ich mir entsprechend folgender Spezifikation die Rechnung zu stellen.
Ich bitte um Zahlung binnen zwei Wochen an unten angegebene Bankverbindung.
\begin{longtable}{|p{0.7cm}|p{2.5cm}|p{5.5cm}|p{1cm}|p{2.2cm}|p{2.2cm}|}
\hline \bf{Nr.} & \bf{Datum} & \bf{Leistung} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endfirsthead
\hline \bf{Nr.} & \bf{Datum} & \bf{Leistung} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endhead
\multicolumn{6}{r}{\em{b.w.}}
\endfoot
\hline \hline
\multicolumn{4}{| p{10cm} |}{Zwischensumme} & & \hfill \tt{220.00 \euro{}}\\ \hline
\multicolumn{4}{| p{10cm} |}{MwSt.} & \hfill \tt{19 \%} & \hfill \tt{41.80 \euro{}}\\ \hline
\multicolumn{4}{| p{10cm} |}{\bf{Summe}} & & \hfill \tt{261.80 \euro{}}\\ \hline
\endlastfoot
\tt{1}&
\tt{01.01.2023}&
\tt{Bla1}&
\tt{\hfill{}2}&
\tt{\hfill{}110.00 \euro{}}&
\tt{\hfill{}220.00 \euro{}}
\\ \hline
\end{longtable}
\closing{Mit freundlichen Gr"u"sen}
% \encl{encl}
\end{letter}
\end{document}

View File

@ -0,0 +1,22 @@
from decimal import Decimal
MwSt_TAX_RATE = Decimal(0.19)
def perform(inputData):
inputData['totalBeforeTaxes'] = Decimal(0)
for entry in inputData['entries']:
entry['totalprice'] = Decimal(entry['count']) * Decimal(entry['unitprice'])
inputData['totalBeforeTaxes'] += entry['totalprice']
inputData['totalBeforeTaxes'] = inputData['totalBeforeTaxes']
inputData['taxes'] = inputData['totalBeforeTaxes'] * MwSt_TAX_RATE
inputData['total'] = inputData['totalBeforeTaxes'] + inputData['taxes']
for entry in inputData['entries']:
entry['totalprice'] = f"{entry['totalprice']:.2f}"
entry['unitprice'] = f"{entry['unitprice']:.2f}"
inputData['totalBeforeTaxes'] = f"{inputData['totalBeforeTaxes']:.2f}"
inputData['taxes'] = f"{inputData['taxes']:.2f}"
inputData['total'] = f"{inputData['total']:.2f}"
return inputData

View File

@ -0,0 +1,8 @@
{
"billingNo": "2023-1",
"receipient": "Herrn Max Mustermann\\\\Dingsstr.\\ 1\\\\12345 Dorf",
"salutation": "Hallo Max",
"entries": [
{ "no": 1, "date": "01.01.2023", "description": "Bla1", "count": 2, "unitprice": 110.0 }
]
}

62
rechnung/rechnung.tmpl Normal file
View File

@ -0,0 +1,62 @@
\documentclass[12pt]{dinbrief}
\usepackage{german}
\usepackage{eurosym}
\usepackage{longtable}
\address{Ingenieurbüro\\
Wolfgang Hottgenroth\\
Eupenstr. 20\\
45259 Essen}
\backaddress{Ingenieurbüro W.\ Hottgenroth, Eupenstr. 20, 45259 Essen}
\signature{W.\ Hottgenroth} %% Hier Unterschrift einfuegen
\nowindowrules
% \yourmail{yourmail}
% \sign{sign}
\writer{wh} %% Hier eigenen Namen oder Kuerzel einfuegen
\phone{0174}{3072474} %% Hier eigene Telefon einfuegen
\bottomtext{\sffamily\footnotesize wh@ib-hottgenroth.de\\
Bankverbindung: IBAN DE96 3505 0105 0001 5037 05, Sparkasse Essen}
\begin{document}
%% Hier Adresse des Empfaengers einfuegen
\begin{letter}{${receipient}}
%% Hier Betreff einfuegen
\subject{Rechnung Nr. ${billingNo}}
%% Hier Anrede einfuegen
\opening{${salutation},}
für Ingenieurdienstleistungen erlaube ich mir entsprechend folgender Spezifikation die Rechnung zu stellen.
Ich bitte um Zahlung binnen zwei Wochen an unten angegebene Bankverbindung.
\begin{longtable}{|p{0.7cm}|p{2.5cm}|p{5.5cm}|p{1cm}|p{2.2cm}|p{2.2cm}|}
\hline \bf{Nr.} & \bf{Datum} & \bf{Leistung} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endfirsthead
\hline \bf{Nr.} & \bf{Datum} & \bf{Leistung} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endhead
\multicolumn{6}{r}{\em{b.w.}}
\endfoot
\hline \hline
\multicolumn{4}{| p{10cm} |}{Zwischensumme} & & \hfill \tt{${totalBeforeTaxes} \euro{}}\\ \hline
\multicolumn{4}{| p{10cm} |}{MwSt.} & \hfill \tt{19 \%} & \hfill \tt{${taxes} \euro{}}\\ \hline
\multicolumn{4}{| p{10cm} |}{\bf{Summe}} & & \hfill \tt{${total} \euro{}}\\ \hline
\endlastfoot
#for $entry in $entries
\tt{$entry['no']}&
\tt{$entry['date']}&
\tt{$entry['description']}&
\tt{\hfill{}$entry['count']}&
\tt{\hfill{}$entry['unitprice'] \euro{}}&
\tt{\hfill{}$entry['totalprice'] \euro{}}
\\ \hline
#end for
\end{longtable}
\closing{Mit freundlichen Gr"u"sen}
% \encl{encl}
\end{letter}
\end{document}

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
Cheetah3==3.2.6.post1

View File

@ -8,8 +8,8 @@
Wolfgang Hottgenroth\\ Wolfgang Hottgenroth\\
Eupenstr. 20\\ Eupenstr. 20\\
45259 Essen} 45259 Essen}
\backaddress{Ingenieurbüro Hottgenroth, Eupenstr. 20, 45259 Essen} \backaddress{Ingenieurbüro W.\ Hottgenroth, Eupenstr. 20, 45259 Essen}
\signature{xxx} %% Hier Unterschrift einfuegen \signature{W.\ Hottgenroth} %% Hier Unterschrift einfuegen
\nowindowrules \nowindowrules
% \yourmail{yourmail} % \yourmail{yourmail}
% \sign{sign} % \sign{sign}
@ -17,7 +17,7 @@
\phone{0174}{3072474} %% Hier eigene Telefon einfuegen \phone{0174}{3072474} %% Hier eigene Telefon einfuegen
\bottomtext{\sffamily\footnotesize wh@ib-hottgenroth.de\\ \bottomtext{\sffamily\footnotesize wh@ib-hottgenroth.de\\
Bankverbindung: IBAN DE96 3505 0105 0001 5987 62, Sparkasse Essen} Bankverbindung: IBAN DE96 3505 0105 0001 5037 05, Sparkasse Essen}
\begin{document} \begin{document}
%% Hier Adresse des Empfaengers einfuegen %% Hier Adresse des Empfaengers einfuegen
\begin{letter}{vorname nachname\\ \begin{letter}{vorname nachname\\
@ -32,46 +32,6 @@ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
\begin{longtable}{|p{1cm}|p{2cm}|p{6cm}|p{1cm}|p{2cm}|p{2cm}|}
\hline \bf{Nr.} & \bf{Datum} & \bf{Gegenstand} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endfirsthead
\hline \bf{Nr.} & \bf{Datum} & \bf{Gegenstand} & \bf{Anz.} & \bf{Einzel} & \bf{Summe} \\ \hline \hline
\endhead
\multicolumn{6}{r}{\em{b.w.}}
\endfoot
\hline \hline
\multicolumn{4}{| p{10cm} |}{Zwischensumme} & & \hfill 1 \euro{}\\ \hline
\multicolumn{4}{| p{10cm} |}{MwSt.} & 19 \% & \hfill 2 \euro{}\\ \hline
\multicolumn{4}{| p{10cm} |}{\bf{Summe}} & & \hfill \bf{3 \euro{}}\\ \hline
\endlastfoot
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\tt{1} & \tt{2} & \tt{3} & \hfill \tt{4} & \hfill \tt{5 \euro{}} & \hfill \tt{6 \euro{}} \\ \hline
\end{longtable}
\closing{Mit freundlichen Gr"u"sen} \closing{Mit freundlichen Gr"u"sen}
% \encl{encl} % \encl{encl}