gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated: start template for


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: start template for generating nicely formatted auditor reports
Date: Thu, 26 Oct 2017 22:40:03 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new a946dc3  start template for generating nicely formatted auditor reports
a946dc3 is described below

commit a946dc30bb53fa09e0a42cadd1e483b69ef2e349
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Oct 19 18:20:26 2017 +0200

    start template for generating nicely formatted auditor reports
---
 contrib/auditor-report.tex.j2 | 89 +++++++++++++++++++++++++++++++++++++++++++
 contrib/render.py             | 38 ++++++++++++++++++
 contrib/samples/auditor.json  |  4 +-
 src/auditor/taler-auditor.c   |  8 ++--
 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 0000000..2b3eb9f
--- /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 0000000..d31c7f9
--- /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.
+
address@hidden 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 1848492..f9c09b3 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 3e4eca1..1e69e31 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,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]