32 lines
830 B
Python
32 lines
830 B
Python
from apps.product.models import Quota, QuotaLivestockAllocation
|
|
from apps.warehouse.models import InventoryEntry
|
|
import typing
|
|
|
|
|
|
def get_products_in_warehouse(organization_id):
|
|
""" get list of products from organization warehouse """
|
|
|
|
entries = InventoryEntry.objects.select_related(
|
|
'distribution__quota__product'
|
|
)
|
|
|
|
product_objects = [
|
|
entry.distribution.quota.product for entry in entries
|
|
]
|
|
|
|
return list(set(product_objects))
|
|
|
|
|
|
def quota_live_stock_allocation_info(quota: Quota) -> typing.Any:
|
|
""" information of quota live stock allocations """
|
|
|
|
allocations = quota.livestock_allocations.filter(quota=quota)
|
|
|
|
allocations_list = [{
|
|
"name": alloc.livestock_type.name,
|
|
"quantity": alloc.quantity_kg
|
|
} for alloc in allocations]
|
|
|
|
return allocations_list
|
|
|