accumulate amounts from coins in batch-deposit for policy

This commit is contained in:
Özgür Kesim 2022-10-14 20:23:59 +02:00
parent 63b19fad0c
commit 949a91c38e
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7

View File

@ -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,
do {
res = parse_coin (connection,
json_array_get (coins,
i),
&dc,
&dc.deposits[i])))
&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 ();