update_product.h (2867B)
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 src/include/merchant-database/update_product.h 18 * @brief implementation of the update_product function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef MERCHANT_DATABASE_UPDATE_PRODUCT_H 22 #define MERCHANT_DATABASE_UPDATE_PRODUCT_H 23 24 #include <taler/taler_util.h> 25 #include "merchantdb_lib.h" 26 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 pg database context 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_cat set to -1 on success, otherwise the update failed and this is set 39 * to the index of a category in @a cats that is unknown 40 * @param[out] no_product the @a product_id is unknown 41 * @param[out] lost_reduced the update failed as the counter of units lost would have been lowered 42 * @param[out] sold_reduced the update failed as the counter of units sold would have been lowered 43 * @param[out] stocked_reduced the update failed as the counter of units stocked would have been lowered 44 * @param[out] pd set to the product details on success, can be NULL 45 * (in that case we only want to check if the product exists) 46 * total_sold in @a pd is ignored, total_lost must not 47 * exceed total_stock minus the existing total_sold; 48 * total_sold and total_stock must be larger or equal to 49 * the existing value; 50 * @param[out] no_group set to true if the product group in @a pd is unknown 51 * @param[out] no_pot set to true if the money pot in @a pd is unknown 52 * @return database result code 53 */ 54 enum GNUNET_DB_QueryStatus 55 TALER_MERCHANTDB_update_product ( 56 struct TALER_MERCHANTDB_PostgresContext *pg, 57 const char *instance_id, 58 const char *product_id, 59 const struct TALER_MERCHANTDB_ProductDetails *pd, 60 size_t num_cats, 61 const uint64_t *cats, 62 ssize_t *no_cat, 63 bool *no_product, 64 bool *lost_reduced, 65 bool *sold_reduced, 66 bool *stocked_reduced, 67 bool *no_group, 68 bool *no_pot); 69 70 #endif