change list of rancher inventory entries to rancher distributions for one item be as sale in pos device
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
from rest_framework import serializers
|
||||
from apps.product import models as product_models
|
||||
from apps.product.services.services import quota_live_stock_allocation_info, quota_incentive_plans_info, \
|
||||
quota_attribute_value
|
||||
from apps.herd.services.services import get_rancher_statistics, rancher_quota_weight
|
||||
from apps.pos_device.services.services import pos_organizations_sharing_information
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.product.web.api.v1.serializers.quota_serializers import QuotaSerializer
|
||||
from django.db import models
|
||||
from apps.product import models as product_models
|
||||
from rest_framework import serializers
|
||||
from apps.product.exceptions import (
|
||||
QuotaWeightException,
|
||||
QuotaClosedException,
|
||||
QuotaExpiredTimeException,
|
||||
QuotaLimitByOrganizationException
|
||||
)
|
||||
from django.db import models
|
||||
|
||||
|
||||
class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
@@ -77,7 +80,46 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
|
||||
representation = super().to_representation(instance)
|
||||
if instance.quota:
|
||||
representation['quota'] = QuotaSerializer(instance.quota).data
|
||||
representation['quota'] = {
|
||||
'quota_identity': instance.quota.quota_id,
|
||||
'quota_weight': instance.quota.quota_weight,
|
||||
'quota_livestock_allocations': quota_live_stock_allocation_info(
|
||||
instance.quota
|
||||
),
|
||||
'quota_incentive_plans': quota_incentive_plans_info(instance.quota)
|
||||
}
|
||||
|
||||
representation['product'] = {
|
||||
'image': instance.quota.product.img,
|
||||
'name': instance.quota.product.name,
|
||||
'id': instance.quota.product.id,
|
||||
}
|
||||
|
||||
representation['pricing'] = { # noqa
|
||||
'pricing_attributes': quota_attribute_value(instance.quota),
|
||||
'sharing': pos_organizations_sharing_information(self.context['device']),
|
||||
'base_prices': [
|
||||
{
|
||||
"text": "قیمت درب کارخانه", # noqa
|
||||
"name": "base_price_factory",
|
||||
"value": instance.quota.base_price_factory
|
||||
},
|
||||
{
|
||||
"text": "قیمت درب اتحادیه", # noqa
|
||||
"name": "base_price_cooperative",
|
||||
"value": instance.quota.base_price_cooperative
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if 'rancher' in self.context.keys():
|
||||
# rancher herd & live stock statistics
|
||||
representation['rancher_statistics'] = get_rancher_statistics(self.context['rancher'])
|
||||
|
||||
# rancher live stock statistics by quota distributions
|
||||
representation['rancher_quota_weight_statistics'] = rancher_quota_weight(
|
||||
self.context['rancher'], distribution=instance
|
||||
)
|
||||
|
||||
if instance.assigned_organization:
|
||||
representation['assigned_organization'] = {
|
||||
|
||||
Reference in New Issue
Block a user