Inventory Item
Model
- class pytm4srv.models.InventoryItem
Represents one inventory item.
- brand: Mapped[str]
The brand (manufacturer) of this item.
- coating: Mapped[str]
Type of coating or treatment (for some tools).
- corners: Mapped[int]
The number of indexed cutting positions this tool has.
- cut_length: Mapped[float | None]
Length of cut (for some tools).
- durable: Mapped[bool]
Whether this item lasts for many parts, such as a mount or drill block, and should not be included with the consumables.
- flutes: Mapped[int | None]
Number of flutes (for some tools).
- id: MappedColumn object at 0x7907c2991c60>]]
Unique, numeric ID for this inventory item in OnTakt.
- lead_time: Mapped[int | None]
Lead time when ordering this item (in days).
- min_on_hand_qty: Mapped[int]
The minimum number of this item to keep in stock.
safety_stock
is measured in production days and depends on inventory item consumption rates, butmin_on_hand_qty
is a minimum number of items to keep in stock at all times. Suggested order quantities will satisfy both requirements.
- name: Mapped[str]
Name of the inventory item separate from any assignments.
- notes: Mapped[str]
User-specified notes about this item.
- overall_length: Mapped[float | None]
OAL (for some tools).
- pack_qty: Mapped[int]
The minimum packaged quantity that can be ordered.
- part_number: Mapped[str]
Part number for ordering replacements.
- price: Mapped[float | None]
Average price of this item for order cost estimation.
- qty_on_order: Mapped[int]
Number that have been ordered but not received.
- safety_stock: Mapped[int | None]
Number of days of safety stock to keep when calculating order quantities.
NULL
means use the global default (controlled with thedefault_tool_safety_stock
setting).
- suppliers: Mapped[List[Dict[str, Any]]]
List of suppliers in the format:
[ { "name": "Supplier A", "partNumber": "45762384" }, { "name": "Supplier B", "partNumber": "7G63HDE56SDG2" } ]
- type: Mapped[str]
Type (for icon display).
Endpoints
- GET /api/inventory/ordering/items
Get a list of inventory items.
- Query Parameters:
tools (boolean) – set to include the tools associated with each item in the results
active_machine (int) – set to a machine ID to get only items that are used by tools assigned to the machine’s currently active process
- Status Codes:
400 Bad Request – if the machine parameter is set but is not a valid machine ID
- Returns:
A JSON object of all items.
- POST /api/inventory/ordering/items
Create a new inventory item.
- Reqjson:
partial inventory item object to create (name is required)
- Returns:
the new inventory item
- Status Codes:
400 Bad Request – if the name is missing
500 Internal Server Error – if there is an error
201 Created – on success
- PATCH /api/inventory/ordering/items/(int: item_id)
Edit an existing inventory item.
- Request JSON Object:
name (string) – new name for the item
price (float) – new price for the item
qty_on_order (int) – new quantity on order for the item
- Request JSON Array of Objects:
suppliers – new suppliers list to set
- Parameters:
item_id – The ID of the inventory item to modify
- Returns:
the modified item object
- Status Codes:
404 Not Found – if the item doesn’t exist
400 Bad Request – if the request body is invalid
- DELETE /api/inventory/ordering/items/(int: item_id)
Delete an inventory item.
- Parameters:
item_id – The ID of the item to delete
- Status Codes:
204 No Content – on success
404 Not Found – if the item does not exist
- POST /api/inventory/ordering/orderInfo
Calculate how many items are consumed each day for each item.
The request body may contain
processes
to limit the calculations to only the selected processes. Otherwise, it is assumed that all currently-active processes will be running.- Request JSON Array of Objects:
processes (int) – list of process IDs that will be running
- Status Codes:
400 Bad Request – if the cycle time is not defined for one of the selected programs
- Returns:
an object whose keys are inventory IDs, each mapping to an object with a
process
and/ormaintenance
property, which map the ID of a Process or MaintenanceItem to the number of the inventory item consumed per day by that process or maintenance item. See the returned data sample below:{ "36": { "process": { "20784": 2.2093023255813953, "20900": 0.145 } }, "37": { "maintenance": { "731": 0.062424242424242424 } }, "39": { "process": { "20731": 0.31212121212121213, "20900": 0.10545454545454545 }, "maintenance": { "661": 0.0000125, "675": 0.0016243 } } }
- POST /api/inventory/ordering/generateOrder
Create an order sheet with the selected inventory items and quantities.
- Reqjson:
an object mapping InventoryItem ID -> quantity to order
- Status Codes:
400 Bad Request – if the IDs are not provided or not provided correctly
- Returns:
a XLSX file download
- POST /api/inventory/ordering/markOnOrder
Add an on-order quantity to the given items.
The POST body should be a JSON object whose keys are inventory item IDs each pointing to a value representing the number to add to that item’s on-order count.
- Returns:
a JSON object containing all affected items
- POST /api/inventory/ordering/items/(int: item_id)/receiveOrder
Adds received quantities of a single inventory item to multiple inventory points and removes the received quantity from the item’s on-order quantity.
If any keys of the request object are not valid inventory point IDs, the error response will contain a
missing_inventory_points
key with a list of the invalid IDs.- Reqjson:
object mapping inventory point ID to quantity received
- Parameters:
item_id – ID of the inventory item being received
- Status Codes:
404 Not Found – if the inventory item does not exist
400 Bad Request – if the request body is missing or invalid, or contains an invalid inventory point ID