Closed progval closed 11 months ago
Hi,
(you can click on each paragraph above to display dumps from the API)
so it looks like Grocy-Android is implicitly converting it to grams, and sending the quantity to the server in grams while the server expects it in kilograms.
FYI ver 3.3.1 fixes some issues with unit conversion. Would suggest seeing if it still exists there
It's fixed, thanks!
Hi,
I am using Grocy 4.0.2 and `xyz.zedler.patrick.grocy` 3.3.0 from F-Droid.
`GET /api/system/info` returns: ```json { "grocy_version": { "Version": "4.0.2", "ReleaseDate": "2023-08-19" }, "php_version": "8.2.7", "sqlite_version": "3.40.1", "os": "Linux 6.1.0-11-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) x86_64", "client": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0" } ```I defined a "Test Product" with the default unit for everything being "Kilogramme"
`GET /api/stock/products/19` returns: ```json { "product": { "id": 19, "name": "Test Product", "description": null, "product_group_id": null, "active": 1, "location_id": 2, "shopping_location_id": null, "qu_id_purchase": 12, "qu_id_stock": 12, "min_stock_amount": 0, "default_best_before_days": 0, "default_best_before_days_after_open": 0, "default_best_before_days_after_freezing": 0, "default_best_before_days_after_thawing": 0, "picture_file_name": null, "enable_tare_weight_handling": 0, "tare_weight": 0, "not_check_stock_fulfillment_for_recipes": 0, "parent_product_id": null, "calories": 0, "cumulate_min_stock_amount_of_sub_products": 0, "due_type": 1, "quick_consume_amount": 1, "hide_on_stock_overview": 0, "default_stock_label_type": 0, "should_not_be_frozen": 0, "treat_opened_as_out_of_stock": 1, "no_own_stock": 0, "default_consume_location_id": null, "move_on_open": 0, "row_created_timestamp": "2023-08-19 11:17:24", "qu_id_consume": 12, "auto_reprint_stock_label": 0, "quick_open_amount": 1, "qu_id_price": 12 }, "product_barcodes": [], "last_purchased": "2023-08-19", "last_used": null, "stock_amount": 2000, "stock_value": 0, "stock_amount_opened": 0, "stock_amount_aggregated": 2000, "stock_amount_opened_aggregated": 0, "quantity_unit_stock": { "id": 12, "name": "Kilogramme", "description": null, "row_created_timestamp": "2023-08-19 10:04:33", "name_plural": "Kilogrammes", "plural_forms": null, "active": 1 }, "default_quantity_unit_purchase": { "id": 12, "name": "Kilogramme", "description": null, "row_created_timestamp": "2023-08-19 10:04:33", "name_plural": "Kilogrammes", "plural_forms": null, "active": 1 }, "default_quantity_unit_consume": { "id": 12, "name": "Kilogramme", "description": null, "row_created_timestamp": "2023-08-19 10:04:33", "name_plural": "Kilogrammes", "plural_forms": null, "active": 1 }, "quantity_unit_price": { "id": 12, "name": "Kilogramme", "description": null, "row_created_timestamp": "2023-08-19 10:04:33", "name_plural": "Kilogrammes", "plural_forms": null, "active": 1 }, "last_price": 0, "avg_price": null, "oldest_price": 0, "current_price": 0, "last_shopping_location_id": null, "default_shopping_location_id": null, "next_due_date": "2999-12-31", "location": { "id": 2, "name": "Frigo", "description": null, "row_created_timestamp": "2023-08-19 09:25:08", "is_freezer": 0, "active": 1 }, "average_shelf_life_days": 356611, "spoil_rate_percent": 0, "is_aggregated_amount": 0, "has_childs": false, "default_consume_location": null, "qu_conversion_factor_purchase_to_stock": 1, "qu_conversion_factor_price_to_stock": 1 } ```in my general unit configuration, I have configured (among others) two units: Kilogramme and Gramme
result of `GET /api/objects/quantity_units` ```json5 [ /* ... */ { "id": 5, "name": "Gramme", "description": null, "row_created_timestamp": "2023-08-19 09:35:35", "name_plural": "Grammes", "plural_forms": null, "active": 1 }, /* ... */ { "id": 12, "name": "Kilogramme", "description": null, "row_created_timestamp": "2023-08-19 10:04:33", "name_plural": "Kilogrammes", "plural_forms": null, "active": 1 }, /* ... */ ] ```with the expected 1:1000 conversion between the two
`GET /api/objects/quantity_unit_conversions_resolved` returns: ```json5 [ /* ... */ { "id": -1, "product_id": 19, "from_qu_id": 5, "from_qu_name": "Gramme", "from_qu_name_plural": "Grammes", "to_qu_id": 12, "to_qu_name": "Kilogramme", "to_qu_name_plural": "Kilogrammes", "factor": 0.001, "path": "/5/12/" }, { "id": -1, "product_id": 19, "from_qu_id": 5, "from_qu_name": "Gramme", "from_qu_name_plural": "Grammes", "to_qu_id": 13, "to_qu_name": "Pincée", "to_qu_name_plural": "Pincées", "factor": 0.5, "path": "/5/12/13/" }, { "id": -1, "product_id": 19, "from_qu_id": 12, "from_qu_name": "Kilogramme", "from_qu_name_plural": "Kilogrammes", "to_qu_id": 5, "to_qu_name": "Gramme", "to_qu_name_plural": "Grammes", "factor": 1000, "path": "/12/5/" }, { "id": -1, "product_id": 19, "from_qu_id": 12, "from_qu_name": "Kilogramme", "from_qu_name_plural": "Kilogrammes", "to_qu_id": 12, "to_qu_name": "Kilogramme", "to_qu_name_plural": "Kilogrammes", "factor": 1, "path": "/12/12/" }, { "id": -1, "product_id": 19, "from_qu_id": 12, "from_qu_name": "Kilogramme", "from_qu_name_plural": "Kilogrammes", "to_qu_id": 13, "to_qu_name": "Pincée", "to_qu_name_plural": "Pincées", "factor": 500, "path": "/12/13/" }, { "id": -1, "product_id": 19, "from_qu_id": 13, "from_qu_name": "Pincée", "from_qu_name_plural": "Pincées", "to_qu_id": 5, "to_qu_name": "Gramme", "to_qu_name_plural": "Grammes", "factor": 2, "path": "/13/12/5/" }, { "id": -1, "product_id": 19, "from_qu_id": 13, "from_qu_name": "Pincée", "from_qu_name_plural": "Pincées", "to_qu_id": 12, "to_qu_name": "Kilogramme", "to_qu_name_plural": "Kilogrammes", "factor": 0.002, "path": "/13/12/" } ] ```When I use Grocy-Android to buy 2 kilograms of this item, Grocy adds 2000 kilograms instead
``` POST /api/stock/products/19/add HTTP/1.1 Host: ... Content-Length: 67 GROCY-API-KEY: ... Content-Type: application/json; charset=utf-8 User-Agent: Dalvik/2.1.0 (Linux; U; Android 13; FP3 Build/TQ3A.230705.001) Accept-Encoding: gzip {"amount":"2000","best_before_date":"2999-12-31","location_id":"2"} ```(you can click on each paragraph above to display dumps from the API)
so it looks like Grocy-Android is implicitly converting it to grams, and sending the quantity to the server in grams while the server expects it in kilograms.