diff --git a/apps/herd/services/services.py b/apps/herd/services/services.py index 2f167f1..59406a2 100644 --- a/apps/herd/services/services.py +++ b/apps/herd/services/services.py @@ -84,7 +84,7 @@ def rancher_quota_weight(rancher, inventory_entry: InventoryEntry = None, distri 'rancher', 'livestock_type' ).filter(rancher=rancher, livestock_type=item.livestock_type) - if rancher_plans: + if rancher_plans.exists(): # multiple count of rancher livestock on incentive plan & # incentive plan quantity by this livestock type rancher_plan_weight = rancher_plans.first().allowed_quantity * item.quantity_kg diff --git a/apps/product/services/services.py b/apps/product/services/services.py index 949c987..64a6902 100644 --- a/apps/product/services/services.py +++ b/apps/product/services/services.py @@ -47,7 +47,7 @@ def quota_incentive_plans_info(quota: Quota, rancher: Rancher) -> typing.Any: ).filter(rancher=rancher, livestock_type=plan.livestock_type) incentive_plans_data = { - 'id': rancher_plan.first().allowed_quantity, + 'id': rancher_plan.first().allowed_quantity if rancher_plan.exists() else None, 'name': plan.incentive_plan.name, 'livestock_type': plan.livestock_type.name if plan.livestock_type else "", 'livestock_type_en': plan.livestock_type.en_name if plan.livestock_type else "",