add some new info to pos distributions list - has sale license-free sale
This commit is contained in:
18
apps/core/migrations/0008_systemconfig_quota.py
Normal file
18
apps/core/migrations/0008_systemconfig_quota.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-09-15 10:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0007_systemconfig'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='systemconfig',
|
||||
name='quota',
|
||||
field=models.CharField(max_length=50, null=True),
|
||||
),
|
||||
]
|
||||
@@ -56,10 +56,13 @@ class MobileTest(BaseModel):
|
||||
class SystemConfig(BaseModel):
|
||||
key = models.CharField(max_length=100, null=True)
|
||||
value = models.CharField(max_length=100, null=True)
|
||||
quota = models.CharField(max_length=50, null=True)
|
||||
|
||||
@classmethod
|
||||
def get(cls, key, default=None):
|
||||
def get(cls, key, quota_identity=None, default=None):
|
||||
try:
|
||||
if quota_identity:
|
||||
return cls.objects.get(key=key, quota=quota_identity).value
|
||||
return cls.objects.get(key=key).value
|
||||
except cls.DoesNotExist:
|
||||
return default
|
||||
|
||||
@@ -595,6 +595,8 @@ class QuotaDistribution(BaseModel):
|
||||
warehouse_balance = models.PositiveBigIntegerField(default=0)
|
||||
been_sold = models.PositiveBigIntegerField(default=0)
|
||||
history = HistoricalRecords()
|
||||
pre_sale = models.BooleanField(default=False)
|
||||
free_sale = models.BooleanField(default=False)
|
||||
|
||||
def generate_distribution_id(self):
|
||||
""" generate special id for quota distribution """
|
||||
|
||||
@@ -4,6 +4,7 @@ from apps.herd.services.services import get_rancher_statistics, rancher_quota_we
|
||||
from apps.pos_device.services.services import pos_organizations_sharing_information
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.product import models as product_models
|
||||
from apps.core.models import SystemConfig
|
||||
from rest_framework import serializers
|
||||
from apps.product.exceptions import (
|
||||
QuotaWeightException,
|
||||
@@ -87,13 +88,20 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
instance.quota
|
||||
),
|
||||
'quota_incentive_plans': quota_incentive_plans_info(instance.quota),
|
||||
'quota_sale_license': instance.quota.sale_license
|
||||
'quota_sale_license': instance.quota.sale_license,
|
||||
'has_sale_license': instance.quota.is_in_valid_time()
|
||||
}
|
||||
|
||||
sale_limitation = SystemConfig.get(
|
||||
"IGNORE_ALL_RANCHER_PURCHASE_LIMITS",
|
||||
quota_identity=instance.quota.quota_id
|
||||
)
|
||||
representation['product'] = {
|
||||
'image': instance.quota.product.img,
|
||||
'name': instance.quota.product.name,
|
||||
'id': instance.quota.product.id,
|
||||
'free_sale_for_all': sale_limitation if sale_limitation else False,
|
||||
'free_sale_for_this_rancher': self.context['rancher'].ignore_purchase_limit
|
||||
}
|
||||
|
||||
representation['pricing'] = { # noqa
|
||||
|
||||
@@ -10,6 +10,7 @@ from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer
|
||||
from apps.herd.pos.api.v1.serializers import RancherSerializer
|
||||
from apps.product.models import QuotaDistribution, Product
|
||||
from apps.warehouse import models as warehouse_models
|
||||
from apps.core.models import SystemConfig
|
||||
from apps.warehouse.exceptions import (
|
||||
TotalInventorySaleException
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user