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
Returns

Slugified filename from instance name and file extension.

Return type

str

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

list(dict)

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
Returns

Quantity of item

Return type

int

pharmaship.inventory.utils.location_iterator(parent, items, parent_id)

Iterate over the Locations tree.

Parameters
Returns

List of serialized pharmaship.inventory.models.Location.

Return type

list(dict)

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
Returns

Computed quantity of the element and the required quantity details (name and quantity of each related allowance)

Return type

tuple(int, list(dict))