[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 01/08: consider that deposit fee is discounted when ref
From: |
gnunet |
Subject: |
[taler-exchange] 01/08: consider that deposit fee is discounted when refund fee is applied |
Date: |
Fri, 27 Mar 2020 11:26:38 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 9445343ec5c35a79b8cd8a2a15e92ca7435bda46
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Mar 27 09:34:58 2020 +0100
consider that deposit fee is discounted when refund fee is applied
---
src/exchangedb/exchangedb_transactions.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/exchangedb/exchangedb_transactions.c
b/src/exchangedb/exchangedb_transactions.c
index c862f5a0..ade7f9cf 100644
--- a/src/exchangedb/exchangedb_transactions.c
+++ b/src/exchangedb/exchangedb_transactions.c
@@ -40,10 +40,13 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
{
struct TALER_Amount spent = *off;
struct TALER_Amount refunded;
+ struct TALER_Amount deposit_fee;
+ int have_refund;
GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (spent.currency,
&refunded));
+ have_refund = GNUNET_NO;
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
NULL != pos;
pos = pos->next)
@@ -60,6 +63,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ deposit_fee = pos->details.deposit->deposit_fee;
break;
case TALER_EXCHANGEDB_TT_MELT:
/* spent += pos->amount_with_fee */
@@ -83,13 +87,14 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
- TALER_amount_subtract (&refunded,
- &refunded,
- &pos->details.refund->refund_fee))
+ TALER_amount_add (&spent,
+ &spent,
+ &pos->details.refund->refund_fee))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ have_refund = GNUNET_YES;
break;
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
/* refunded += pos->value */
@@ -126,6 +131,18 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
break;
}
}
+ if (have_refund)
+ {
+ /* If we gave any refund, also discount ONE deposit fee */
+ if (GNUNET_OK !=
+ TALER_amount_add (&refunded,
+ &refunded,
+ &deposit_fee))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ }
/* spent = spent - refunded */
if (GNUNET_SYSERR ==
TALER_amount_subtract (&spent,
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-exchange] branch master updated (f052527e -> 13bbcef8), gnunet, 2020/03/27
- [taler-exchange] 04/08: missing break, gnunet, 2020/03/27
- [taler-exchange] 02/08: check coin history consistency, gnunet, 2020/03/27
- [taler-exchange] 08/08: adjust test to code changes, gnunet, 2020/03/27
- [taler-exchange] 06/08: improve error logging, gnunet, 2020/03/27
- [taler-exchange] 01/08: consider that deposit fee is discounted when refund fee is applied,
gnunet <=
- [taler-exchange] 03/08: expand test suite, gnunet, 2020/03/27
- [taler-exchange] 07/08: fix inconsistency in field naming, gnunet, 2020/03/27
- [taler-exchange] 05/08: improve coin audit logic, gnunet, 2020/03/27