commit 2f69842ac81188435b54c4a14817edb0cf4ca370
parent d919743e62a669be9edfe4eccda56f62020aa517
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 26 Feb 2026 22:00:47 +0100
fix #11122
Diffstat:
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/src/backenddb/pg_lookup_reconciliation_details.c b/src/backenddb/pg_lookup_reconciliation_details.c
@@ -73,15 +73,26 @@ reconciliation_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
char *order_id;
+ uint64_t dvs;
+ uint64_t dfs;
+ uint64_t fvs;
+ uint64_t ffs;
+ char *currency;
struct TALER_Amount remaining_deposit;
struct TALER_Amount deposit_fee;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("order_id",
&order_id),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value",
- &remaining_deposit),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee",
- &deposit_fee),
+ GNUNET_PQ_result_spec_string ("currency",
+ ¤cy),
+ GNUNET_PQ_result_spec_uint64 ("deposit_value_sum",
+ &dvs),
+ GNUNET_PQ_result_spec_uint64 ("deposit_frac_sum",
+ &dfs),
+ GNUNET_PQ_result_spec_uint64 ("fee_value_sum",
+ &fvs),
+ GNUNET_PQ_result_spec_uint64 ("fee_frac_sum",
+ &ffs),
GNUNET_PQ_result_spec_end
};
@@ -94,6 +105,16 @@ reconciliation_cb (void *cls,
lic->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (currency,
+ &remaining_deposit));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (currency,
+ &deposit_fee));
+ remaining_deposit.value = dvs + dfs / TALER_AMOUNT_FRAC_BASE;
+ remaining_deposit.fraction = dfs % TALER_AMOUNT_FRAC_BASE;
+ deposit_fee.value = fvs + ffs / TALER_AMOUNT_FRAC_BASE;
+ deposit_fee.fraction = ffs % TALER_AMOUNT_FRAC_BASE;
lic->cb (lic->cb_cls,
order_id,
@@ -130,8 +151,11 @@ TMH_PG_lookup_reconciliation_details (
"lookup_reconciliation_details",
"SELECT"
" mct.order_id"
- ",etc.exchange_deposit_value"
- ",etc.exchange_deposit_fee"
+ ",SUM((etc.exchange_deposit_value).val)::INT8 AS deposit_value_sum"
+ ",SUM((etc.exchange_deposit_value).frac)::INT8 AS deposit_frac_sum"
+ ",SUM((etc.exchange_deposit_fee).val)::INT8 AS fee_value_sum"
+ ",SUM((etc.exchange_deposit_fee).frac)::INT8 AS fee_frac_sum"
+ ",(etc.exchange_deposit_value).curr AS currency"
" FROM merchant_expected_transfer_to_coin etc"
" JOIN merchant_deposits md"
" USING (deposit_serial)"
@@ -142,7 +166,8 @@ TMH_PG_lookup_reconciliation_details (
" JOIN merchant_instances mi"
" USING (merchant_serial)"
" WHERE expected_credit_serial=$2"
- " AND mi.merchant_id=$1;");
+ " AND mi.merchant_id=$1"
+ " GROUP BY mct.order_id, (etc.exchange_deposit_value).curr;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"lookup_reconciliation_details",
params,