rancher incentive quota usage - pos product search
This commit is contained in:
@@ -14,8 +14,9 @@ from apps.warehouse.services.services import (
|
||||
create_pre_sale
|
||||
)
|
||||
from apps.herd.pos.api.v1.serializers import RancherSerializer
|
||||
from apps.product.models import QuotaDistribution, Product
|
||||
from apps.product.models import QuotaDistribution, Product, QuotaUsage
|
||||
from apps.warehouse import models as warehouse_models
|
||||
from apps.livestock.models import LiveStockType
|
||||
from apps.core.models import SystemConfig
|
||||
from django.db.transaction import atomic
|
||||
from apps.warehouse.exceptions import (
|
||||
@@ -165,6 +166,44 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
|
||||
# create pre sale for distribution
|
||||
create_pre_sale(transaction=transaction, sale_item=item)
|
||||
|
||||
# # purchase quota usage of rancher
|
||||
# if 'livestock_statistic' in item_data.keys():
|
||||
# for item in item_data['livestock_statistic']:
|
||||
# # get livestock by en name
|
||||
# livestock_type = LiveStockType.objects.get(en_name=item['name'])
|
||||
# # get usage & calculate
|
||||
# usage = QuotaUsage.objects.filter(
|
||||
# incentive_plan=item['id'],
|
||||
# rancher=rancher,
|
||||
# livestock_type=livestock_type,
|
||||
# distribution=distribution
|
||||
# )
|
||||
# if not usage.exists():
|
||||
# usage = QuotaUsage(
|
||||
# rancher=rancher,
|
||||
# livestock_type=livestock_type,
|
||||
# distribution=distribution,
|
||||
# count=item['count'],
|
||||
# )
|
||||
# if item['id'] != 0: # if id != 0 it means using his incentive plan
|
||||
# usage.incentive_plan = item['id'],
|
||||
# usage.incentive_quota_used = item['total_weight'],
|
||||
# usage.usage_type = 'incentive'
|
||||
# usage.save()
|
||||
# else:
|
||||
# usage.incentive_plan = None
|
||||
# usage.base_quota_used = item['total_weight'],
|
||||
# usage.usage_type = 'base'
|
||||
# usage.save()
|
||||
# else:
|
||||
# usage = usage.first()
|
||||
# if usage.usage_type == 'incentive':
|
||||
# usage.incentive_quota_used += item['total_weight']
|
||||
# usage.save()
|
||||
# elif usage.usage_type == 'base':
|
||||
# usage.base_quota_used = item['total_weight']
|
||||
# usage.save()
|
||||
|
||||
transaction.transaction_price = total_price
|
||||
transaction.save()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from rest_framework import status
|
||||
import typing
|
||||
|
||||
|
||||
class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin, SoftDeleteMixin):
|
||||
class InventoryEntryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||
# filter_backends = [filters.SearchFilter]
|
||||
@@ -120,7 +120,7 @@ class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin, SoftDelet
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
|
||||
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet, SoftDeleteMixin):
|
||||
class InventoryQuotaSaleTransactionViewSet(SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
|
||||
Reference in New Issue
Block a user