aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-19 18:20:26 +0200
committerChristian Grothoff <christian@grothoff.org>2017-10-26 22:39:59 +0200
commita946dc30bb53fa09e0a42cadd1e483b69ef2e349 (patch)
treed75d7e39a58906f0e4b0c9d7179328a2200fe047
parentd107baa2c30980b85f6330f3f7c3287b4d58708b (diff)
start template for generating nicely formatted auditor reports
-rw-r--r--contrib/auditor-report.tex.j289
-rwxr-xr-xcontrib/render.py38
-rw-r--r--contrib/samples/auditor.json4
-rw-r--r--src/auditor/taler-auditor.c8
4 files changed, 133 insertions, 6 deletions
diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2
new file mode 100644
index 000000000..2b3eb9fc7
--- /dev/null
+++ b/contrib/auditor-report.tex.j2
@@ -0,0 +1,89 @@
+\documentclass{article} % {acmart}
+\usepackage{url}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+
+\begin{document}
+
+\title{Taler Auditor Report}
+\maketitle
+
+\section{Operations}
+
+The balance of the escrow account should
+be {\bf
+\mbox{
+ {{ data.report_denomination_balance[0].total_escrow_balance.value }}.{{ data.report_denomination_balance[0].total_escrow_balance.fraction }}
+ {{ data.report_denomination_balance[0].total_escrow_balance.currency }}}}.
+
+\noindent
+The active operational risk stands at
+\mbox{
+{\bf
+ {{ data.report_denomination_balance[0].total_active_risk.value }}.{{ data.report_denomination_balance[0].total_active_risk.fraction }}
+ {{ data.report_denomination_balance[0].total_active_risk.currency }}}}.
+
+
+\section{Income}
+
+\begin{table}[h!]
+ \caption{Revenue}
+ \label{table:revenue}
+ \begin{tabular}{l|rl}
+ Category & Amount & \\ \hline \hline
+ Withdraw fees &
+ {{ data.reserve_balance[0].total_withdraw_fee_income.value }}.{{ data.reserve_balance[0].total_withdraw_fee_income.fraction }} &
+ {{ data.reserve_balance[0].total_withdraw_fee_income.currency }} \\
+ Deposit fees &
+ {{ data.report_denomination_balance[0].total_deposit_fee_income.value }}.{{ data.report_denomination_balance[0].total_deposit_fee_income.fraction }} &
+ {{ data.report_denomination_balance[0].total_deposit_fee_income.currency }} \\
+ Melt fees &
+ {{ data.report_denomination_balance[0].total_melt_fee_income.value }}.{{ data.report_denomination_balance[0].total_melt_fee_income.fraction }} &
+ {{ data.report_denomination_balance[0].total_melt_fee_income.currency }} \\
+ Refund fees &
+ {{ data.report_denomination_balance[0].total_refund_fee_income.value }}.{{ data.report_denomination_balance[0].total_refund_fee_income.fraction }} &
+ {{ data.report_denomination_balance[0].total_refund_fee_income.currency }} \\
+ Aggregation fees &
+ {{ data.aggregation_fee_balance[0].total_aggregation_fee_income.value }}.{{ data.aggregation_fee_balance[0].total_aggregation_fee_income.fraction }} &
+ {{ data.aggregation_fee_balance[0].total_aggregation_fee_income.currency }} \\
+ {\bf Total} & TBD & TBD \\
+\end{tabular}
+\end{table}
+
+\section{Irregularities}
+
+{% if data.emergencies|length() == 0 %}
+ {\bf No emergencies detected.}
+{% else %}
+ \begin{table}
+ \caption{Emergencies.}
+ \label{table:emergencies}
+ TBD.
+ \end{table}
+ {% endif %}
+
+
+{% if data.reserve_inconsistencies|length() == 0 %}
+ {\bf No reserve inconsistencies detected.}
+{% else %}
+ \begin{table}
+ \caption{Reserve inconsistencies.}
+ \label{table:reserve:inconsistencies}
+ \begin{tabular}{p{1.5cm}|rl|rl|p{4cm}}
+ {\bf Reserve} & \multicolumn{2}{|c|}{Expected} & \multicolumn{2}{|c|}{Observed} & Diagnostic \\ \hline \hline
+{% for item in data.reserve_inconsistencies %}
+ \multicolumn{6}{l}{ {\tt {{ item.reserve_pub }} } } \\
+ &
+ {{ item.expected.value }}.{{ item.expected.fraction }} &
+ {{ item.expected.currency }} &
+ {{ item.observed.value }}.{{ item.observed.fraction }} &
+ {{ item.observed.currency }} &
+ {{ item.diagnostic }} \\ \hline
+{% endfor %}
+ \hline
+ {\bf Reserve} & Expected & Observed & Diagnostic \\
+ \end{tabular}
+ \end{table}
+{% endif %}
+
+\end{document}
diff --git a/contrib/render.py b/contrib/render.py
new file mode 100755
index 000000000..d31c7f9bd
--- /dev/null
+++ b/contrib/render.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+# This file is in the public domain.
+
+"""
+Expand Jinja2 templates based on JSON input.
+
+First command-line argument must be the JSON input.
+The tool reads the template from stdin and writes
+the expanded output to stdout.
+
+@author Christian Grothoff
+"""
+
+import sys
+import json
+import jinja2
+from jinja2 import BaseLoader
+
+
+class StdinLoader(BaseLoader):
+ def __init__ (self):
+ self.path = '-'
+ def get_source(self, environment, template):
+ source = sys.stdin.read().decode('utf-8')
+ return source, self.path, lambda: false
+
+
+jsonFile = open (sys.argv[1], 'r')
+jsonData = json.load(jsonFile)
+
+jinjaEnv = jinja2.Environment(loader=StdinLoader(),
+ lstrip_blocks=True,
+ trim_blocks=True,
+ undefined=jinja2.StrictUndefined,
+ autoescape=False)
+tmpl = jinjaEnv.get_template('stdin');
+
+print(tmpl.render(data = jsonData))
diff --git a/contrib/samples/auditor.json b/contrib/samples/auditor.json
index 1848492d4..f9c09b3e8 100644
--- a/contrib/samples/auditor.json
+++ b/contrib/samples/auditor.json
@@ -2,7 +2,7 @@
"emergencies": [],
"row-inconsistencies": [],
"row-minor-inconsistencies": [],
- "reserve-inconsistencies": [
+ "reserve_inconsistencies": [
{
"reserve_pub": "8ZV52AB6MHX8YVV0W0FHVDEZB54197JB85703J0E0AY6ZC4BFR7G",
"expected": {
@@ -11734,4 +11734,4 @@
}
}
]
-} \ No newline at end of file
+}
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index 3e4eca15b..1e69e3108 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -3886,10 +3886,10 @@ run (void *cls,
TALER_EXCHANGEDB_plugin_unload (edb);
report = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"emergencies", report_emergencies,
- "row-inconsistencies", report_row_inconsistencies,
- "row-minor-inconsistencies", report_row_minor_inconsistencies,
- "reserve-inconsistencies", report_reserve_inconsistencies,
- "wire-out-inconsistencies", report_wire_out_inconsistencies,
+ "row_inconsistencies", report_row_inconsistencies,
+ "row_minor_inconsistencies", report_row_minor_inconsistencies,
+ "reserve_inconsistencies", report_reserve_inconsistencies,
+ "wire_out_inconsistencies", report_wire_out_inconsistencies,
"coin_inconsistencies", report_coin_inconsistencies,
"reserve_balance", report_reserve_balances,
"aggregation_fee_balance", report_aggregation_fee_balances,