From 067891bbbade55644344585ea8b9cc95cba039c8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 09:00:39 +0100 Subject: fix audit report formatting issues --- contrib/auditor-report.tex.j2 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'contrib') diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2 index 0fbf74c1..e4f5c8dc 100644 --- a/contrib/auditor-report.tex.j2 +++ b/contrib/auditor-report.tex.j2 @@ -102,8 +102,7 @@ making wire transfers that have been due. The total amount the exchange currently lags behind is {\bf {{ wire.total_amount_lag.value }}.{{ wire.total_amount_lag.fraction }} - {{ wire.total_amount_lag.currency }} -}. + {{ wire.total_amount_lag.currency }}}. Note that some lag is perfectly normal, as tiny amounts that are too small to be wired are deferred beyond the due date, hoping that additional transfers will push them above @@ -593,7 +592,7 @@ have a clear financial impact. \hline {\bf Table} & {\bf Row} & {\bf Diagnostic} \\ \caption{Other wire table issues found (by table and row).} - \label{table:misc} + \label{table:wire:misc} \endlastfoot {% for item in wire.row_inconsistencies %} \verb! {{ item.table }} ! & @@ -687,7 +686,7 @@ impact. {% if data.row_inconsistencies|length() == 0 %} {\bf No row inconsistencies found.} {% else %} - \begin{longtable}{p{1.5cm}|l|p{5.5}} + \begin{longtable}{p{1.5cm}|l|p{5.5cm}} {\bf Table} & {\bf Row} & {\bf Diagnostic} \\ \hline \hline \endfirsthead @@ -703,7 +702,7 @@ impact. \label{table:misc} \endlastfoot {% for item in data.row_inconsistencies %} - {{ item.table }} & + \verb! {{ item.table }} ! & {{ item.row }} & {{ item.diagnostic }} \\ \hline {% endfor %} @@ -854,7 +853,7 @@ This section lists issues with wire transfers related to timestamps. \label{table:wire:bad_time} \endlastfoot {% for item in wire.row_minor_inconsistencies %} - {\tt {{ item.table }} } & {{ item.row }} & {{ item.diagnostic }} \\ \hline + \verb! {{ item.table }} ! & {{ item.row }} & {{ item.diagnostic }} \\ \hline {% endfor %} \end{longtable} {% endif %} -- cgit v1.2.3 From 7d60d3a61823594a9f6df9f884d9237741a4576c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 09:22:33 +0100 Subject: nicer formatting, some DCE --- contrib/auditor-report.tex.j2 | 20 ++++++++++---------- src/auditor/taler-auditor.c | 5 ----- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'contrib') diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2 index e4f5c8dc..bad7397d 100644 --- a/contrib/auditor-report.tex.j2 +++ b/contrib/auditor-report.tex.j2 @@ -209,7 +209,7 @@ the financial damage done to the customer). {% if data.amount_arithmetic_inconsistencies|length() == 0 %} {\bf No arithmetic problems detected.} {% else %} - \begin{longtable}{p{4.5cm}|l|rl|rl} + \begin{longtable}{p{3.5cm}|l|rl|rl} {\bf Operation} & {\bf Table row} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \hline \hline \endfirsthead @@ -218,11 +218,11 @@ the financial damage done to the customer). \hline \hline {\bf Operation} & {\bf Table row} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \endfoot - \hline - {\bf Total} & & - {{ data.total_arithmetic_delta_plus.value }}.{{ data.total_arithmetic_delta_plus.fraction }} & + \hline \hline + \multicolumn{2}{l|}{ {\bf $\sum$ Deltas (Auditor-Exchange)} } & + + {{ data.total_arithmetic_delta_plus.value }}.{{ data.total_arithmetic_delta_plus.fraction }} & {{ data.total_arithmetic_delta_plus.currency }} & - {{ data.total_arithmetic_delta_minus.value }}.{{ data.total_arithmetic_delta_minus.fraction }} & + - {{ data.total_arithmetic_delta_minus.value }}.{{ data.total_arithmetic_delta_minus.fraction }} & {{ data.total_arithmetic_delta_minus.currency }} \\ \caption{Arithmetic inconsistencies.} \label{table:amount:arithmetic:inconsistencies} @@ -327,14 +327,14 @@ any effects on its own balance, those entries are excluded from the total. {% if data.coin_inconsistencies|length() == 0 %} {\bf All coin histories were unproblematic.} {% else %} - \begin{longtable}{l|p{5.5cm}|rl|rl} - {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c|}{ {\bf Auditor}} \\ + \begin{longtable}{p{1.8cm}|p{3cm}|rl|rl} + {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \hline \hline \endfirsthead - {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c|}{ {\bf Auditor}} \\ \hline \hline + {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \hline \hline \endhead \hline \hline - {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c|}{ {\bf Auditor}} \\ + {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \endfoot \hline {\bf Total} & & @@ -696,7 +696,7 @@ impact. \hline \hline {\bf Table} & {\bf Row} & {\bf Diagnostic} \\ \endfoot - \hline + \hline \hline {\bf Table} & {\bf Row} & {\bf Diagnostic} \\ \caption{Other issues found (by table and row).} \label{table:misc} diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 89f04460..7ce2032d 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -1702,11 +1702,6 @@ struct AggregationContext */ struct WireFeeInfo *fee_tail; - /** - * How much did we make in aggregation fees. - */ - struct TALER_Amount total_aggregation_feesX; - /** * Final result status. */ -- cgit v1.2.3 From 0906696ec2949e2c9fa7a168e3d270fae1c3a905 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 10:38:16 +0100 Subject: bugfixes in auditor and rendering --- contrib/auditor-report.tex.j2 | 2 +- src/auditor/taler-auditor.c | 78 ++++++++++++------------------ src/exchange/taler-exchange-httpd_refund.c | 1 - 3 files changed, 32 insertions(+), 49 deletions(-) (limited to 'contrib') diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2 index bad7397d..4c979f7e 100644 --- a/contrib/auditor-report.tex.j2 +++ b/contrib/auditor-report.tex.j2 @@ -337,7 +337,7 @@ any effects on its own balance, those entries are excluded from the total. {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ \endfoot \hline - {\bf Total} & & + \multicolumn{2}{l|}{ $\sum$ {\bf Delta (Auditor-Exchange)} } & {{ data.total_coin_delta_plus.value }}.{{ data.total_coin_delta_plus.fraction }} & {{ data.total_coin_delta_plus.currency }} & - {{ data.total_coin_delta_minus.value }}.{{ data.total_coin_delta_minus.fraction }} & diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 7ce2032d..e807378f 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -391,7 +391,7 @@ report_amount_arithmetic_inconsistency (const char *operation, "profitable", (json_int_t) profitable)); if (0 != profitable) { - target = profitable + target = (1 == profitable) ? &total_arithmetic_delta_plus : &total_arithmetic_delta_minus; GNUNET_break (GNUNET_OK == @@ -452,7 +452,7 @@ report_coin_arithmetic_inconsistency (const char *operation, "profitable", (json_int_t) profitable)); if (0 != profitable) { - target = profitable + target = (1 == profitable) ? &total_coin_delta_plus : &total_coin_delta_minus; GNUNET_break (GNUNET_OK == @@ -1798,7 +1798,6 @@ struct WireCheckContext * @param dki denomination information about the coin * @param tl_head head of transaction history to verify * @param[out] merchant_gain amount the coin contributes to the wire transfer to the merchant - * @param[out] merchant_fees fees the exchange charged the merchant for the transaction(s) * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ static int @@ -1807,8 +1806,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct TALER_EXCHANGEDB_TransactionList *tl_head, - struct TALER_Amount *merchant_gain, - struct TALER_Amount *merchant_fees) + struct TALER_Amount *merchant_gain) { struct TALER_Amount expenditures; struct TALER_Amount refunds; @@ -1816,6 +1814,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount value; struct TALER_Amount merchant_loss; struct TALER_Amount merchant_delta; + const struct TALER_Amount *deposit_fee; + int refund_deposit_fee; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking transaction history of coin %s\n", @@ -1831,9 +1831,6 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, merchant_gain)); - GNUNET_assert (GNUNET_OK == - TALER_amount_get_zero (currency, - merchant_fees)); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &merchant_loss)); @@ -1841,6 +1838,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, know the order, so instead of subtracting we compute positive (deposit, melt) and negative (refund) values separately here, and then subtract the negative from the positive after the loop. */ + refund_deposit_fee = GNUNET_NO; + deposit_fee = NULL; for (const struct TALER_EXCHANGEDB_TransactionList *tl = tl_head;NULL != tl;tl = tl->next) { const struct TALER_Amount *amount_with_fee; @@ -1872,7 +1871,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, { struct TALER_Amount amount_without_fee; - if (GNUNET_OK != + if (GNUNET_OK != TALER_amount_subtract (&amount_without_fee, amount_with_fee, fee)) @@ -1891,14 +1890,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Detected applicable deposit of %s\n", TALER_amount2s (&amount_without_fee)); - if (GNUNET_OK != - TALER_amount_add (merchant_fees, - merchant_fees, - fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } + deposit_fee = fee; } /* Check that the fees given in the transaction list and in dki match */ TALER_amount_ntoh (&tmp, @@ -1976,14 +1968,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Detected applicable refund of %s\n", TALER_amount2s (amount_with_fee)); - if (GNUNET_OK != - TALER_amount_add (merchant_fees, - merchant_fees, - fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } + refund_deposit_fee = GNUNET_YES; } /* Check that the fees given in the transaction list and in dki match */ TALER_amount_ntoh (&tmp, @@ -2009,9 +1994,19 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, } break; } - } /* for 'tl' */ + if ( (GNUNET_YES == refund_deposit_fee) && + (NULL != deposit_fee) ) + { + /* We had a /deposit operation AND a /refund operation, + and should thus not charge the merchant the /deposit fee */ + GNUNET_assert (GNUNET_OK == + TALER_amount_add (merchant_gain, + merchant_gain, + deposit_fee)); + } + /* Calculate total balance change, i.e. expenditures minus refunds */ if (GNUNET_SYSERR == TALER_amount_subtract (&spent, @@ -2023,7 +2018,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, coin_pub, &expenditures, &refunds, - 0); + 1); return GNUNET_SYSERR; } @@ -2042,7 +2037,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, return GNUNET_SYSERR; } - /* Finally, update @a merchant_gain by subtracting what he "lost" from refunds */ + /* Finally, update @a merchant_gain by subtracting what he "lost" + from refunds */ if (GNUNET_SYSERR == TALER_amount_subtract (&merchant_delta, merchant_gain, @@ -2053,7 +2049,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, coin_pub, merchant_gain, &merchant_loss, - 0); + 1); return GNUNET_SYSERR; } *merchant_gain = merchant_delta; @@ -2079,7 +2075,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, * @param h_contract_terms which proposal was this payment about * @param coin_pub which public key was this payment about * @param coin_value amount contributed by this coin in total (with fee) - * @param coin_fee applicable fee for this coin + * @param deposit_fee applicable deposit fee for this coin, actual + * fees charged may differ if coin was refunded */ static void wire_transfer_information_cb (void *cls, @@ -2091,12 +2088,11 @@ wire_transfer_information_cb (void *cls, const struct GNUNET_HashCode *h_contract_terms, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *coin_value, - const struct TALER_Amount *coin_fee) + const struct TALER_Amount *deposit_fee) { struct WireCheckContext *wcc = cls; const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; struct TALER_Amount computed_value; - struct TALER_Amount computed_fees; struct TALER_Amount coin_value_without_fee; struct TALER_EXCHANGEDB_TransactionList *tl; const struct TALER_CoinPublicInfo *coin; @@ -2158,18 +2154,17 @@ wire_transfer_information_cb (void *cls, merchant_pub, dki, tl, - &computed_value, - &computed_fees); + &computed_value); if (GNUNET_SYSERR == TALER_amount_subtract (&coin_value_without_fee, coin_value, - coin_fee)) + deposit_fee)) { wcc->qs = GNUNET_DB_STATUS_HARD_ERROR; report_amount_arithmetic_inconsistency ("aggregation (fee structure)", rowid, coin_value, - coin_fee, + deposit_fee, -1); return; } @@ -2184,17 +2179,6 @@ wire_transfer_information_cb (void *cls, &computed_value, -1); } - if (0 != - TALER_amount_cmp (&computed_fees, - coin_fee)) - { - wcc->qs = GNUNET_DB_STATUS_HARD_ERROR; - report_amount_arithmetic_inconsistency ("aggregation (fee)", - rowid, - coin_fee, - &computed_fees, - 1); - } edb->free_coin_transaction_list (edb->cls, tl); diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index f0aaa65c..986c9d31 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -285,7 +285,6 @@ refund_transaction (void *cls, } /* check if we already send the money for the /deposit */ - // FIXME: DB API... qs = TEH_plugin->test_deposit_done (TEH_plugin->cls, session, dep); -- cgit v1.2.3 From 23cb23b1e73f996fddf3a1cbb22329c4dcf632e9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 11:55:00 +0100 Subject: fix minor formatting issue --- contrib/auditor-report.tex.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'contrib') diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2 index 4c979f7e..38073303 100644 --- a/contrib/auditor-report.tex.j2 +++ b/contrib/auditor-report.tex.j2 @@ -727,12 +727,12 @@ reserve expired. {\bf All expired reserves were closed.} {% else %} \begin{longtable}{p{1.5cm}|c|rl} - {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c|}{ {\bf Balance}} \\ \hline \hline + {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c}{ {\bf Balance}} \\ \hline \hline \endfirsthead - {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c|}{ {\bf Balance}} \\ \hline \hline + {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c}{ {\bf Balance}} \\ \hline \hline \endhead \hline \hline - {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c|}{ {\bf Balance}} + {\bf Reserve} & {\bf Expired} & \multicolumn{2}{|c}{ {\bf Balance}} \endfoot \hline {\bf Sum} & & -- cgit v1.2.3