gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated (847a9d6f -> cd5a9803)


From: gnunet
Subject: [taler-merchant] branch master updated (847a9d6f -> cd5a9803)
Date: Wed, 21 Apr 2021 01:01:48 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository merchant.

    from 847a9d6f cannot increase stock if the product has an order asociated
     new e9f29d84 -fix direction of check
     new 0b9a2ab6 -fix product ID in patch operation
     new cd5a9803 -do not update total_sold when patching product, not provided 
as an argument, breaks invariants

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../taler-merchant-httpd_private-patch-products-ID.c    |  5 ++++-
 src/backenddb/plugin_merchantdb_postgres.c              | 17 +++++++----------
 src/testing/test_merchant_product_creation.sh           |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
index cc4678a7..f9f7bc67 100644
--- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
@@ -57,6 +57,7 @@ determine_cause (struct MHD_Connection *connection,
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
+    GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -84,9 +85,10 @@ determine_cause (struct MHD_Connection *connection,
       ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_REDUCED;
     if (pdx.total_stock > pd->total_stock)
       ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_STOCKED_REDUCED;
-    if (pd->total_stock - pdx.total_sold > pd->total_lost)
+    if (pd->total_stock - pdx.total_sold < pd->total_lost)
       ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_EXCEEDS_STOCKS;
     TALER_MERCHANTDB_product_details_free (&pdx);
+    GNUNET_break (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE != ec);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_CONFLICT,
                                        ec,
@@ -213,6 +215,7 @@ TMH_private_patch_products_ID (const struct 
TMH_RequestHandler *rh,
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
+      GNUNET_break (0);
       ret = TALER_MHD_reply_with_error (connection,
                                         MHD_HTTP_INTERNAL_SERVER_ERROR,
                                         TALER_EC_GENERIC_DB_STORE_FAILED,
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 0170767d..cb9d1163 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1111,8 +1111,7 @@ postgres_update_product (void *cls,
     TALER_PQ_query_param_json (pd->taxes),
     TALER_PQ_query_param_amount (&pd->price),
     GNUNET_PQ_query_param_uint64 (&pd->total_stock),
-    GNUNET_PQ_query_param_uint64 (&pd->total_sold),
-    GNUNET_PQ_query_param_uint64 (&pd->total_lost), /* $11 */
+    GNUNET_PQ_query_param_uint64 (&pd->total_lost), /* $10 */
     TALER_PQ_query_param_json (pd->address),
     GNUNET_PQ_query_param_absolute_time (&pd->next_restock),
     GNUNET_PQ_query_param_end
@@ -6315,20 +6314,18 @@ postgres_connect (void *cls)
                             ",price_val=$8"
                             ",price_frac=$9"
                             ",total_stock=$10"
-                            ",total_sold=$11"
-                            ",total_lost=$12"
-                            ",address=$13"
-                            ",next_restock=$14"
+                            ",total_lost=$11"
+                            ",address=$12"
+                            ",next_restock=$13"
                             " WHERE merchant_serial="
                             "   (SELECT merchant_serial"
                             "      FROM merchant_instances"
                             "      WHERE merchant_id=$1)"
                             "   AND product_id=$2"
                             "   AND total_stock <= $10"
-                            "   AND total_sold <= $11"
-                            "   AND $10 - $11 >= $12"
-                            "   AND total_lost <= $12",
-                            14),
+                            "   AND $10 - total_sold >= $11"
+                            "   AND total_lost <= $11",
+                            13),
 
     /* for postgres_lock_product() */
     GNUNET_PQ_make_prepare ("lock_product",
diff --git a/src/testing/test_merchant_product_creation.sh 
b/src/testing/test_merchant_product_creation.sh
index defbcb37..e089dcb8 100755
--- a/src/testing/test_merchant_product_creation.sh
+++ b/src/testing/test_merchant_product_creation.sh
@@ -147,7 +147,7 @@ echo -n "Updating product..."
 
 PRODUCT_DATA=$(echo $MANAGED_PRODUCT_TEMPLATE | jq 'del(.product_id) | . + 
{"total_stock": (.total_stock + 2) }')
 
-STATUS=$(curl 'http://localhost:9966/instances/default/private/products/2' -X 
PATCH \
+STATUS=$(curl 'http://localhost:9966/instances/default/private/products/3' -X 
PATCH \
     -d "$PRODUCT_DATA" \
     -w "%{http_code}" -s -o $LAST_RESPONSE)
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]