{"openapi":"3.1.0","info":{"title":"Warehouse Service API","description":"Shipments, returns (RMA), suppliers, purchase orders and the stock ledger. Uses the access tokens issued by the backend.","license":{"name":"Apache 2.0","url":"http://springdoc.org"},"version":"1.0"},"servers":[{"url":"https://awesome.byst.re","description":"Generated server url"}],"tags":[{"name":"Stock ledger (internal)","description":"Reservations, adjustments, stock items and movements; called by the backend with its service token"},{"name":"Returns","description":"Customer returns (RMA)"},{"name":"Warehouse","description":"Fulfilment queue and shipment state machine for warehouse operators"},{"name":"Orders","description":"Order management endpoints"},{"name":"Tracking","description":"Public parcel tracking"},{"name":"Purchasing","description":"Suppliers, purchase orders, goods receipts and reorder suggestions"},{"name":"Warehouse locations","description":"Warehouse locations, their activation and the fulfilment reconciliation report"}],"paths":{"/internal/v1/stock/items/{productId}":{"get":{"tags":["Stock ledger (internal)"],"summary":"Get a product's stock","description":"Returns the quantity and ledger version.","operationId":"item","parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Stock item returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/StockItemDto"}}}},"404":{"description":"Product not found (no stock item)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]},"put":{"tags":["Stock ledger (internal)"],"summary":"Create a product's stock item","description":"Creates the item with ledgerVersion 1 and, for a positive quantity, an INITIAL_STOCK movement. An existing item is left unchanged and returned with 200.","operationId":"createItem","parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InitialStockRequestDto"}}},"required":true},"responses":{"201":{"description":"Stock item created","content":{"*/*":{"schema":{"$ref":"#/components/schemas/StockItemDto"}}}},"200":{"description":"Stock item already existed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/StockItemDto"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]},"delete":{"tags":["Stock ledger (internal)"],"summary":"Delete a product's stock","description":"Deletes the item, its movements, its reservation lines and its pending levels. Idempotent: 204 also when there is no item.","operationId":"deleteItem","parameters":[{"name":"productId","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"204":{"description":"Stock item deleted (or absent)"}},"security":[{"backendServiceToken":[]}]}},"/api/v1/warehouse/locations/{code}":{"put":{"tags":["Warehouse locations"],"summary":"Activate or deactivate location","description":"An inactive location receives no new allocations; parcels already allocated there stay until they are reallocated.","operationId":"update","parameters":[{"name":"code","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateLocationDto"}}},"required":true},"responses":{"200":{"description":"Location updated","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WarehouseLocationDto"}}}},"400":{"description":"Missing active flag","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Warehouse location not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/purchase-orders/{id}":{"get":{"tags":["Purchasing"],"summary":"Get purchase order","description":"Returns one purchase order with received and outstanding quantities.","operationId":"get","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Purchase order returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"404":{"description":"Purchase order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]},"put":{"tags":["Purchasing"],"summary":"Update draft purchase order","description":"Replaces the supplier, note and lines of a DRAFT purchase order.","operationId":"update_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderRequestDto"}}},"required":true},"responses":{"200":{"description":"Draft updated","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"400":{"description":"Invalid purchase order or duplicate product","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Purchase order, supplier or product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Purchase order is no longer a draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/internal/v1/stock/reservations":{"post":{"tags":["Stock ledger (internal)"],"summary":"Reserve stock for a checkout","description":"Locks the items in product id order, checks every line, then deducts every line with an ORDER_DEDUCTED movement. The reservation stays PENDING_CONFIRMATION until confirmed. A repeated call with the same reservationId and lines returns the stored reservation.","operationId":"reserve","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReserveStockRequestDto"}}},"required":true},"responses":{"201":{"description":"Stock reserved (or the stored reservation replayed)","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReservationDto"}}}},"400":{"description":"Invalid request or a product listed twice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"A product has no stock item; nothing was deducted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockErrorDto"}}}},"409":{"description":"Insufficient stock (the first short product in id order), or the reservationId was used with different lines; nothing was deducted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockErrorDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]}},"/internal/v1/stock/reservations/{reservationId}/release":{"post":{"tags":["Stock ledger (internal)"],"summary":"Release a reservation","description":"Puts back the stock of a PENDING_CONFIRMATION reservation (ORDER_RESTORED movements by \"system\", reason \"Reservation released\") and marks it RELEASED. Repeated calls return the same body. Confirmed reservations are restored only through order.cancelled.","operationId":"release","parameters":[{"name":"reservationId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Reservation released","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReleasedReservationDto"}}}},"404":{"description":"Reservation not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Reservation already confirmed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]}},"/internal/v1/stock/reservations/{reservationId}/confirm":{"post":{"tags":["Stock ledger (internal)"],"summary":"Confirm a reservation","description":"Marks the reservation CONFIRMED for the order and sets the order id on its movements. Idempotent for the same order.","operationId":"confirm","parameters":[{"name":"reservationId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConfirmReservationRequestDto"}}},"required":true},"responses":{"200":{"description":"Reservation confirmed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReservationDto"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Reservation not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Reservation released, or confirmed for another order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]}},"/internal/v1/stock/adjustments":{"post":{"tags":["Stock ledger (internal)"],"summary":"Adjust stock","description":"Admin adjustment with the backend's former rules: a replay of (productId, requestId) with the same delta and reason returns the stored movement; the result must stay within 0..2147483647. Returns the movement plus the ledger version it left.","operationId":"adjust","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockAdjustmentRequestDto"}}},"required":true},"responses":{"201":{"description":"Adjustment recorded (or the stored one replayed)","content":{"*/*":{"schema":{"$ref":"#/components/schemas/StockAdjustmentDto"}}}},"400":{"description":"Invalid request or a zero delta","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Product not found (no stock item)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"requestId already used with different payload, insufficient stock, or the result exceeds the supported maximum","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]}},"/api/v1/warehouse/shipments":{"get":{"tags":["Warehouse"],"summary":"List shipments","description":"Lists shipments oldest first, optionally filtered by status. Negative page is clamped to zero; size is clamped to 1-100.","operationId":"list","parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"]}},{"name":"page","in":"query","description":"Zero-based page index","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","description":"Page size, 1-100","required":false,"schema":{"type":"integer","format":"int32","default":20}}],"responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Shipments returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoShipmentDto"}}}}},"security":[{"bearerAuth":[]}]},"post":{"tags":["Warehouse"],"summary":"Create shipment","description":"Releases a PAID order to the warehouse. Each order line is allocated to the highest-priority active location that stocks its category (one location for the whole order when one location can take every line), and one AWAITING_PICK parcel is created per location. Returns the first parcel; parcelCount tells how many were created.","operationId":"create","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateShipmentDto"}}},"required":true},"responses":{"201":{"description":"Parcels created; the first one is returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Order is not PAID, already has a shipment, or no active location stocks one of its categories","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/short-pick":{"post":{"tags":["Warehouse"],"summary":"Report short pick","description":"Records units of a product that could not be picked for an AWAITING_PICK parcel and moves them to the order's AWAITING_PICK parcel at another active location that stocks the category (a new parcel when there is none). A parcel left without lines is removed. Returns the receiving parcel.","operationId":"shortPick","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShortPickDto"}}},"required":true},"responses":{"200":{"description":"Units moved","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"400":{"description":"Missing product or quantity below 1","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Shipment not found, or the product is not in it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Parcel is not AWAITING_PICK, the quantity exceeds the line, or no other active location stocks the category","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/ship":{"post":{"tags":["Warehouse"],"summary":"Hand shipment to carrier","description":"PACKED to SHIPPED. The tracking number must match the carrier format. Without a tracking number the parcel goes to the simulated carrier, which generates a tracking number and moves the parcel through IN_TRANSIT and OUT_FOR_DELIVERY to DELIVERED on its own. The order becomes SHIPPED and the customer receives an email.","operationId":"ship","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShipShipmentDto"}}},"required":true},"responses":{"200":{"description":"Shipment shipped","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"400":{"description":"Missing carrier or invalid tracking number","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current shipment status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/reallocate":{"post":{"tags":["Warehouse"],"summary":"Reallocate parcel","description":"Moves an AWAITING_PICK parcel to another active location: the given targetLocation, or without it the best other active location that stocks all of the parcel's categories. The lines merge into the order's parcel at that location when there is one (the moved parcel is then removed). Returns the parcel now holding the lines.","operationId":"reallocate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReallocateShipmentDto"}}}},"responses":{"200":{"description":"Parcel reallocated","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"400":{"description":"Invalid target location code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Shipment or target location not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Parcel is not AWAITING_PICK, or the target is the current, an inactive or a non-stocking location, or the order's parcel there is past AWAITING_PICK, or no other location can take it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/pick":{"post":{"tags":["Warehouse"],"summary":"Mark shipment picked","description":"AWAITING_PICK to PICKED.","operationId":"pick","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment picked","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current shipment status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/pack":{"post":{"tags":["Warehouse"],"summary":"Mark shipment packed","description":"PICKED to PACKED with the package weight (0.01-30.00 kg).","operationId":"pack","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PackShipmentDto"}}},"required":true},"responses":{"200":{"description":"Shipment packed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"400":{"description":"Invalid weight","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current shipment status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/deliver":{"post":{"tags":["Warehouse"],"summary":"Confirm delivery","description":"SHIPPED to DELIVERED. The order becomes DELIVERED, which enables reviews and returns, and the customer receives an email.","operationId":"deliver","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment delivered","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current shipment status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/carrier/advance":{"post":{"tags":["Warehouse"],"summary":"Advance simulated carrier","description":"Fast-forwards a simulated SHIPPED shipment by one carrier scan (IN_TRANSIT, OUT_FOR_DELIVERY, DELIVERY_FAILED or DELIVERED) without waiting for the step interval. The DELIVERED step delivers the shipment like the deliver endpoint.","operationId":"advanceCarrier","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment advanced; returns its tracking","content":{"*/*":{"schema":{"$ref":"#/components/schemas/TrackingDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Not a simulated shipment in status SHIPPED","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/cancel":{"post":{"tags":["Warehouse"],"summary":"Cancel shipment","description":"Cancels an AWAITING_PICK or PICKED parcel together with its order: every AWAITING_PICK or PICKED parcel of the order is cancelled, stock is restored and any coupon redemption is released. Refused while another parcel of the order is already PACKED or later.","operationId":"cancel","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment cancelled","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current shipment status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/orders/{orderId}/returns":{"post":{"tags":["Returns"],"summary":"Request a return","description":"Opens a return for the caller's DELIVERED order within 30 days of delivery. Each product may appear once, and quantities cannot exceed what was bought minus units in other non-rejected returns.","operationId":"create_1","parameters":[{"name":"orderId","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateReturnDto"}}},"required":true},"responses":{"201":{"description":"Return requested","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"400":{"description":"Invalid request, duplicate product, or product not in the order","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Order not delivered, return window passed, or quantity exceeds what can be returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/suppliers":{"get":{"tags":["Purchasing"],"summary":"List suppliers","description":"Lists suppliers by name.","operationId":"suppliers","responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Suppliers returned","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SupplierDto"}}}}}},"security":[{"bearerAuth":[]}]},"post":{"tags":["Purchasing"],"summary":"Create supplier","description":"Creates a supplier with a case-insensitively unique name and a lead time of 0-365 days.","operationId":"createSupplier","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierRequestDto"}}},"required":true},"responses":{"201":{"description":"Supplier created","content":{"*/*":{"schema":{"$ref":"#/components/schemas/SupplierDto"}}}},"400":{"description":"Invalid supplier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"409":{"description":"Supplier name already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns/{id}/reject":{"post":{"tags":["Returns"],"summary":"Reject return","description":"REQUESTED to REJECTED with a note for the customer. Rejected quantities become returnable again.","operationId":"reject","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RejectReturnDto"}}},"required":true},"responses":{"200":{"description":"Return rejected","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"400":{"description":"Missing note","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current return status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns/{id}/refund":{"post":{"tags":["Returns"],"summary":"Refund return","description":"RECEIVED to REFUNDED. The refund is the returned items' value scaled by the order's total-to-subtotal ratio, rounded half-up. The customer is emailed.","operationId":"refund","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Return refunded","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current return status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns/{id}/receive":{"post":{"tags":["Returns"],"summary":"Receive returned goods","description":"APPROVED to RECEIVED. Every returned product needs a condition; RESELLABLE units go back to stock as RETURN_RESTOCKED movements.","operationId":"receive","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReceiveReturnDto"}}},"required":true},"responses":{"200":{"description":"Return received","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"400":{"description":"Conditions missing or not matching the returned products","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current return status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns/{id}/approve":{"post":{"tags":["Returns"],"summary":"Approve return","description":"REQUESTED to APPROVED. The customer is emailed.","operationId":"approve","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Return approved","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Transition not allowed from the current return status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/purchase-orders":{"get":{"tags":["Purchasing"],"summary":"List purchase orders","description":"Lists purchase orders newest first, optionally filtered by status. Negative page is clamped to zero; size is clamped to 1-100.","operationId":"list_1","parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["DRAFT","SUBMITTED","PARTIALLY_RECEIVED","RECEIVED","CANCELLED"]}},{"name":"page","in":"query","description":"Zero-based page index","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","description":"Page size, 1-100","required":false,"schema":{"type":"integer","format":"int32","default":20}}],"responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Purchase orders returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoPurchaseOrderDto"}}}}},"security":[{"bearerAuth":[]}]},"post":{"tags":["Purchasing"],"summary":"Create purchase order","description":"Creates a DRAFT purchase order. Lines may be empty until submission; each product may appear once.","operationId":"create_2","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderRequestDto"}}},"required":true},"responses":{"201":{"description":"Draft created","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"400":{"description":"Invalid purchase order or duplicate product","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Supplier or product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/purchase-orders/{id}/submit":{"post":{"tags":["Purchasing"],"summary":"Submit purchase order","description":"DRAFT to SUBMITTED. Requires at least one line; expectedAt is the submission time plus the supplier lead time.","operationId":"submit","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Purchase order submitted","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"400":{"description":"Purchase order has no lines","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"404":{"description":"Purchase order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Purchase order is not a draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/purchase-orders/{id}/receipts":{"post":{"tags":["Purchasing"],"summary":"Receive goods","description":"Books received units for SUBMITTED or PARTIALLY_RECEIVED purchase orders and raises stock with PURCHASE_RECEIVED movements. Receiving more than is outstanding returns 409. Repeating requestId with the same lines returns the current purchase order without booking again.","operationId":"receive_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReceiptRequestDto"}}},"required":true},"responses":{"200":{"description":"Goods received, or receipt replayed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"400":{"description":"Invalid receipt, duplicate product, or product not on the purchase order","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationErrorsDto"},{"$ref":"#/components/schemas/ErrorDto"}]}}}},"404":{"description":"Purchase order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Not open for receipt, over-receipt, or requestId reused with different lines","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/purchase-orders/{id}/cancel":{"post":{"tags":["Purchasing"],"summary":"Cancel purchase order","description":"Cancels a DRAFT or SUBMITTED purchase order. Orders with received goods cannot be cancelled.","operationId":"cancel_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Purchase order cancelled","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PurchaseOrderDto"}}}},"404":{"description":"Purchase order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"409":{"description":"Purchase order cannot be cancelled in its status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/internal/v1/stock/movements":{"get":{"tags":["Stock ledger (internal)"],"summary":"List a product's movements","description":"Movements newest first (createdAt desc, then id desc), in the backend's page format. Negative page is clamped to zero; size is clamped to 1-100. A product without a stock item has no movements.","operationId":"movements","parameters":[{"name":"productId","in":"query","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":20}}],"responses":{"200":{"description":"Movements returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoInventoryMovementDto"}}}},"400":{"description":"Missing or invalid parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"401":{"description":"Missing or invalid backend service token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Stock ledger not initialised (the startup import is running)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"backendServiceToken":[]}]}},"/api/v1/warehouse/shipments/{id}":{"get":{"tags":["Warehouse"],"summary":"Get shipment","description":"Returns one parcel with its location, lines and timestamps.","operationId":"get_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/shipments/{id}/pick-list":{"get":{"tags":["Warehouse"],"summary":"Get pick list","description":"Returns the parcel's products to pick grouped by product and sorted by category, then name.","operationId":"pickList","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Pick list returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PickListDto"}}}},"404":{"description":"Shipment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/reconciliation":{"get":{"tags":["Warehouse locations"],"summary":"Fulfilment reconciliation","description":"Orders (at most 100, lowest id first) with an open parcel whose expected backend state, max(last mirrored, aggregate of the parcels), differs from the backend's fulfilmentState, for example a customer cancellation the event feed has not applied yet.","operationId":"reconciliation","responses":{"200":{"description":"Disagreeing orders returned","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ReconciliationDto"}}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/queue":{"get":{"tags":["Warehouse"],"summary":"Get fulfilment queue","description":"Lists PAID orders that have not been released to the warehouse yet, oldest first. Negative page is clamped to zero; size is clamped to 1-100.","operationId":"queue","parameters":[{"name":"page","in":"query","description":"Zero-based page index","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","description":"Page size, 1-100","required":false,"schema":{"type":"integer","format":"int32","default":20}}],"responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Queue returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoOrderDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/warehouse/locations":{"get":{"tags":["Warehouse locations"],"summary":"List warehouse locations","description":"Lists every location by priority with its active flag and the categories it stocks as PRIMARY or BACKUP (\"*\" stands for every category without its own entry).","operationId":"locations","responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden; requires ROLE_WAREHOUSE or ROLE_ADMIN","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Locations returned","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WarehouseLocationDto"}}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/tracking/{trackingNumber}":{"get":{"tags":["Tracking"],"summary":"Track parcel by tracking number","description":"Public, no authentication. Returns the carrier, current status, estimated delivery and scans of the parcel; no order id, customer or address. Surrounding spaces are ignored and letters are upper-cased.","operationId":"track","parameters":[{"name":"trackingNumber","in":"path","description":"Carrier tracking number","required":true,"schema":{"type":"string"},"example":1234567890}],"responses":{"200":{"description":"Tracking returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PublicTrackingDto"}}}},"404":{"description":"Tracking number not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}}}},"/api/v1/returns":{"get":{"tags":["Returns"],"summary":"List my returns","description":"Lists the caller's returns newest first. Negative page is clamped to zero; size is clamped to 1-100.","operationId":"mine","parameters":[{"name":"page","in":"query","description":"Zero-based page index","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","description":"Page size, 1-100","required":false,"schema":{"type":"integer","format":"int32","default":10}}],"responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Returns listed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoReturnDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/returns/{id}":{"get":{"tags":["Returns"],"summary":"Get my return","description":"Returns one of the caller's returns with its estimated or paid refund.","operationId":"get_2","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Return found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/orders/{id}/shipments":{"get":{"tags":["Orders"],"summary":"List order parcels","description":"Returns every parcel of one of the caller's orders, oldest first, each with its location, lines and tracking number. Empty while the order is not released to the warehouse. Administrators may list any order.","operationId":"parcels","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Parcels returned","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ShipmentDto"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"404":{"description":"Order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/orders/{id}/shipment":{"get":{"tags":["Orders"],"summary":"Track order shipment","description":"Returns the first parcel of one of the caller's orders, with locationCode and parcelCount; GET /api/v1/orders/{id}/shipments lists every parcel. Administrators may track any order.","operationId":"track_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Shipment returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ShipmentDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"404":{"description":"Order not found, or not released to the warehouse yet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/orders/{id}/shipment/tracking":{"get":{"tags":["Orders"],"summary":"Track order parcel","description":"Returns the carrier tracking of the order's first parcel (scans, current status, estimated delivery) for one of the caller's orders. Administrators may track any order. Before the hand-over to the carrier the events are empty.","operationId":"tracking","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Tracking returned","content":{"*/*":{"schema":{"$ref":"#/components/schemas/TrackingDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"404":{"description":"Order not found, or not released to the warehouse yet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns":{"get":{"tags":["Returns"],"summary":"List returns","description":"Lists returns oldest first, optionally filtered by status. Negative page is clamped to zero; size is clamped to 1-100.","operationId":"list_2","parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["REQUESTED","APPROVED","REJECTED","RECEIVED","REFUNDED"]}},{"name":"page","in":"query","description":"Zero-based page index","required":false,"schema":{"type":"integer","format":"int32","default":0}},{"name":"size","in":"query","description":"Page size, 1-100","required":false,"schema":{"type":"integer","format":"int32","default":20}}],"responses":{"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"200":{"description":"Returns listed","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageDtoReturnDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/returns/{id}":{"get":{"tags":["Returns"],"summary":"Get return","description":"Returns any customer's return.","operationId":"get_3","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Return found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReturnDto"}}}},"404":{"description":"Return not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}},"/api/v1/admin/inventory/reorder-suggestions":{"get":{"tags":["Purchasing"],"summary":"Get reorder suggestions","description":"Lists products whose stock plus units outstanding on open purchase orders is at or below the threshold, with suggestedQuantity = 4 × threshold − stock − incoming. Sorted by projected stock, then product id.","operationId":"reorderSuggestions","parameters":[{"name":"lowStockThreshold","in":"query","description":"Inclusive low-stock threshold; at least one","required":false,"schema":{"type":"string","minimum":1}}],"responses":{"200":{"description":"Suggestions returned","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ReorderSuggestionDto"}}}}},"400":{"description":"Threshold below 1","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorsDto"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}},"503":{"description":"Backend unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorDto"}}}}},"security":[{"bearerAuth":[]}]}}},"components":{"schemas":{"InitialStockRequestDto":{"type":"object","properties":{"initialQuantity":{"type":"integer","format":"int32","example":10,"minimum":0},"actor":{"type":"string","example":"admin","maxLength":255,"minLength":0},"requestId":{"type":["string","null"],"format":"uuid"}},"required":["actor","initialQuantity"]},"ValidationErrorsDto":{"type":"object","additionalProperties":{"type":"string","description":"Validation messages keyed by field name; invalid arguments use the error key","example":{"email":"Email should be valid"}},"description":"Validation messages keyed by field name; invalid arguments use the error key","example":{"email":"Email should be valid"},"properties":{"empty":{"type":"boolean"}}},"ErrorDto":{"type":"object","additionalProperties":false,"properties":{"message":{"type":"string","description":"Error message","example":"Error message"}},"required":["message"]},"StockItemDto":{"type":"object","properties":{"productId":{"type":"integer","format":"int64","example":1},"quantity":{"type":"integer","format":"int32","example":10},"ledgerVersion":{"type":"integer","format":"int64","example":1}},"required":["ledgerVersion","productId","quantity"]},"UpdateLocationDto":{"type":"object","description":"Location activation","properties":{"active":{"type":"boolean","description":"false stops new allocations to the location; parcels already there stay","example":false}},"required":["active"]},"WarehouseLocationDto":{"type":"object","description":"Warehouse location with the categories it stocks","properties":{"code":{"type":"string","description":"Location code","example":"KRK"},"name":{"type":"string","description":"Location name","example":"Krakow Central"},"city":{"type":"string","description":"City","example":"Krakow"},"active":{"type":"boolean","description":"Whether new parcels are allocated to this location","example":true},"priority":{"type":"integer","format":"int32","description":"Allocation priority; lower numbers are preferred","example":1},"primaryCategories":{"type":"array","description":"Categories shipped from here first; \"*\" stands for every category without its own entry","example":["*"],"items":{"type":"string"}},"backupCategories":{"type":"array","description":"Categories shipped from here when no primary location can; \"*\" as above","example":["Books"],"items":{"type":"string"}}}},"PurchaseOrderLineRequestDto":{"type":"object","description":"Purchase order line","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"quantity":{"type":"integer","format":"int32","description":"Units ordered","example":50,"maximum":100000,"minimum":1},"unitCost":{"type":"number","description":"Purchase price per unit","example":640.0,"minimum":0.01,"multipleOf":0.01}},"required":["productId","quantity","unitCost"]},"PurchaseOrderRequestDto":{"type":"object","description":"Draft purchase order; lines may be empty until submission","properties":{"supplierId":{"type":"integer","format":"int64","description":"Supplier ID","example":1},"note":{"type":["string","null"],"description":"Internal note","example":"Restock before Black Friday","maxLength":500,"minLength":0},"lines":{"type":"array","description":"Lines; each product at most once","items":{"$ref":"#/components/schemas/PurchaseOrderLineRequestDto"},"maxItems":200,"minItems":0}},"required":["supplierId"]},"PurchaseOrderDto":{"type":"object","description":"Purchase order","properties":{"id":{"type":"integer","format":"int64","description":"Purchase order ID","example":1},"supplierId":{"type":"integer","format":"int64","description":"Supplier ID","example":1},"supplierName":{"type":"string","description":"Supplier name","example":"Nordic Electronics"},"status":{"type":"string","description":"Status","enum":["DRAFT","SUBMITTED","PARTIALLY_RECEIVED","RECEIVED","CANCELLED"],"example":"SUBMITTED"},"note":{"type":["string","null"],"description":"Internal note"},"createdBy":{"type":"string","description":"Creator","example":"admin"},"totalCost":{"type":"number","description":"Sum of line totals","example":32000.0},"lines":{"type":"array","description":"Lines","items":{"$ref":"#/components/schemas/PurchaseOrderLineDto"}},"createdAt":{"type":"string","format":"local-date-time","description":"Creation timestamp"},"updatedAt":{"type":"string","format":"local-date-time","description":"Last update timestamp"},"submittedAt":{"type":["string","null"],"format":"local-date-time","description":"Submission timestamp"},"expectedAt":{"type":["string","null"],"format":"local-date-time","description":"submittedAt plus the supplier lead time"},"receivedAt":{"type":["string","null"],"format":"local-date-time","description":"When the last units arrived"},"cancelledAt":{"type":["string","null"],"format":"local-date-time","description":"Cancellation timestamp"}}},"PurchaseOrderLineDto":{"type":"object","description":"Purchase order line","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"productName":{"type":"string","description":"Product name","example":"iPhone 13 Pro"},"orderedQuantity":{"type":"integer","format":"int32","description":"Units ordered","example":50},"receivedQuantity":{"type":"integer","format":"int32","description":"Units received so far","example":20},"outstandingQuantity":{"type":"integer","format":"int32","description":"Units still expected","example":30},"unitCost":{"type":"number","description":"Purchase price per unit","example":640.0},"lineTotal":{"type":"number","description":"orderedQuantity × unitCost","example":32000.0}}},"ReserveStockRequestDto":{"type":"object","properties":{"reservationId":{"type":"string","format":"uuid"},"username":{"type":"string","example":"alice","maxLength":255,"minLength":0},"lines":{"type":"array","items":{"$ref":"#/components/schemas/StockLineDto"},"maxItems":100,"minItems":0}},"required":["lines","reservationId","username"]},"StockLineDto":{"type":"object","properties":{"productId":{"type":"integer","format":"int64","example":1,"exclusiveMinimum":0},"quantity":{"type":"integer","format":"int32","example":2,"exclusiveMinimum":0}},"required":["productId","quantity"]},"StockErrorDto":{"type":"object","properties":{"message":{"type":"string","example":"Insufficient stock for product 1"},"productId":{"type":"integer","format":"int64","example":1}},"required":["message"]},"ReservationDto":{"type":"object","properties":{"reservationId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/ReservedLineDto"}}},"required":["lines","reservationId"]},"ReservedLineDto":{"type":"object","properties":{"productId":{"type":"integer","format":"int64","example":1},"quantityAfter":{"type":"integer","format":"int32","example":8},"ledgerVersion":{"type":"integer","format":"int64","example":42}},"required":["ledgerVersion","productId","quantityAfter"]},"ReleasedReservationDto":{"type":"object","properties":{"reservationId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["PENDING_CONFIRMATION","CONFIRMED","RELEASED"]}},"required":["reservationId","status"]},"ConfirmReservationRequestDto":{"type":"object","properties":{"orderId":{"type":"integer","format":"int64","example":123,"exclusiveMinimum":0}},"required":["orderId"]},"StockAdjustmentRequestDto":{"type":"object","properties":{"productId":{"type":"integer","format":"int64","example":1,"exclusiveMinimum":0},"delta":{"type":"integer","format":"int32","example":-3},"reason":{"type":"string","example":"Damaged","maxLength":500,"minLength":0},"requestId":{"type":"string","format":"uuid"},"actor":{"type":"string","example":"admin","maxLength":255,"minLength":0}},"required":["actor","delta","productId","reason","requestId"]},"StockAdjustmentDto":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"productId":{"type":"integer","format":"int64"},"orderId":{"type":["integer","null"],"format":"int64"},"type":{"type":"string","enum":["INITIAL_STOCK","ADMIN_ADJUSTMENT","ORDER_DEDUCTED","ORDER_RESTORED","PURCHASE_RECEIVED","RETURN_RESTOCKED"]},"delta":{"type":"integer","format":"int32"},"quantityAfter":{"type":"integer","format":"int32"},"actor":{"type":"string"},"reason":{"type":"string"},"requestId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string","format":"local-date-time","description":"UTC date and time without an offset"},"ledgerVersion":{"type":"integer","format":"int64","example":43}}},"CreateShipmentDto":{"type":"object","description":"Release a PAID order to the warehouse","properties":{"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42}},"required":["orderId"]},"ShipmentDto":{"type":"object","description":"Warehouse shipment: one parcel of an order, shipped from one location","properties":{"id":{"type":"integer","format":"int64","description":"Shipment ID","example":1},"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42},"username":{"type":"string","description":"Order owner","example":"client"},"status":{"type":"string","description":"Shipment status","enum":["AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"AWAITING_PICK"},"totalUnits":{"type":"integer","format":"int32","description":"Units to pick for this parcel","example":3},"locationCode":{"type":"string","description":"Location the parcel ships from","example":"KRK"},"locationName":{"type":"string","description":"Name of that location","example":"Krakow Central"},"parcelIndex":{"type":"integer","format":"int32","description":"1-based position of the parcel among the order's parcels (oldest first)","example":1},"parcelCount":{"type":"integer","format":"int32","description":"Number of parcels of the order","example":2},"lines":{"type":"array","description":"Products in this parcel","items":{"$ref":"#/components/schemas/ShipmentLineDto"}},"carrier":{"type":["string","null"],"description":"Carrier, set when shipped","enum":["INPOST","DPD","DHL","UPS"],"example":"DHL"},"trackingNumber":{"type":["string","null"],"description":"Carrier tracking number","example":"1234567890"},"weightKg":{"type":["number","null"],"description":"Package weight in kilograms, set when packed","example":1.25},"createdBy":{"type":"string","description":"User who released the order to the warehouse","example":"warehouse"},"lastActor":{"type":"string","description":"User who performed the latest transition","example":"warehouse"},"createdAt":{"type":"string","format":"local-date-time","description":"Creation timestamp"},"updatedAt":{"type":"string","format":"local-date-time","description":"Last update timestamp"},"pickedAt":{"type":["string","null"],"format":"local-date-time","description":"When picking finished"},"packedAt":{"type":["string","null"],"format":"local-date-time","description":"When packing finished"},"shippedAt":{"type":["string","null"],"format":"local-date-time","description":"When the carrier collected the parcel"},"deliveredAt":{"type":["string","null"],"format":"local-date-time","description":"When the parcel was delivered"},"cancelledAt":{"type":["string","null"],"format":"local-date-time","description":"When the shipment was cancelled"}}},"ShipmentLineDto":{"type":"object","description":"Units of one product in a parcel","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"productName":{"type":"string","description":"Product name at release","example":"iPhone 13 Pro"},"category":{"type":["string","null"],"description":"Product category at release","example":"Electronics"},"quantity":{"type":"integer","format":"int32","description":"Units in this parcel","example":2}}},"ShortPickDto":{"type":"object","description":"Units of a product that could not be found while picking","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID of a line in the parcel","example":3},"missingQuantity":{"type":"integer","format":"int32","description":"Units to move to a parcel at another location","example":1,"minimum":1}},"required":["missingQuantity","productId"]},"ShipShipmentDto":{"type":"object","description":"Carrier hand-over. INPOST: 24 digits, DPD: 14 digits, DHL: 10 digits, UPS: 1Z + 16 letters or digits. Omit trackingNumber to hand the parcel to the simulated carrier, which generates the number and delivers automatically.","properties":{"carrier":{"type":"string","description":"Carrier","enum":["INPOST","DPD","DHL","UPS"],"example":"DHL"},"trackingNumber":{"type":["string","null"],"description":"Tracking number; surrounding spaces are ignored and letters are upper-cased. Omit it (or send null) for the simulated carrier.","example":"1234567890","minLength":1,"pattern":"(?s).*\\S.*"}},"required":["carrier"]},"ReallocateShipmentDto":{"type":"object","description":"Parcel reallocation. Omit targetLocation (or the whole body) to move the parcel to the best other active location that stocks all of its categories","properties":{"targetLocation":{"type":["string","null"],"description":"Target location code","example":"GDN","pattern":"\\s*[A-Za-z0-9]{1,8}\\s*"}}},"PackShipmentDto":{"type":"object","description":"Packing result","properties":{"weightKg":{"type":"number","description":"Package weight in kilograms","example":1.25,"maximum":30.00,"minimum":0.01,"multipleOf":0.01}},"required":["weightKg"]},"TrackingDto":{"type":"object","description":"Carrier tracking of an order's shipment","properties":{"shipmentId":{"type":"integer","format":"int64","description":"Shipment ID","example":1},"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42},"carrier":{"type":["string","null"],"description":"Carrier, set when shipped","enum":["INPOST","DPD","DHL","UPS"],"example":"DHL"},"trackingNumber":{"type":["string","null"],"description":"Carrier tracking number, set when shipped","example":"1234567890"},"simulated":{"type":"boolean","description":"True when the parcel was handed to the simulated carrier, which advances it automatically","example":true},"currentStatus":{"type":["string","null"],"description":"Status of the latest scan; null before the hand-over","enum":["LABEL_CREATED","IN_TRANSIT","OUT_FOR_DELIVERY","DELIVERY_FAILED","DELIVERED"],"example":"IN_TRANSIT"},"estimatedDelivery":{"type":["string","null"],"format":"local-date-time","description":"Expected delivery (the delivery time once delivered); null before the hand-over"},"events":{"type":"array","description":"Carrier scans, oldest first","items":{"$ref":"#/components/schemas/TrackingEventDto"}}}},"TrackingEventDto":{"type":"object","description":"One carrier scan","properties":{"status":{"type":"string","description":"Carrier status after this scan","enum":["LABEL_CREATED","IN_TRANSIT","OUT_FOR_DELIVERY","DELIVERY_FAILED","DELIVERED"],"example":"IN_TRANSIT"},"location":{"type":"string","description":"Where the parcel was scanned","example":"DHL Hub, Leipzig"},"description":{"type":"string","description":"What happened","example":"Collected from the sender and sorted at the hub"},"occurredAt":{"type":"string","format":"local-date-time","description":"When the scan happened"}}},"CreateReturnDto":{"type":"object","description":"Return request for a delivered order","properties":{"reason":{"type":"string","description":"Return reason","enum":["DAMAGED","WRONG_ITEM","NOT_AS_DESCRIBED","NO_LONGER_NEEDED"],"example":"DAMAGED"},"comment":{"type":["string","null"],"description":"Customer comment","example":"Screen arrived cracked","maxLength":1000,"minLength":0},"items":{"type":"array","description":"Items to return; each product at most once","items":{"$ref":"#/components/schemas/ReturnItemRequestDto"},"minItems":1}},"required":["items","reason"]},"ReturnItemRequestDto":{"type":"object","description":"Product and quantity to return","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID from the order","example":3},"quantity":{"type":"integer","format":"int32","description":"Units to return","example":1,"minimum":1}},"required":["productId","quantity"]},"ReturnDto":{"type":"object","description":"Return request (RMA)","properties":{"id":{"type":"integer","format":"int64","description":"Return ID","example":1},"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42},"username":{"type":"string","description":"Customer","example":"client"},"status":{"type":"string","description":"Status","enum":["REQUESTED","APPROVED","REJECTED","RECEIVED","REFUNDED"],"example":"REQUESTED"},"reason":{"type":"string","description":"Reason","enum":["DAMAGED","WRONG_ITEM","NOT_AS_DESCRIBED","NO_LONGER_NEEDED"],"example":"DAMAGED"},"comment":{"type":["string","null"],"description":"Customer comment"},"resolutionNote":{"type":["string","null"],"description":"Administrator note"},"estimatedRefund":{"type":"number","description":"Refund the customer receives, proportional to any order discount","example":899.99},"refundAmount":{"type":["number","null"],"description":"Refund paid; set when REFUNDED","example":899.99},"items":{"type":"array","description":"Returned items","items":{"$ref":"#/components/schemas/ReturnItemDto"}},"createdAt":{"type":"string","format":"local-date-time","description":"Creation timestamp"},"updatedAt":{"type":"string","format":"local-date-time","description":"Last update timestamp"},"approvedAt":{"type":["string","null"],"format":"local-date-time","description":"Approval timestamp"},"rejectedAt":{"type":["string","null"],"format":"local-date-time","description":"Rejection timestamp"},"receivedAt":{"type":["string","null"],"format":"local-date-time","description":"Receipt timestamp"},"refundedAt":{"type":["string","null"],"format":"local-date-time","description":"Refund timestamp"}}},"ReturnItemDto":{"type":"object","description":"Returned item","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"productName":{"type":"string","description":"Product name","example":"iPhone 13 Pro"},"quantity":{"type":"integer","format":"int32","description":"Units returned","example":1},"unitPrice":{"type":"number","description":"Unit price paid before discounts","example":999.99},"condition":{"type":["string","null"],"description":"Condition recorded on receipt","enum":["RESELLABLE","DAMAGED"],"example":"RESELLABLE"}}},"SupplierRequestDto":{"type":"object","description":"Supplier","properties":{"name":{"type":"string","description":"Unique name, case-insensitive","example":"Nordic Electronics","maxLength":120,"minLength":2,"pattern":"\\S"},"email":{"type":"string","format":"email","description":"Purchasing contact","example":"orders@nordic.example","minLength":1,"pattern":"\\S"},"leadTimeDays":{"type":"integer","format":"int32","description":"Days between submission and expected delivery","example":7,"maximum":365,"minimum":0}},"required":["email","leadTimeDays","name"]},"SupplierDto":{"type":"object","description":"Supplier","properties":{"id":{"type":"integer","format":"int64","description":"Supplier ID","example":1},"name":{"type":"string","description":"Name","example":"Nordic Electronics"},"email":{"type":"string","description":"Purchasing contact","example":"orders@nordic.example"},"leadTimeDays":{"type":"integer","format":"int32","description":"Lead time in days","example":7},"createdAt":{"type":"string","format":"local-date-time","description":"Creation timestamp"}}},"RejectReturnDto":{"type":"object","description":"Rejection reason shown to the customer","properties":{"note":{"type":"string","description":"Reason","example":"Item shows signs of use","maxLength":500,"minLength":0,"pattern":"\\S"}},"required":["note"]},"ReceiveItemDto":{"type":"object","description":"Condition of one returned product","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"condition":{"type":"string","description":"RESELLABLE items return to stock","enum":["RESELLABLE","DAMAGED"],"example":"RESELLABLE"}},"required":["condition","productId"]},"ReceiveReturnDto":{"type":"object","description":"Inspection result covering every returned product exactly once","properties":{"items":{"type":"array","description":"Conditions per product","items":{"$ref":"#/components/schemas/ReceiveItemDto"},"minItems":1}},"required":["items"]},"ReceiptLineDto":{"type":"object","description":"Units received for one product","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"quantity":{"type":"integer","format":"int32","description":"Units received","example":20,"minimum":1}},"required":["productId","quantity"]},"ReceiptRequestDto":{"type":"object","description":"Goods receipt. Repeating requestId with the same lines replays the receipt; different lines return 409.","properties":{"requestId":{"type":"string","format":"uuid","description":"Client-generated idempotency key","example":"2f1c8a8e-3b0e-4d39-9d43-0a6d6f7f0a11"},"lines":{"type":"array","description":"Lines; each product at most once","items":{"$ref":"#/components/schemas/ReceiptLineDto"},"minItems":1}},"required":["lines","requestId"]},"InventoryMovementDto":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"productId":{"type":"integer","format":"int64"},"orderId":{"type":["integer","null"],"format":"int64"},"type":{"type":"string","enum":["INITIAL_STOCK","ADMIN_ADJUSTMENT","ORDER_DEDUCTED","ORDER_RESTORED","PURCHASE_RECEIVED","RETURN_RESTOCKED"]},"delta":{"type":"integer","format":"int32"},"quantityAfter":{"type":"integer","format":"int32"},"actor":{"type":"string"},"reason":{"type":"string"},"requestId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string","format":"local-date-time","description":"UTC date and time without an offset"}}},"PageDtoInventoryMovementDto":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/InventoryMovementDto"}},"pageNumber":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"}}},"PageDtoShipmentDto":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/ShipmentDto"}},"pageNumber":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"}}},"AddressDto":{"type":"object","description":"Address data transfer object","properties":{"street":{"type":"string","description":"Street address","example":"123 Main St","minLength":1,"pattern":"\\S"},"city":{"type":"string","description":"City","example":"New York","minLength":1,"pattern":"\\S"},"state":{"type":"string","description":"State","example":"NY","minLength":1,"pattern":"\\S"},"zipCode":{"type":"string","description":"Postal/ZIP code","example":"35-119","minLength":1,"pattern":"^[0-9]{2}(-[0-9]{3})?|[0-9]{5}(-[0-9]{4})?$"},"country":{"type":"string","description":"Country","example":"Poland","minLength":1,"pattern":"\\S"}},"required":["city","country","state","street","zipCode"]},"PickListDto":{"type":"object","description":"Pick list grouped by product and sorted by category, then name","properties":{"shipmentId":{"type":"integer","format":"int64","description":"Shipment ID","example":1},"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42},"status":{"type":"string","description":"Shipment status","enum":["AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"AWAITING_PICK"},"totalUnits":{"type":"integer","format":"int32","description":"Units to pick","example":3},"shippingAddress":{"$ref":"#/components/schemas/AddressDto","description":"Shipping address"},"items":{"type":"array","description":"Products to pick","items":{"$ref":"#/components/schemas/PickListItemDto"}}}},"PickListItemDto":{"type":"object","description":"Product to pick","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"productName":{"type":"string","description":"Product name","example":"iPhone 13 Pro"},"category":{"type":"string","description":"Category, used as the warehouse aisle","example":"Electronics"},"quantity":{"type":"integer","format":"int32","description":"Units to pick","example":2}}},"Parcel":{"type":"object","description":"Parcel status in a reconciliation entry","properties":{"shipmentId":{"type":"integer","format":"int64","description":"Shipment ID","example":7},"locationCode":{"type":"string","description":"Location code","example":"KRK"},"status":{"type":"string","description":"Parcel status","enum":["AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"PICKED"}}},"ReconciliationDto":{"type":"object","description":"An order whose parcels' aggregate fulfilment state disagrees with the backend","properties":{"orderId":{"type":"integer","format":"int64","description":"Order ID","example":42},"backendState":{"type":["string","null"],"description":"fulfilmentState on the backend; null when the backend does not know the order","enum":["NONE","AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"AWAITING_PICK"},"aggregateState":{"type":"string","description":"State the backend should have: max(last mirrored, aggregate of the parcels)","enum":["NONE","AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"PICKED"},"lastMirroredState":{"type":["string","null"],"description":"State last mirrored to the backend","enum":["NONE","AWAITING_PICK","PICKED","PACKED","SHIPPED","DELIVERED","CANCELLED"],"example":"AWAITING_PICK"},"parcels":{"type":"array","description":"The order's parcels","items":{"$ref":"#/components/schemas/Parcel"}}}},"OrderDto":{"type":"object","description":"Order data transfer object","properties":{"id":{"type":"integer","format":"int64","description":"Order ID","example":1},"username":{"type":"string","description":"Username","example":"john.doe"},"items":{"type":"array","description":"Order items","items":{"$ref":"#/components/schemas/OrderItemDto"}},"totalAmount":{"type":"number","description":"Total amount","example":1999.98},"subtotalAmount":{"type":"number","description":"Sum of item prices before discounts","example":2222.2},"discountAmount":{"type":"number","description":"Coupon discount subtracted from the subtotal","example":222.22},"couponCode":{"type":["string","null"],"description":"Coupon code applied at checkout","example":"WELCOME10"},"status":{"type":"string","description":"Order status","enum":["PENDING","PAID","SHIPPED","DELIVERED","CANCELLED"],"example":"PENDING"},"shippingAddress":{"$ref":"#/components/schemas/AddressDto","description":"Shipping address"},"createdAt":{"type":"string","format":"local-date-time","description":"Creation timestamp"},"updatedAt":{"type":"string","format":"local-date-time","description":"Last update timestamp"}},"required":["shippingAddress"]},"OrderItemDto":{"type":"object","description":"Order item data transfer object","properties":{"id":{"type":"integer","format":"int64","description":"Order item ID","example":1},"productId":{"type":"integer","format":"int64","description":"Product ID","example":1},"quantity":{"type":"integer","format":"int32","description":"Quantity","example":2,"minimum":1},"productName":{"type":"string","description":"Product name","example":"iPhone 13 Pro"},"unitPrice":{"type":"number","description":"Unit price","example":999.99},"totalPrice":{"type":"number","description":"Total price","example":1999.98}},"required":["productId","quantity"]},"PageDtoOrderDto":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/OrderDto"}},"pageNumber":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"}}},"PublicTrackingDto":{"type":"object","description":"Public carrier tracking of a parcel; contains no order or customer data","properties":{"shipmentId":{"type":"integer","format":"int64","description":"Shipment ID","example":1},"carrier":{"type":"string","description":"Carrier","enum":["INPOST","DPD","DHL","UPS"],"example":"DHL"},"trackingNumber":{"type":"string","description":"Carrier tracking number","example":"1234567890"},"simulated":{"type":"boolean","description":"True when the parcel was handed to the simulated carrier","example":true},"currentStatus":{"type":["string","null"],"description":"Status of the latest scan","enum":["LABEL_CREATED","IN_TRANSIT","OUT_FOR_DELIVERY","DELIVERY_FAILED","DELIVERED"],"example":"OUT_FOR_DELIVERY"},"estimatedDelivery":{"type":["string","null"],"format":"local-date-time","description":"Expected delivery (the delivery time once delivered)"},"events":{"type":"array","description":"Carrier scans, oldest first","items":{"$ref":"#/components/schemas/TrackingEventDto"}}}},"PageDtoReturnDto":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/ReturnDto"}},"pageNumber":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"}}},"PageDtoPurchaseOrderDto":{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/PurchaseOrderDto"}},"pageNumber":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"}}},"ReorderSuggestionDto":{"type":"object","description":"Product that should be reordered","properties":{"productId":{"type":"integer","format":"int64","description":"Product ID","example":3},"productName":{"type":"string","description":"Product name","example":"iPhone 13 Pro"},"category":{"type":"string","description":"Category","example":"Electronics"},"stockQuantity":{"type":"integer","format":"int32","description":"Stock on hand","example":2},"incomingQuantity":{"type":"integer","format":"int32","description":"Units outstanding on SUBMITTED or PARTIALLY_RECEIVED purchase orders","example":0},"suggestedQuantity":{"type":"integer","format":"int32","description":"4 × threshold − stock − incoming","example":18}}}},"securitySchemes":{"bearerAuth":{"type":"http","name":"bearerAuth","scheme":"bearer","bearerFormat":"JWT"},"backendServiceToken":{"type":"http","description":"The backend's BACKEND_SERVICE_TOKEN (caller BACKEND), only for /internal/v1/stock","name":"backendServiceToken","scheme":"bearer"}}}}