error analysis
This commit is contained in:
parent
ac1636c162
commit
b1b81eeb07
@ -48,7 +48,51 @@ def perform(dbh, params):
|
||||
}
|
||||
)
|
||||
|
||||
sum_total = dbGetOne(
|
||||
dbh,
|
||||
{
|
||||
"statement": "select sum(amount) as sum from account_statement_v where fiscal_year = %(year)s",
|
||||
"params": {
|
||||
'year': year
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sum_error = dbGetMany(
|
||||
dbh,
|
||||
{
|
||||
"statement": """
|
||||
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 1 as error, 'booked in %(year1)s, accounted in %(year0)s' as remark from account_statement_v where fiscal_year = %(year0)s and extract(year from created_at) = %(year1)s
|
||||
union
|
||||
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 2 as error, 'booked in %(year0)s, accounted in %(year1)s' as remark from account_statement_v where fiscal_year = %(year1)s and extract(year from created_at) = %(year0)s
|
||||
union
|
||||
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 3 as error, 'booked in %(year2)s, accounted in %(year1)s' as remark from account_statement_v where fiscal_year = %(year1)s and extract(year from created_at) = %(year2)s
|
||||
union
|
||||
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 4 as error, 'booked in %(year1)s, accounted in %(year2)s' as remark from account_statement_v where fiscal_year = %(year2)s and extract(year from created_at) = %(year1)s
|
||||
order by error
|
||||
""",
|
||||
"params": {
|
||||
'year0': year - 1,
|
||||
'year1': year,
|
||||
'year2': year + 1
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
raw_total = sum_total['sum']
|
||||
logger.info(f"{raw_total=}")
|
||||
err1 = sum_error[0]['sum']
|
||||
logger.info(f"{err1=}")
|
||||
err2 = sum_error[1]['sum']
|
||||
logger.info(f"{err2=}")
|
||||
err3 = sum_error[2]['sum']
|
||||
logger.info(f"{err3=}")
|
||||
err4 = sum_error[3]['sum']
|
||||
logger.info(f"{err4=}")
|
||||
adjusted_total = raw_total - err1 + err2 - err3 + err4
|
||||
logger.info(f"{adjusted_total=}")
|
||||
|
||||
template = getParam(params, 'template', 'accountStatement.tmpl')
|
||||
input = { 'year': year, 'entries': accountEntries, 'overview': overview, 'related': sum_related, 'unrelated': sum_unrelated }
|
||||
input = { 'year': year, 'entries': accountEntries, 'overview': overview, 'related': sum_related, 'unrelated': sum_unrelated, 'total': sum_total, 'errors': sum_error, 'adjusted_total' :adjusted_total }
|
||||
tmpl = Template(file=template, searchList=[ input ])
|
||||
print(tmpl)
|
||||
|
@ -53,7 +53,21 @@
|
||||
|
||||
\hline \hline related & \tt{$related['sum']} \,\euro{} \\
|
||||
\hline unrelated & \tt{$unrelated['sum']} \,\euro{} \\
|
||||
\hline total & \tt{$total['sum']} \,\euro{} \\
|
||||
\hline \hline
|
||||
\end{tabular}
|
||||
|
||||
\pagebreak
|
||||
\subsection*{Errors}
|
||||
|
||||
\begin{tabular}{|r|r|l|} \hline
|
||||
\hline \textcolor{blue}{\bf{type}} & \textcolor{blue}{\bf{sum}} & \textcolor{blue}{\bf{remark}} \\
|
||||
#for $entry in $errors
|
||||
\hline \tt{$entry['error']} & \tt{$entry['sum']} \,\euro{} & \tt{$entry['remark']} \\
|
||||
#end for
|
||||
\hline \tt{0} & \tt{$adjusted_total} \,\euro{} & \tt{adjusted total} \\
|
||||
\hline \hline
|
||||
\end{tabular}
|
||||
|
||||
|
||||
\end{document}
|
||||
|
Loading…
x
Reference in New Issue
Block a user