merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

update_product.h (3435B)


      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 <taler/taler_json_lib.h>
     26 #include "merchantdb_lib.h"
     27 
     28 
     29 struct TALER_MERCHANTDB_PostgresContext;
     30 /**
     31  * Update details about a particular product. Note that the
     32  * transaction must enforce that the sold/stocked/lost counters
     33  * are not reduced.
     34  *
     35  * @param pg database context
     36  * @param instance_id instance to lookup products for
     37  * @param product_id product to lookup
     38  * @param num_cats length of @a cats array
     39  * @param cats number of categories the product is in
     40  * @param[out] no_instance the update failed as the instance is unknown
     41  * @param[out] no_cat set to -1 on success, otherwise the update failed and this is set
     42  *                to the index of a category in @a cats that is unknown
     43  * @param[out] no_product the @a product_id is unknown
     44  * @param[out] lost_reduced the update failed as the counter of units lost would have been lowered
     45  * @param[out] sold_reduced the update failed as the counter of units sold would have been lowered
     46  * @param[out] stocked_reduced the update failed as the counter of units stocked would have been lowered
     47  * @param[out] pd set to the product details on success, can be NULL
     48  *             (in that case we only want to check if the product exists)
     49  *             total_sold in @a pd is ignored, total_lost must not
     50  *             exceed total_stock minus the existing total_sold;
     51  *             total_sold and total_stock must be larger or equal to
     52  *             the existing value;
     53  * @param[out] no_group set to true if the product group in @a pd is unknown
     54  * @param[out] no_pot set to true if the money pot in @a pd is unknown
     55  * @return database result code
     56  */
     57 enum GNUNET_DB_QueryStatus
     58 TALER_MERCHANTDB_update_product (struct TALER_MERCHANTDB_PostgresContext *pg,
     59                                  const char *instance_id,
     60                                  const char *product_id,
     61                                  const struct TALER_MERCHANTDB_ProductDetails *pd,
     62                                  size_t num_cats,
     63                                  const uint64_t *cats,
     64                                  bool *no_instance,
     65                                  ssize_t *no_cat,
     66                                  bool *no_product,
     67                                  bool *lost_reduced,
     68                                  bool *sold_reduced,
     69                                  bool *stocked_reduced,
     70                                  bool *no_group,
     71                                  bool *no_pot);
     72 
     73 #endif