format of output

This commit is contained in:
Wolfgang Hottgenroth 2022-03-31 22:30:09 +02:00
parent 0d4e33505e
commit 4553272c42
5 changed files with 70 additions and 9 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ ENV
api/config/dbconfig.ini
api/config/authservice.pub
cli/config/dbconfig.ini
cli/output/
*~
.*~
.vscode/

View File

@ -1,4 +1,4 @@
from db import dbGetMany
from db import dbGetMany, dbGetOne
from loguru import logger
import datetime
import iso8601
@ -15,11 +15,40 @@ def perform(dbh, params):
"params": {
'year': year
}
}
)
overview = dbGetMany(
dbh,
{
"statement": "select sum(amount), category from account_statement_v where fiscal_year = %(year)s group by category",
"params": {
'year': year
}
}
)
sum_related = dbGetOne(
dbh,
{
"statement": "select coalesce(sum(amount), 0::numeric(10,2)) as sum from account_statement_v where fiscal_year = %(year)s and category != 'nicht abrechenbare Positionen'",
"params": {
'year': year
}
}
)
sum_unrelated = dbGetOne(
dbh,
{
"statement": "select coalesce(sum(amount), 0::numeric(10,2)) as sum from account_statement_v where fiscal_year = %(year)s and category = 'nicht abrechenbare Positionen'",
"params": {
'year': year
}
}
)
template = getParam(params, 'template', 'accountStatement.tmpl')
input = { 'year': year, 'entries': accountEntries }
input = { 'year': year, 'entries': accountEntries, 'overview': overview, 'related': sum_related, 'unrelated': sum_unrelated }
tmpl = Template(file=template, searchList=[ input ])
print(tmpl)

View File

@ -32,7 +32,12 @@ if [ "$YEAR" = "" ]; then
exit 1
fi
python3.10 hv2cli.py -o AccountStatement -p '{"year":'$YEAR'}' > $YEAR.tex
python3.10 hv2cli.py -o AccountStatement -p '{"year":'$YEAR'}' > ./output/$YEAR.tex
pushd ./output
pdflatex $YEAR.tex
pdflatex $YEAR.tex
pdflatex $YEAR.tex
if [ "$SHOW" = "1" ]; then
@ -43,3 +48,4 @@ if [ "$PRINT" = "1" ]; then
lpr $PRINTER $YEAR.pdf
fi
popd

View File

@ -9,12 +9,12 @@
\begin{document}
\subsection*{Kontoauszug $year}
\subsection*{Account Statement $year}
\begin{longtable}{|r|r|p{5cm}|r|r|r|p{3cm}|r|p{5cm}|}
\hline \textcolor{blue}{\tt{id}} & \textcolor{blue}{\tt{date}} & \textcolor{blue}{\tt{description}} & \textcolor{blue}{\tt{amount}} & \textcolor{blue}{\tt{docNo}} & \textcolor{blue}{\tt{year}} & \textcolor{blue}{\tt{category}} & \textcolor{blue}{\tt{isRef}} & \textcolor{blue}{\tt{baseAccount}} \\ \hline \hline
\begin{longtable}{|r|r|p{6cm}|r|r|r|p{3cm}|r|p{5cm}|}
\hline \textcolor{blue}{\bf{ID}} & \textcolor{blue}{\bf{Date}} & \textcolor{blue}{\bf{Description}} & \textcolor{blue}{\bf{Amount}} & \textcolor{blue}{\bf{DocNo}} & \textcolor{blue}{\bf{Year}} & \textcolor{blue}{\bf{Category}} & \textcolor{blue}{\bf{IsRef}} & \textcolor{blue}{\bf{BaseAccount}} \\ \hline \hline
\endfirsthead
\hline \textcolor{blue}{\tt{id}} & \textcolor{blue}{\tt{date}} & \textcolor{blue}{\tt{description}} & \textcolor{blue}{\tt{amount}} & \textcolor{blue}{\tt{docNo}} & \textcolor{blue}{\tt{year}} & \textcolor{blue}{\tt{category}} & \textcolor{blue}{\tt{isRef}} & \textcolor{blue}{\tt{baseAccount}} \\ \hline \hline
\hline \textcolor{blue}{\bf{ID}} & \textcolor{blue}{\bf{Date}} & \textcolor{blue}{\bf{Description}} & \textcolor{blue}{\bf{Amount}} & \textcolor{blue}{\bf{DocNo}} & \textcolor{blue}{\bf{Year}} & \textcolor{blue}{\bf{Category}} & \textcolor{blue}{\bf{IsRef}} & \textcolor{blue}{\bf{BaseAccount}} \\ \hline \hline
\endhead
\multicolumn{9}{r}{\em{to be continued}}
\endfoot
@ -26,7 +26,7 @@
#if $entry['amount'] <= 0
\textcolor{red}{#slurp
#end if
\tt{$entry['amount']}#slurp
\tt{$entry['amount']} \,\euro{}#slurp
#if $entry['amount'] <= 0
}#slurp
#end if
@ -34,4 +34,26 @@
#end for
\end{longtable}
\pagebreak
\subsection*{Overviews}
\begin{tabular}{|l|r|} \hline
\hline \textcolor{blue}{\bf{category}} & \textcolor{blue}{\bf{sum}} \\
#for $entry in $overview
\hline \tt{$entry['category']} & #slurp
#if $entry['sum'] <= 0
\textcolor{red}{#slurp
#end if
\tt{$entry['sum']} \,\euro{}#slurp
#if $entry['sum'] <= 0
}#slurp
#end if
\\
#end for
\hline \hline related & \tt{$related['sum']} \,\euro{} \\
\hline unrelated & \tt{$unrelated['sum']} \,\euro{} \\
\hline \hline
\end{tabular}
\end{document}

View File

@ -18,3 +18,6 @@ create or replace view account_statement_v as
ae.base_account = bac.id and
ac.id = 1000
order by created_at;
grant select on account_statement_v to hv2;