diff options
author | Niklas Halle <niklas@niklashalle.net> | 2024-02-10 13:04:47 +0100 |
---|---|---|
committer | Niklas Halle <niklas@niklashalle.net> | 2024-02-10 13:04:47 +0100 |
commit | b7ffebddfccbc0420693aeeac3e9c4d560fa4cdc (patch) | |
tree | 28bf85982ffe8dcdf76cf1b3588eccc5fcfb498e | |
parent | 089569b5f051a3254667ac89e445dc4db3d37cf1 (diff) | |
download | server_scripts-b7ffebddfccbc0420693aeeac3e9c4d560fa4cdc.tar.gz server_scripts-b7ffebddfccbc0420693aeeac3e9c4d560fa4cdc.zip |
grocy: switch to aggregated amount to reflect "counter" items better, display already tracked numbers on list, fix typo(s)
-rwxr-xr-x | grocy_update_secondary_shoppinglist.sh | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/grocy_update_secondary_shoppinglist.sh b/grocy_update_secondary_shoppinglist.sh index 43d7d2d..c2d1af7 100755 --- a/grocy_update_secondary_shoppinglist.sh +++ b/grocy_update_secondary_shoppinglist.sh @@ -21,8 +21,8 @@ perform_curl() { } -# Clean shopping list, because th api only supports adding items and it is way more cumbersome to adjust to that than just doing it from scratch each time -echo "Cleaning list..." +# Clear the shopping list, because the api only supports adding items and it is way more cumbersome to adjust to that than just doing it from scratch each time +echo "Clearing list..." perform_curl "/api/stock/shoppinglist/clear" "POST" "{ \"list_id\": ${LIST_ID}, \"done_only\": false @@ -52,7 +52,7 @@ echo "Processing products..." jq -c '.[]' combined_products.json | while read i; do PRODUCT_ID=$(echo $i | jq '.product.id') PRODUCT_NAME=$(echo $i | jq -r '.product.name') # Extract product name - CURRENT_AMOUNT=$(echo $i | jq '.amount' | sed 's/null/0/') # Treat null as 0 + CURRENT_AMOUNT=$(echo $i | jq '.amount_aggregated' | sed 's/null/0/') # Treat null as 0 # Fetch MaxStockAmount value and convert to number if not null MAX_STOCK_AMOUNT_JSON=$(perform_curl "/api/userfields/products/${PRODUCT_ID}" "GET") @@ -90,7 +90,8 @@ jq -c '.[]' combined_products.json | while read i; do perform_curl "/api/stock/shoppinglist/add-product" "POST" "{ \"product_id\": ${PRODUCT_ID}, \"list_id\": ${LIST_ID}, - \"product_amount\": ${PRODUCT_AMOUNT_TO_ADD} + \"product_amount\": ${PRODUCT_AMOUNT_TO_ADD}, + \"note\": \"Bereits da: ${CURRENT_AMOUNT} + ${AMOUNT_ON_DEFAULT_LIST}\" }" fi done |