Abrechnungsskript

This commit is contained in:
Wolfgang Hottgenroth 2022-04-01 12:04:33 +02:00
parent 452b4f69bd
commit d0771be1d1
3 changed files with 69 additions and 9 deletions

View File

@ -23,7 +23,7 @@ def perform(dbh, params):
{ {
"statement": "statement":
""" """
select sum(ae.amount) as sum, select (coalesce(sum(ae.amount), 0::numeric(10,2)) * -1) as sum,
aec.description as category, aec.description as category,
aec.considerminusarea as considerminusarea aec.considerminusarea as considerminusarea
from account_t a, from account_t a,
@ -48,13 +48,13 @@ def perform(dbh, params):
where p.account = a.id and where p.account = a.id and
ae.account = a.id and ae.account = a.id and
aec.overhead_relevant = 't' and aec.overhead_relevant = 't' and
aec.id not in (select distinct account_entry_category from account_entry_t) and aec.id not in (select distinct account_entry_category from account_entry_t where fiscal_year = %(year)s) and
ae.fiscal_year = %(year)s and ae.fiscal_year = %(year)s and
p.id = %(premise)s p.id = %(premise)s
group by category, considerminusarea group by category, considerminusarea
union union
select 120 as sum, select 120 as sum,
'Waschmaschine' as category, '16. Waschmaschine' as category,
false as considerminusarea false as considerminusarea
from premise_t from premise_t
where id = %(premise)s where id = %(premise)s
@ -181,7 +181,7 @@ def perform(dbh, params):
for house in houses.values(): for house in houses.values():
logger.debug(f"Processing item: {house}") logger.debug(f"Processing item: {house}")
outputFile = f"{overviewPrefix}-{house['details']['id']}.{overviewSuffix}" outputFile = f"./output/{overviewPrefix}-{house['details']['id']}.{overviewSuffix}"
tmpl = Template(file=overviewTemplate, searchList=[ house ]) tmpl = Template(file=overviewTemplate, searchList=[ house ])
logger.debug(tmpl) logger.debug(tmpl)
with open(outputFile, 'w') as f: with open(outputFile, 'w') as f:

55
cli/OverheadAccounts.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
PRINT="0"
while getopts "y:phP:" flag
do
case "${flag}" in
h)
echo "y ... year for statement";
echo "p ... print output";
echo "P ... printer name";
exit 1;
;;
y)
YEAR=${OPTARG}
;;
p)
PRINT="1"
;;
P)
PRINTER="-P ${OPTARG}"
;;
esac
done
if [ "$YEAR" = "" ]; then
echo "give year for statement as argument"
exit 1
fi
python3.10 hv2cli.py -o OverheadAccounts -p '{"year":'$YEAR'}'
pushd ./output
for I in letter-*.tex; do
pdflatex $I
pdflatex $I
pdflatex $I
done
for I in overview-*.tex; do
pdflatex $I
pdflatex $I
pdflatex $I
done
if [ "$PRINT" = "1" ]; then
for I in letter-*.pdf; do
lpr $PRINTER $I
done
for I in overview-*.pdf; do
lpr $PRINTER $I
done
fi
popd

View File

@ -1,4 +1,5 @@
\documentclass[12pt]{article} \documentclass[12pt]{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{german} \usepackage{german}
\usepackage{eurosym} \usepackage{eurosym}
\usepackage[a4paper, left=2cm, right=2cm, top=2cm]{geometry} \usepackage[a4paper, left=2cm, right=2cm, top=2cm]{geometry}
@ -7,8 +8,10 @@
\begin{document} \begin{document}
\subsection*{Betriebskostenabrechnung} \subsection*{Aufstellung}
über die Ermittlung der Betriebskosten gemäß §27 II. BV
\vspace{15mm}
\begin{tabular}{ll} \begin{tabular}{ll}
Objekt & $details['description'] \\ Objekt & $details['description'] \\
@ -18,23 +21,25 @@ Eigent"umer & Nober Grundbesitz GmbH \\
\addvspace{1cm} \addvspace{1cm}
\begin{tabular}{|p{5cm}|r|r|r|} \begin{tabular}{|p{7cm}|r|r|r|}
\hline Art & Wohnungen & andere Fl"achen & Gesamtfl"ache \\ \hline Art & Wohnungen & andere Fl"achen & Gesamtfl"ache \\
\hline \hline
\hline Fl"ache & \tt{$areas['flat_area']\,m\textsuperscript{2}} & \tt{$areas['other_area']\,m\textsuperscript{2}} & \tt{$areas['total_area']\,m\textsuperscript{2}} \\ \hline Fl"ache & \tt{$areas['flat_area']\,m\textsuperscript{2}} & \tt{$areas['other_area']\,m\textsuperscript{2}} & \tt{$areas['total_area']\,m\textsuperscript{2}} \\
\hline Faktor & \tt{#echo '%.10f' % $areas['flat_factor'] #} & \tt{#echo '%.10f' % $areas['other_factor'] #} & \\ \hline Faktor & \tt{#echo '%.10f' % $areas['flat_factor'] #} & \tt{#echo '%.10f' % $areas['other_factor'] #} & \\
\hline \hline \hline
#for $item in $overhead_items #for $item in $overhead_items
\hline $item['category'] & \tt{#echo '%.2f' % $item['flat_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['other_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['sum'] #\,\euro{}} \\ \hline $item['category'] & \tt{#echo '%.2f' % $item['flat_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['other_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['sum'] #\,\euro{}} \\
#end for #end for
\hline \multicolumn{4}{c}{ } \\ \hline
% \hline \multicolumn{4}{c}{ } \\
\hline Zwischensumme & \tt{#echo '%.2f' % $flat_sum #\,\euro{}} & \tt{#echo '%.2f' % $other_sum #\,\euro{}} & \tt{#echo '%.2f' % $total_sum #\,\euro{}} \\ \hline Zwischensumme & \tt{#echo '%.2f' % $flat_sum #\,\euro{}} & \tt{#echo '%.2f' % $other_sum #\,\euro{}} & \tt{#echo '%.2f' % $total_sum #\,\euro{}} \\
\hline Umlageausfallwagnis & \tt{#echo '%.2f' % $umlage_ausfall_wagnis #\,\euro{}} & & \\ \hline Umlageausfallwagnis & \tt{#echo '%.2f' % $umlage_ausfall_wagnis #\,\euro{}} & & \\
\hline Summe & \tt{#echo '%.2f' % $flat_sum_2 #\,\euro{}} & & \\ \hline Summe & \tt{#echo '%.2f' % $flat_sum_2 #\,\euro{}} & & \\
\hline \multicolumn{4}{c}{ } \\ \hline
% \hline \multicolumn{4}{c}{ } \\
\hline Anteil pro Monat und m\textsuperscript{2} & \tt{#echo '%.10f' % $part_by_montharea #\,\euro{}} & & \\ \hline Anteil pro Monat und m\textsuperscript{2} & \tt{#echo '%.10f' % $part_by_montharea #\,\euro{}} & & \\
\hline \hline
\end{tabular} \end{tabular}