pharmaship.inventory.utils¶
Utility functions for model data handling.
-
pharmaship.inventory.utils.
filepath
(instance, filename)¶ Return a “slugified” filename using the instance name.
The extension of the original filename is preserved.
- Parameters
instance (models.Equipment) – Equipment instance
filename (str) – Name of the file
- Returns
Slugified filename from instance name and file extension.
- Return type
-
pharmaship.inventory.utils.
get_location_list
(show_reserved=True)¶ Return a list of pseudo-serialized Locations.
- Parameters
show_reserved (bool) – if
True
, show locations with id > 100.- Returns
List of serialized
pharmaship.inventory.models.Location
.- Return type
-
pharmaship.inventory.utils.
get_quantity
(transaction_list, item_id)¶ Get the item quantity from a transaction list.
Transactions of type 1 (“in”) or 8 (“stock count”) are setters. Other types are decreasing the value.
- Parameters
transaction_list (django.db.models.query.QuerySet) – List of transactions
pharmaship.inventory.models.QtyTransaction
.item_id (int) – ID of item
- Returns
Quantity of item
- Return type
-
pharmaship.inventory.utils.
location_iterator
(parent, items, parent_id)¶ Iterate over the Locations tree.
- Parameters
parent (list) – Sequence of parent serialized locations
items (iterator) – Children to serialize (iterator of
pharmaship.inventory.models.Location
)parent_id (int) – Parent Location ID
- Returns
List of serialized
pharmaship.inventory.models.Location
.- Return type
-
pharmaship.inventory.utils.
req_qty_element
(element, req_qty_list)¶ Return the required quantity of an element.
Use the allowance list and required quantities list.
- Parameters
element (pharmaship.inventory.models.Equipment or pharmaship.inventory.models.Molecule) – Reference element
req_qty_list (django.db.models.query.QuerySet) – List of quantity transactions
- Returns
Computed quantity of the element and the required quantity details (name and quantity of each related allowance)
- Return type