commit b0779234b53b18bb7d3307b873892c7707ea2712 parent f5c5811e9d0c7078ce8d429876d4c5a1f3d4e41e Author: Bohdan Potuzhnyi <potub1@bfh.ch> Date: Fri, 4 Oct 2024 19:06:57 +0000 update of the naming and implementations of the insert, delete donau charities Diffstat:
| D | src/backenddb/pg_delete_donau.c | | | 27 | --------------------------- |
| D | src/backenddb/pg_delete_donau.h | | | 30 | ------------------------------ |
| A | src/backenddb/pg_delete_donau_instance.c | | | 49 | +++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/backenddb/pg_delete_donau_instance.h | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
| D | src/backenddb/pg_insert_donau.c | | | 28 | ---------------------------- |
| D | src/backenddb/pg_insert_donau.h | | | 30 | ------------------------------ |
| A | src/backenddb/pg_insert_donau_instance.c | | | 65 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/backenddb/pg_insert_donau_instance.h | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
| D | src/backenddb/pg_select_donau.c | | | 27 | --------------------------- |
| D | src/backenddb/pg_select_donau.h | | | 29 | ----------------------------- |
| A | src/backenddb/pg_select_donau_instance.c | | | 27 | +++++++++++++++++++++++++++ |
| A | src/backenddb/pg_select_donau_instance.h | | | 29 | +++++++++++++++++++++++++++++ |
| A | src/include/taler_merchant_donau.h | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 files changed, 322 insertions(+), 171 deletions(-)
diff --git a/src/backenddb/pg_delete_donau.c b/src/backenddb/pg_delete_donau.c @@ -1,27 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_delete_donau.c - * @brief Implementation of the delete_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#include "platform.h" -#include <taler/taler_error_codes.h> -#include <taler/taler_dbevents.h> -#include <taler/taler_pq_lib.h> -#include "pg_delete_donau.h" -#include "pg_helper.h" diff --git a/src/backenddb/pg_delete_donau.h b/src/backenddb/pg_delete_donau.h @@ -1,30 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_delete_donau.h - * @brief implementation of the delete_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#ifndef PG_DELETE_DONAU_H -#define PG_DELETE_DONAU_H - -#include <taler/taler_util.h> -#include <taler/taler_json_lib.h> -#include "taler_merchantdb_plugin.h" - - -#endif diff --git a/src/backenddb/pg_delete_donau_instance.c b/src/backenddb/pg_delete_donau_instance.c @@ -0,0 +1,48 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_donau_instance.c + * @brief Implementation of the delete_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_delete_donau_instance.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_delete_donau_instance ( + void *cls, + const uint64_t charity_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (charity_id), + GNUNET_PQ_query_param_end + }; + + check_connection (pg); + PREPARE (pg, + "delete_donau_instance", + "DELETE FROM donau_instance WHERE charity_id = $1"); + " WHERE charity_id = $1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "delete_donau_instance", + params); +} +\ No newline at end of file diff --git a/src/backenddb/pg_delete_donau_instance.h b/src/backenddb/pg_delete_donau_instance.h @@ -0,0 +1,41 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_donau_instance.h + * @brief implementation of the delete_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef PG_DELETE_DONAU_INSTANCE_H +#define PG_DELETE_DONAU_INSTANCE_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Delete an existing Donau charity instance from the database. + * + * @param cls closure + * @param charity_id unique identifier of the charity instance to be deleted + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_delete_donau_instance ( + void *cls, + const uint64_t charity_id); + +#endif diff --git a/src/backenddb/pg_insert_donau.c b/src/backenddb/pg_insert_donau.c @@ -1,28 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_insert_donau.c - * @brief Implementation of the insert_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#include "platform.h" -#include <taler/taler_error_codes.h> -#include <taler/taler_dbevents.h> -#include <taler/taler_pq_lib.h> -#include "pg_insert_donau.h" -#include "pg_helper.h" - diff --git a/src/backenddb/pg_insert_donau.h b/src/backenddb/pg_insert_donau.h @@ -1,30 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_insert_donau.h - * @brief implementation of the insert_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#ifndef PG_INSERT_DONAU_H -#define PG_INSERT_DONAU_H - -#include <taler/taler_util.h> -#include <taler/taler_json_lib.h> -#include "taler_merchantdb_plugin.h" - - -#endif diff --git a/src/backenddb/pg_insert_donau_instance.c b/src/backenddb/pg_insert_donau_instance.c @@ -0,0 +1,64 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_donau_instance.c + * @brief Implementation of the insert_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_insert_donau_instance.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_donau_instance ( + void *cls, + const struct DONAU_Charity *charity, + const uint64_t charity_id ) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (&charity->donau_url), + GNUNET_PQ_query_param_string (charity->name), + GNUNET_PQ_query_param_auto_from_type (charity->charity_pub), + GNUNET_PQ_query_param_uint64 (charity_id), + TALER_PQ_query_param_amount_with_currency (pg->conn, + &charity->max_per_year), + TALER_PQ_query_param_amount_with_currency (pg->conn, + &charity->receipts_to_date), + GNUNET_PQ_query_param_uint64 (charity->current_year), + GNUNET_PQ_query_param_end + }; + + check_connection(pg); + PREPARE (pg, + "insert_donau_instance", + "INSERT INTO merchant_donau_instances", + "(donau_url" + ",charity_name" + ",charity_pub_key" + ",charity_id" + ",charity_max_per_year" + ",charity_receipts_to_date" + ",current_year)" + "VALUES ($1, $2, $3, $4, $5, $6, $7);"); + return GNUNET_PQ_eval_prepared_non_select(pg->conn, + "insert_donau_instance", + params); +} +\ No newline at end of file diff --git a/src/backenddb/pg_insert_donau_instance.h b/src/backenddb/pg_insert_donau_instance.h @@ -0,0 +1,43 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_donau_instance.h + * @brief implementation of the insert_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef PG_INSERT_DONAU_INSTANCE_H +#define PG_INSERT_DONAU_INSTANCE_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Insert information about a Donau charity instance. + * + * @param cls closure + * @param charity structure containing information about the charity + * @param charity_id unique identifier for the charity + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_donau_instance ( + void *cls, + const struct DONAU_Charity *charity, + const uint64_t charity_id); + +#endif diff --git a/src/backenddb/pg_select_donau.c b/src/backenddb/pg_select_donau.c @@ -1,27 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_select_donau.c - * @brief Implementation of the select_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#include "platform.h" -#include <taler/taler_error_codes.h> -#include <taler/taler_dbevents.h> -#include <taler/taler_pq_lib.h> -#include "pg_select_donau.h" -#include "pg_helper.h" diff --git a/src/backenddb/pg_select_donau.h b/src/backenddb/pg_select_donau.h @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file backenddb/pg_select_donau.h - * @brief implementation of the select_donau function for Postgres - * @author Bohdan Potuzhnyi - * @author Vlada Svirsh - */ -#ifndef PG_SELECT_DONAU_H -#define PG_SELECT_DONAU_H - -#include <taler/taler_util.h> -#include <taler/taler_json_lib.h> -#include "taler_merchantdb_plugin.h" - -#endif diff --git a/src/backenddb/pg_select_donau_instance.c b/src/backenddb/pg_select_donau_instance.c @@ -0,0 +1,27 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_donau_instance.c + * @brief Implementation of the select_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_donau_instance.h" +#include "pg_helper.h" diff --git a/src/backenddb/pg_select_donau_instance.h b/src/backenddb/pg_select_donau_instance.h @@ -0,0 +1,29 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_donau_instance.h + * @brief implementation of the select_donau_instance function for Postgres + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef PG_SELECT_DONAU_INSTANCE_H +#define PG_SELECT_DONAU_INSTANCE_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +#endif diff --git a/src/include/taler_merchant_donau.h b/src/include/taler_merchant_donau.h @@ -0,0 +1,67 @@ +/* + This file is part of TALER + Copyright (C) 2014-2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file taler_merchant_donau.h + * @brief Structs to interact with the donau. + * @author Bohdan Potuzhnyi + * @author Vlada Svirsh + */ +#ifndef _TALER_MERCHANT_DONAU_H +#define _TALER_MERCHANT_DONAU_H + +#include <taler/taler_util.h> +#include <taler/taler_error_codes.h> +#include <taler/taler_exchange_service.h> + +struct TALER_MERCHANT_DONAU_Charity +{ + /** + * name of the charity + */ + char *name; + + /** + * charity url + */ + char *charity_url; + + /** + * public key of the charity + */ + struct DONAU_CharityPublicKeyP charity_pub; + + /** + * Max donation amout for this charitiy and @e current_year. + */ + struct TALER_Amount max_per_year; + + /** + * Current amount of donation receipts for @e current_year. + */ + struct TALER_Amount receipts_to_date; + + /** + * current year + */ + uint64_t current_year; + + /** + * The unique identifier of the charity. + */ + uint64_t charity_id; +}; + +#endif +\ No newline at end of file