pg_update_product.h (2949B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file backenddb/pg_update_product.h 18 * @brief implementation of the update_product function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef PG_UPDATE_PRODUCT_H 22 #define PG_UPDATE_PRODUCT_H 23 24 #include <taler/taler_util.h> 25 #include <taler/taler_json_lib.h> 26 #include "taler_merchantdb_plugin.h" 27 28 /** 29 * Update details about a particular product. Note that the 30 * transaction must enforce that the sold/stocked/lost counters 31 * are not reduced. 32 * 33 * @param cls closure 34 * @param instance_id instance to lookup products for 35 * @param product_id product to lookup 36 * @param num_cats length of @a cats array 37 * @param cats number of categories the product is in 38 * @param[out] no_instance the update failed as the instance is unknown 39 * @param[out] no_cat set to -1 on success, otherwise the update failed and this is set 40 * to the index of a category in @a cats that is unknown 41 * @param[out] no_product the @a product_id is unknown 42 * @param[out] lost_reduced the update failed as the counter of units lost would have been lowered 43 * @param[out] sold_reduced the update failed as the counter of units sold would have been lowered 44 * @param[out] stocked_reduced the update failed as the counter of units stocked would have been lowered 45 * @param[out] pd set to the product details on success, can be NULL 46 * (in that case we only want to check if the product exists) 47 * total_sold in @a pd is ignored, total_lost must not 48 * exceed total_stock minus the existing total_sold; 49 * total_sold and total_stock must be larger or equal to 50 * the existing value; 51 * @return database result code 52 */ 53 enum GNUNET_DB_QueryStatus 54 TMH_PG_update_product (void *cls, 55 const char *instance_id, 56 const char *product_id, 57 const struct TALER_MERCHANTDB_ProductDetails *pd, 58 size_t num_cats, 59 const uint64_t *cats, 60 bool *no_instance, 61 ssize_t *no_cat, 62 bool *no_product, 63 bool *lost_reduced, 64 bool *sold_reduced, 65 bool *stocked_reduced); 66 67 #endif