diff options
| -rw-r--r-- | src/exchange/taler-exchange-httpd_batch-deposit.c | 35 | 
1 files changed, 27 insertions, 8 deletions
| diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c index 92bf5bdd..a51b3ee2 100644 --- a/src/exchange/taler-exchange-httpd_batch-deposit.c +++ b/src/exchange/taler-exchange-httpd_batch-deposit.c @@ -688,12 +688,33 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc,                                    struct TALER_EXCHANGEDB_Deposit);    for (unsigned int i = 0; i<dc.num_coins; i++)    { -    if (GNUNET_OK != -        (res = parse_coin (connection, -                           json_array_get (coins, -                                           i), -                           &dc, -                           &dc.deposits[i]))) +    do { +      res = parse_coin (connection, +                        json_array_get (coins, +                                        i), +                        &dc, +                        &dc.deposits[i]); +      if (GNUNET_OK != res) +        break; + +      /* If applicable, accumulate all contributions into the policy_details */ +      if (dc.has_policy) +      { +        /* FIXME: how doe deposit-fee and policy-fee interact? */ +        struct TALER_Amount amount_without_fee; + +        res = TALER_amount_subtract (&amount_without_fee, +                                     &dc.deposits[i].amount_with_fee, +                                     &dc.deposits[i].deposit_fee +                                     ); +        res = TALER_amount_add ( +          &dc.policy_details.accumulated_total, +          &dc.policy_details.accumulated_total, +          &amount_without_fee); +      } +    } while(0); + +    if (GNUNET_OK != res)      {        for (unsigned int j = 0; j<i; j++)          TALER_denom_sig_free (&dc.deposits[j].coin.denom_sig); @@ -701,8 +722,6 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc,        GNUNET_JSON_parse_free (spec);        return (GNUNET_NO == res) ? MHD_YES : MHD_NO;      } - -    /* FIXME: sum all contributions for the policy_details.accumulated_total */    }    dc.exchange_timestamp = GNUNET_TIME_timestamp_get (); | 
