fix FIXME: total up irregular paybacks and add to report
This commit is contained in:
parent
e369dcfc25
commit
0145609890
@ -142,10 +142,17 @@ be {\bf {{ data.total_escrow_balance }}}.
|
||||
The active operational risk stands at
|
||||
{\bf {{ data.total_active_risk }}}.
|
||||
|
||||
{% if (data.total_payback_loss.value != 0) or (data.total_payback_loss.fraction != 0) %}
|
||||
\noindent
|
||||
Loss (actualized risk from paybacks) is
|
||||
{\bf {{ data.total_payback_loss }}}.
|
||||
{% endif %}
|
||||
|
||||
{% if (data.total_irregular_paybacks.value != 0) or (data.total_irregular_paybacks.fraction != 0) %}
|
||||
\noindent
|
||||
Paybacks of non-revoked coins are at
|
||||
{\bf {{ data.total_irregular_paybacks }}}.
|
||||
{% endif %}
|
||||
|
||||
\section{Income}
|
||||
|
||||
|
@ -318,6 +318,11 @@ static struct TALER_Amount total_risk;
|
||||
*/
|
||||
static struct TALER_Amount total_payback_loss;
|
||||
|
||||
/**
|
||||
* Paybacks we made on denominations that were not revoked (!?).
|
||||
*/
|
||||
static struct TALER_Amount total_irregular_paybacks;
|
||||
|
||||
/**
|
||||
* Total withdraw fees earned.
|
||||
*/
|
||||
@ -1339,9 +1344,10 @@ handle_payback_by_reserve (void *cls,
|
||||
report_row_inconsistency ("payback",
|
||||
rowid,
|
||||
"denomination key not in revocation set");
|
||||
/* FIXME: add amount involved to some loss statistic!?
|
||||
It's kind-of not a loss (we just paid back), OTOH, it is
|
||||
certainly irregular and involves some amount. */
|
||||
GNUNET_break (GNUNET_OK ==
|
||||
TALER_amount_add (&total_irregular_paybacks,
|
||||
&total_irregular_paybacks,
|
||||
amount));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4628,7 +4634,8 @@ analyze_coins (void *cls)
|
||||
&total_melt_fee_income,
|
||||
&total_refund_fee_income,
|
||||
&total_risk,
|
||||
&total_payback_loss);
|
||||
&total_payback_loss,
|
||||
&total_irregular_paybacks);
|
||||
if (0 > qsx)
|
||||
{
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
|
||||
@ -4727,7 +4734,8 @@ analyze_coins (void *cls)
|
||||
&total_melt_fee_income,
|
||||
&total_refund_fee_income,
|
||||
&total_risk,
|
||||
&total_payback_loss);
|
||||
&total_payback_loss,
|
||||
&total_irregular_paybacks);
|
||||
else
|
||||
qs = adb->insert_balance_summary (adb->cls,
|
||||
asession,
|
||||
@ -4737,7 +4745,8 @@ analyze_coins (void *cls)
|
||||
&total_melt_fee_income,
|
||||
&total_refund_fee_income,
|
||||
&total_risk,
|
||||
&total_payback_loss);
|
||||
&total_payback_loss,
|
||||
&total_irregular_paybacks);
|
||||
if (0 >= qs)
|
||||
{
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
@ -5316,6 +5325,9 @@ run (void *cls,
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_get_zero (currency,
|
||||
&total_payback_loss));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_get_zero (currency,
|
||||
&total_irregular_paybacks));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_get_zero (currency,
|
||||
&total_withdraw_fee_income));
|
||||
@ -5598,7 +5610,9 @@ run (void *cls,
|
||||
GNUNET_STRINGS_absolute_time_to_string (start_time)),
|
||||
"auditor_end_time", json_string (
|
||||
GNUNET_STRINGS_absolute_time_to_string (
|
||||
GNUNET_TIME_absolute_get ()))
|
||||
GNUNET_TIME_absolute_get ())),
|
||||
"total_irregular_paybacks",
|
||||
TALER_JSON_from_amount (&total_irregular_paybacks)
|
||||
);
|
||||
GNUNET_break (NULL != report);
|
||||
json_dumpf (report,
|
||||
|
@ -172,6 +172,8 @@ CREATE TABLE IF NOT EXISTS auditor_balance_summary
|
||||
,risk_frac INT4 NOT NULL
|
||||
,loss_val INT8 NOT NULL
|
||||
,loss_frac INT4 NOT NULL
|
||||
,irregular_payback_val INT8 NOT NULL
|
||||
,irregular_payback_frac INT4 NOT NULL
|
||||
);
|
||||
-- Table with historic profits; basically, when a denom_pub has
|
||||
-- expired and everything associated with it is garbage collected,
|
||||
|
@ -614,9 +614,11 @@ postgres_get_session (void *cls)
|
||||
",risk_frac"
|
||||
",loss_val"
|
||||
",loss_frac"
|
||||
",irregular_payback_val"
|
||||
",irregular_payback_frac"
|
||||
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,"
|
||||
" $11,$12,$13);",
|
||||
13),
|
||||
" $11,$12,$13,$14,$15);",
|
||||
15),
|
||||
/* Used in #postgres_update_balance_summary() */
|
||||
GNUNET_PQ_make_prepare ("auditor_balance_summary_update",
|
||||
"UPDATE auditor_balance_summary SET"
|
||||
@ -632,8 +634,10 @@ postgres_get_session (void *cls)
|
||||
",risk_frac=$10"
|
||||
",loss_val=$11"
|
||||
",loss_frac=$12"
|
||||
" WHERE master_pub=$13;",
|
||||
13),
|
||||
",irregular_payback_val=$13"
|
||||
",irregular_payback_frac=$14"
|
||||
" WHERE master_pub=$15;",
|
||||
15),
|
||||
/* Used in #postgres_get_balance_summary() */
|
||||
GNUNET_PQ_make_prepare ("auditor_balance_summary_select",
|
||||
"SELECT"
|
||||
@ -649,6 +653,8 @@ postgres_get_session (void *cls)
|
||||
",risk_frac"
|
||||
",loss_val"
|
||||
",loss_frac"
|
||||
",irregular_payback_val"
|
||||
",irregular_payback_frac"
|
||||
" FROM auditor_balance_summary"
|
||||
" WHERE master_pub=$1;",
|
||||
1),
|
||||
@ -2620,6 +2626,7 @@ postgres_get_denomination_balance (void *cls,
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @param loss materialized @a risk from payback
|
||||
* @param irregular_payback paybacks on non-revoked coins
|
||||
* @return transaction status code
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
@ -2632,7 +2639,8 @@ postgres_insert_balance_summary (void *cls,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
const struct TALER_Amount *risk,
|
||||
const struct TALER_Amount *loss)
|
||||
const struct TALER_Amount *loss,
|
||||
const struct TALER_Amount *irregular_payback)
|
||||
{
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||
@ -2642,6 +2650,7 @@ postgres_insert_balance_summary (void *cls,
|
||||
TALER_PQ_query_param_amount (refund_fee_balance),
|
||||
TALER_PQ_query_param_amount (risk),
|
||||
TALER_PQ_query_param_amount (loss),
|
||||
TALER_PQ_query_param_amount (irregular_payback),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
@ -2675,6 +2684,7 @@ postgres_insert_balance_summary (void *cls,
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @param loss materialized @a risk from payback
|
||||
* @param irregular_payback paybacks made on non-revoked coins
|
||||
* @return transaction status code
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
@ -2687,7 +2697,8 @@ postgres_update_balance_summary (void *cls,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
const struct TALER_Amount *risk,
|
||||
const struct TALER_Amount *loss)
|
||||
const struct TALER_Amount *loss,
|
||||
const struct TALER_Amount *irregular_payback)
|
||||
{
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
TALER_PQ_query_param_amount (denom_balance),
|
||||
@ -2696,6 +2707,7 @@ postgres_update_balance_summary (void *cls,
|
||||
TALER_PQ_query_param_amount (refund_fee_balance),
|
||||
TALER_PQ_query_param_amount (risk),
|
||||
TALER_PQ_query_param_amount (loss),
|
||||
TALER_PQ_query_param_amount (irregular_payback),
|
||||
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
@ -2718,6 +2730,7 @@ postgres_update_balance_summary (void *cls,
|
||||
* @param[out] refund_fee_balance total refund fees collected for this DK
|
||||
* @param[out] risk maximum risk exposure of the exchange
|
||||
* @param[out] loss losses from payback (on revoked denominations)
|
||||
* @param[out] irregular_payback paybacks on NOT revoked denominations
|
||||
* @return transaction status code
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
@ -2729,7 +2742,8 @@ postgres_get_balance_summary (void *cls,
|
||||
struct TALER_Amount *melt_fee_balance,
|
||||
struct TALER_Amount *refund_fee_balance,
|
||||
struct TALER_Amount *risk,
|
||||
struct TALER_Amount *loss)
|
||||
struct TALER_Amount *loss,
|
||||
struct TALER_Amount *irregular_payback)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
@ -2743,6 +2757,7 @@ postgres_get_balance_summary (void *cls,
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance", refund_fee_balance),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("risk", risk),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("loss", loss),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_payback", irregular_payback),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
|
@ -392,6 +392,8 @@ run (void *cls)
|
||||
struct TALER_Amount rbalance2;
|
||||
struct TALER_Amount loss;
|
||||
struct TALER_Amount loss2;
|
||||
struct TALER_Amount iirp;
|
||||
struct TALER_Amount iirp2;
|
||||
uint64_t nissued;
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
@ -415,6 +417,9 @@ run (void *cls)
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (CURRENCY ":1.6",
|
||||
&loss));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (CURRENCY ":1.1",
|
||||
&iirp));
|
||||
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
plugin->insert_denomination_balance (plugin->cls,
|
||||
@ -474,7 +479,8 @@ run (void *cls)
|
||||
&deposit_fee_balance,
|
||||
&denom_balance,
|
||||
&rbalance,
|
||||
&loss));
|
||||
&loss,
|
||||
&iirp));
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Test: update_balance_summary\n");
|
||||
@ -488,7 +494,8 @@ run (void *cls)
|
||||
&melt_fee_balance,
|
||||
&refund_fee_balance,
|
||||
&rbalance,
|
||||
&loss));
|
||||
&loss,
|
||||
&iirp));
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Test: get_balance_summary\n");
|
||||
@ -499,6 +506,7 @@ run (void *cls)
|
||||
ZR_BLK (&refund_fee_balance2);
|
||||
ZR_BLK (&rbalance2);
|
||||
ZR_BLK (&loss2);
|
||||
ZR_BLK (&iirp2);
|
||||
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
plugin->get_balance_summary (plugin->cls,
|
||||
@ -509,7 +517,8 @@ run (void *cls)
|
||||
&melt_fee_balance2,
|
||||
&refund_fee_balance2,
|
||||
&rbalance2,
|
||||
&loss2));
|
||||
&loss2,
|
||||
&iirp2));
|
||||
|
||||
FAILIF ( (0 != GNUNET_memcmp (&denom_balance2,
|
||||
&denom_balance) ) ||
|
||||
@ -523,6 +532,8 @@ run (void *cls)
|
||||
&rbalance));
|
||||
FAILIF (0 != GNUNET_memcmp (&loss2,
|
||||
&loss));
|
||||
FAILIF (0 != GNUNET_memcmp (&iirp2,
|
||||
&iirp));
|
||||
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
|
@ -1302,6 +1302,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @param payback_loss actual losses from payback (actualized @a risk)
|
||||
* @param irregular_paybacks paybacks made of non-revoked coins (reduces
|
||||
* risk, but should never happen)
|
||||
* @return transaction status code
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
@ -1313,7 +1315,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
const struct TALER_Amount *risk,
|
||||
const struct TALER_Amount *payback_loss);
|
||||
const struct TALER_Amount *payback_loss,
|
||||
const struct TALER_Amount *irregular_paybacks);
|
||||
|
||||
|
||||
/**
|
||||
@ -1329,6 +1332,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @param payback_loss actual losses from payback (actualized @a risk)
|
||||
* @param irregular_paybacks paybacks made of non-revoked coins (reduces
|
||||
* risk, but should never happen)
|
||||
* @return transaction status code
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
@ -1340,7 +1345,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
const struct TALER_Amount *risk,
|
||||
const struct TALER_Amount *payback_loss);
|
||||
const struct TALER_Amount *payback_loss,
|
||||
const struct TALER_Amount *irregular_paybacks);
|
||||
|
||||
|
||||
/**
|
||||
@ -1355,6 +1361,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
* @param[out] refund_fee_balance total refund fees collected for this DK
|
||||
* @param[out] risk maximum risk exposure of the exchange
|
||||
* @param[out] payback_loss actual losses from payback (actualized @a risk)
|
||||
* @param[out] irregular_paybacks paybacks made of non-revoked coins (reduces
|
||||
* risk, but should never happen)
|
||||
* @return transaction status code
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
@ -1366,7 +1374,8 @@ struct TALER_AUDITORDB_Plugin
|
||||
struct TALER_Amount *melt_fee_balance,
|
||||
struct TALER_Amount *refund_fee_balance,
|
||||
struct TALER_Amount *risk,
|
||||
struct TALER_Amount *payback_loss);
|
||||
struct TALER_Amount *payback_loss,
|
||||
struct TALER_Amount *irregular_payback);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user