commit c49d8a7bffb5e8e3f79b250a6102eee6d84b7250
parent b55f5bc2c301579224aa1e2dc1c571ec37e0133c
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 24 Apr 2024 12:49:03 +0200
fix SQL
Diffstat:
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/donaudb/donau_do_insert_issued_receipts.sql b/src/donaudb/donau_do_insert_issued_receipts.sql
@@ -24,9 +24,9 @@ CREATE OR REPLACE FUNCTION do_insert_issued_receipts (
LANGUAGE plpgsql
AS $$
DECLARE
+ old_receipts_to_date taler_amount;
new_receipts_to_date taler_amount;
- may_per_year taler_amount;
- tmp taler_amount;
+ max_per_year taler_amount;
BEGIN
-- Get charity values
SELECT
@@ -35,25 +35,27 @@ BEGIN
,(chari.max_per_year).val
,(chari.max_per_year).frac
INTO
- new_receipts_to_date.val
- ,new_receipts_to_date.frac
- ,may_per_year.val
- ,may_per_year.frac
+ old_receipts_to_date.val
+ ,old_receipts_to_date.frac
+ ,max_per_year.val
+ ,max_per_year.frac
FROM charities chari
- WHERE charity_id=in_charity_id;
+ WHERE charity_id=in_charity_id;
-- calculate sum of the recent amount of receipts and the issued amount
- SELECT * FROM amount_add(new_receipts_to_date, in_amount) INTO new_receipts_to_date;
+ SELECT *
+ FROM amount_add(old_receipts_to_date, in_amount)
+ INTO new_receipts_to_date;
-- check if the new receipts to date is below or equal the limit for the charity
- IF (may_per_year.val > new_receipts_to_date.val)
- OR (may_per_year.val = new_receipts_to_date.val)
- AND (may_per_year.frac >= new_receipts_to_date.frac)
+ IF ( (max_per_year.val > new_receipts_to_date.val) OR
+ ( (max_per_year.val = new_receipts_to_date.val) AND
+ (max_per_year.frac > new_receipts_to_date.frac) ) )
THEN
out_smaller_than_max_per_year=TRUE;
UPDATE charities
- SET receipts_to_date=in_amount
+ SET receipts_to_date=new_receipts_to_date
WHERE charity_id=in_charity_id;
INSERT INTO receipts_issued (/*blinded_sig,*/ charity_id, receipt_hash, amount)
- VALUES (/*in_blinded_sig,*/ in_charity_id, in_receipt_hash, in_amount);
+ VALUES (/*in_blinded_sig,*/ in_charity_id, in_receipt_hash, in_amount);
ELSE
out_smaller_than_max_per_year=FALSE;
END IF;
diff --git a/src/testing/coins-rsa.conf b/src/testing/coins-rsa.conf
@@ -4,7 +4,8 @@
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
-duration_withdraw = 7 days
+duration_withdraw = 1 year
+anchor_round = 1 year
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00