Panly API docsstaging

Screens / Shopping list

Shopping list

Stock at or under its minimum plus anything that ran out (status=restock, PAN-61), opened from the Stock page. Rows are grouped by last_supplier (A-Z, "No supplier" last; Out before Low, then by name) and show the Low/Out level, stock and minimum. The suggested amount is par_quantity (Restock to) minus stock, or the minimum minus stock when there is no target (negative stock adds up); it can be changed per row. Ticks and changed amounts are kept on the device per business (with the last loaded rows, so the list still shows offline; Receive is off then). Share and copy: the text is "Shopping list · <business>", the date, then every row in list order (checked or not) as "- Name: amount unit" under its supplier header (headers left out when no supplier is known). On a phone, Share opens the OS share sheet, anchored to the Share button's position (the iPad popover needs a non-empty origin, so a 1x1 fallback is used before layout; PAN-69), and falls back to copying where there is none; the desktop has Copy list in the header and a Text for WhatsApp preview with Copy in the side pane. Copying shows "List copied. Paste it in WhatsApp." Neither makes an API call. "Receive N into stock" opens a sheet with one block per supplier (amount prefilled, total cost typed, one date) and books each block as one stock-in. Empty state: "Nothing to buy". Add item (PAN-74/PAN-76, one sheet) searches stock and sets an ingredient's Low-stock minimum and Restock to; the API has no shopping-list write, so adding means setting that alert. Rows open the same levels sheet. The page needs `shopping.manage`.

App routes
/stock/shopping-list
Access
shopping.manage
Screen code
lib/screens/shopping_list/shopping_list_page.dart
lib/screens/shopping_list/shopping_list_controller.dart
lib/screens/shopping_list/shopping_list_bindings.dart
lib/screens/shopping_list/widgets/shopping_receive_sheet.dart
lib/screens/shopping_list/widgets/shopping_action_bar.dart
lib/domain/stock/shopping_list_rules.dart
lib/data/stock/shopping_list_store.dart
lib/core/utils/text_share.dart
lib/screens/shopping_list/widgets/shopping_add_sheet.dart
lib/screens/shopping_list/widgets/shopping_levels_sheet.dart
Source
elmermj/panly-app @ pre-staging-test (72aaffd)

API calls (5)

CallWhy the screen makes itWhere in the app code
GET /v1/ingredients
List ingredients
Every page of status=restock, limit 100 (low and out together). Reads par_quantity for the suggested amount, last_supplier for the groups, min_quantity and stock_quantity for the level lib/screens/shopping_list/shopping_list_controller.dart:146
lib/screens/shopping_list/shopping_list_controller.dart:158
lib/data/repositories/stock_repository.dart:39
lib/data/stock/stock_remote.dart:39
GET /v1/expense-categories
List expense categories
When Receive opens (once per visit): the first cost-of-goods category books the stock-ins; with none, Receive stays closed with "Add a cost-of-goods expense category before receiving stock." lib/screens/shopping_list/shopping_list_page.dart:143
lib/screens/shopping_list/shopping_list_controller.dart:272
lib/data/repositories/stock_repository.dart:100
lib/data/stock/stock_remote.dart:77
POST /v1/expenses
Create expense (ingredient lines auto-add stock)
Receive into stock: one stock-in per supplier block (ingredient_lines, supplier, note "From shopping list", incurred_on from the sheet), one after another
Not idempotent, so the app never retries by itself: it stops at the first failed block and a second try sends only the blocks that did not save. A 422 on ingredient_lines[i].quantity, .line_cost or supplier marks that field. Received rows lose their ticks and the list reloads.
lib/screens/shopping_list/widgets/shopping_receive_sheet.dart:100
lib/screens/shopping_list/shopping_list_controller.dart:315
lib/data/repositories/stock_repository.dart:111
lib/data/stock/stock_remote.dart:114
GET /v1/ingredients
List ingredients
Add item sheet: stock search (`q`, first 100) with what is in stock and each alert on every row lib/screens/shopping_list/widgets/shopping_add_sheet.dart:77
lib/screens/shopping_list/shopping_list_controller.dart:383
lib/data/repositories/stock_repository.dart:32
lib/data/stock/stock_remote.dart:39
PATCH /v1/ingredients/{ingredientId}
Update ingredient name, unit, low-stock minimum or restock target
Save the levels sheet or Add item: only the changed min_quantity (Low-stock minimum) and par_quantity (Restock to); the name goes as it is and the unit is never sent (PAN-95). The list reloads afterwards lib/screens/shopping_list/widgets/shopping_levels_sheet.dart:197
lib/screens/shopping_list/shopping_list_controller.dart:397
lib/data/repositories/stock_repository.dart:62
lib/data/repositories/catalog_repository.dart:73
lib/data/catalog/catalog_remote.dart:149

Each call links to its operation in the API reference. Code locations are file:line in panly-app at 72aaffd, listed from the screen down to the line that sends the request.