rancher incentive quota usage - pos product search
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 5.0 on 2025-09-27 05:20
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0078_quotausage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='quotausage',
|
||||
name='distribution',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='usages', to='product.quotadistribution'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='quotausage',
|
||||
name='usage_type',
|
||||
field=models.CharField(choices=[('base', 'BASE'), ('incentive', 'INCENTIVE')], max_length=150, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='quotausage',
|
||||
name='base_quota_used',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='quotausage',
|
||||
name='incentive_quota_used',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -494,8 +494,8 @@ class QuotaUsage(BaseModel):
|
||||
on_delete=models.SET_NULL
|
||||
)
|
||||
count = models.PositiveIntegerField()
|
||||
base_quota_used = models.DecimalField(max_digits=12, decimal_places=2, default=0)
|
||||
incentive_quota_used = models.DecimalField(max_digits=12, decimal_places=2, default=0)
|
||||
base_quota_used = models.IntegerField(default=0)
|
||||
incentive_quota_used = models.IntegerField(default=0)
|
||||
usage_type_choices = (
|
||||
('base', 'BASE'),
|
||||
('incentive', 'INCENTIVE'),
|
||||
|
||||
@@ -33,7 +33,7 @@ class ProductViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDeviceMixin):
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
|
||||
queryset = self.filter_query(self.get_queryset().order_by('-create_date')) # noqa
|
||||
queryset = self.filter_queryset(self.get_queryset().order_by('-create_date')) # noqa
|
||||
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None:
|
||||
|
||||
@@ -29,7 +29,7 @@ def delete(queryset, pk):
|
||||
obj.delete()
|
||||
|
||||
|
||||
class ProductCategoryViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class ProductCategoryViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
queryset = product_models.ProductCategory.objects.all()
|
||||
serializer_class = product_serializers.ProductCategorySerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
@@ -67,7 +67,7 @@ class ProductCategoryViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSear
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class ProductViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class ProductViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
queryset = product_models.Product.objects.all()
|
||||
serializer_class = product_serializers.ProductSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
@@ -146,7 +146,7 @@ class ProductViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin)
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class ProductStatsViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class ProductStatsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" product statistics by its quotas """
|
||||
|
||||
queryset = product_models.ProductStats.objects.all()
|
||||
@@ -177,7 +177,7 @@ class ProductStatsViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchM
|
||||
raise e
|
||||
|
||||
|
||||
class AttributeViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class AttributeViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" attributes of reference product """ #
|
||||
|
||||
queryset = product_models.Attribute.objects.select_related('product').all()
|
||||
@@ -235,7 +235,7 @@ class AttributeViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixi
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class AttributeValueViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class AttributeValueViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" apis for attribute values of child products """ # noqa
|
||||
|
||||
queryset = product_models.AttributeValue.objects.all()
|
||||
@@ -273,7 +273,7 @@ class AttributeValueViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearc
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class BrokerViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class BrokerViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" apis of product brokers """ # noqa
|
||||
|
||||
queryset = product_models.Broker.objects.all()
|
||||
@@ -313,7 +313,7 @@ class BrokerViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class SaleUnitViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class SaleUnitViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" apis of unit of sale for products """ # noqa
|
||||
|
||||
queryset = product_models.SaleUnit.objects.all()
|
||||
@@ -353,7 +353,7 @@ class SaleUnitViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class IncentivePlanViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin): # noqa
|
||||
class IncentivePlanViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin): # noqa
|
||||
""" apis for incentive plan """
|
||||
|
||||
queryset = product_models.IncentivePlan.objects.all()
|
||||
@@ -443,7 +443,7 @@ class IncentivePlanViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearch
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class IncentivePlanRancherViewSet(viewsets.ModelViewSet, SoftDeleteMixin, DynamicSearchMixin):
|
||||
class IncentivePlanRancherViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
queryset = product_models.IncentivePlanRancher.objects.all()
|
||||
serializer_class = product_serializers.IncentivePlanRancherSerializer
|
||||
search_fields = []
|
||||
|
||||
@@ -32,7 +32,7 @@ def delete(queryset, pk):
|
||||
obj.delete()
|
||||
|
||||
|
||||
class QuotaViewSet(viewsets.ModelViewSet, DynamicSearchMixin, SoftDeleteMixin): # noqa
|
||||
class QuotaViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin): # noqa
|
||||
""" apis for product quota """
|
||||
|
||||
queryset = product_models.Quota.objects.all()
|
||||
@@ -454,7 +454,7 @@ class QuotaViewSet(viewsets.ModelViewSet, DynamicSearchMixin, SoftDeleteMixin):
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class QuotaIncentiveAssignmentViewSet(viewsets.ModelViewSet, SoftDeleteMixin): # noqa
|
||||
class QuotaIncentiveAssignmentViewSet(SoftDeleteMixin, viewsets.ModelViewSet): # noqa
|
||||
""" apis for incentive assignment """
|
||||
|
||||
queryset = product_models.QuotaIncentiveAssignment.objects.all()
|
||||
@@ -492,7 +492,7 @@ class QuotaIncentiveAssignmentViewSet(viewsets.ModelViewSet, SoftDeleteMixin):
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class QuotaBrokerValueViewSet(viewsets.ModelViewSet, SoftDeleteMixin): # noqa
|
||||
class QuotaBrokerValueViewSet(SoftDeleteMixin, viewsets.ModelViewSet): # noqa
|
||||
""" apis for quota broker value """
|
||||
|
||||
queryset = product_models.QuotaBrokerValue.objects.all()
|
||||
@@ -530,7 +530,7 @@ class QuotaBrokerValueViewSet(viewsets.ModelViewSet, SoftDeleteMixin): # noqa
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class QuotaLiveStockAllocationViewSet(viewsets.ModelViewSet, SoftDeleteMixin):
|
||||
class QuotaLiveStockAllocationViewSet(SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
""" apis for quota livestock allocation """
|
||||
|
||||
queryset = product_models.QuotaLivestockAllocation.objects.all()
|
||||
@@ -568,7 +568,7 @@ class QuotaLiveStockAllocationViewSet(viewsets.ModelViewSet, SoftDeleteMixin):
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class QuotaLiveStockAgeLimitation(viewsets.ModelViewSet, SoftDeleteMixin):
|
||||
class QuotaLiveStockAgeLimitation(SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
queryset = product_models.QuotaLiveStockAgeLimitation.objects.all() # noqa
|
||||
serializer_class = quota_serializers.QuotaLiveStockAgeLimitationSerializer
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def delete(queryset, pk):
|
||||
obj.delete()
|
||||
|
||||
|
||||
class QuotaDistributionViewSet(viewsets.ModelViewSet, DynamicSearchMixin, SoftDeleteMixin):
|
||||
class QuotaDistributionViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" quota distribution apis """
|
||||
|
||||
queryset = product_models.QuotaDistribution.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user