consider that deposit fee is discounted when refund fee is applied
This commit is contained in:
parent
f052527ea5
commit
9445343ec5
@ -40,10 +40,13 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
{
|
{
|
||||||
struct TALER_Amount spent = *off;
|
struct TALER_Amount spent = *off;
|
||||||
struct TALER_Amount refunded;
|
struct TALER_Amount refunded;
|
||||||
|
struct TALER_Amount deposit_fee;
|
||||||
|
int have_refund;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (spent.currency,
|
TALER_amount_get_zero (spent.currency,
|
||||||
&refunded));
|
&refunded));
|
||||||
|
have_refund = GNUNET_NO;
|
||||||
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
|
||||||
NULL != pos;
|
NULL != pos;
|
||||||
pos = pos->next)
|
pos = pos->next)
|
||||||
@ -60,6 +63,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
deposit_fee = pos->details.deposit->deposit_fee;
|
||||||
break;
|
break;
|
||||||
case TALER_EXCHANGEDB_TT_MELT:
|
case TALER_EXCHANGEDB_TT_MELT:
|
||||||
/* spent += pos->amount_with_fee */
|
/* spent += pos->amount_with_fee */
|
||||||
@ -83,13 +87,14 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_amount_subtract (&refunded,
|
TALER_amount_add (&spent,
|
||||||
&refunded,
|
&spent,
|
||||||
&pos->details.refund->refund_fee))
|
&pos->details.refund->refund_fee))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
have_refund = GNUNET_YES;
|
||||||
break;
|
break;
|
||||||
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
|
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
|
||||||
/* refunded += pos->value */
|
/* refunded += pos->value */
|
||||||
@ -126,6 +131,18 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
|
|||||||
break;
|
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 */
|
/* spent = spent - refunded */
|
||||||
if (GNUNET_SYSERR ==
|
if (GNUNET_SYSERR ==
|
||||||
TALER_amount_subtract (&spent,
|
TALER_amount_subtract (&spent,
|
||||||
|
Loading…
Reference in New Issue
Block a user