diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2022-10-14 20:23:59 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2022-10-14 20:23:59 +0200 |
commit | 949a91c38e01f7850f1cf1ff8c8f9d1e8b0d377e (patch) | |
tree | c112a43b68f75a2c987bd70f413ef5979ca3fa26 /src/exchange/taler-exchange-httpd_batch-deposit.c | |
parent | 63b19fad0cbcafa340d3344c9dc33c06402371a6 (diff) |
accumulate amounts from coins in batch-deposit for policyauction_brandt
Diffstat (limited to 'src/exchange/taler-exchange-httpd_batch-deposit.c')
-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 (); |