add pos sale type to quota

This commit is contained in:
2025-09-24 12:24:16 +03:30
parent b771e55bd9
commit 69daf8d5ef
3 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-09-24 08:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('product', '0076_incentiveplanrancher'),
]
operations = [
migrations.AddField(
model_name='quota',
name='pos_sale_type',
field=models.CharField(choices=[('weight', 'WEIGHT'), ('count', 'COUNT'), ('all', 'ALL')], default='all', max_length=25),
),
]

View File

@@ -394,6 +394,12 @@ class Quota(BaseModel):
limit_by_herd_size = models.BooleanField(default=True)
is_closed = models.BooleanField(default=False)
closed_at = models.DateTimeField(null=True, blank=True)
pos_sale_type_choices = (
('weight', 'WEIGHT'),
('count', 'COUNT'),
('all', 'ALL'),
)
pos_sale_type = models.CharField(choices=pos_sale_type_choices, max_length=25, default='all')
def __str__(self):
return f"Quota ({self.id}) for {self.product.name}"

View File

@@ -89,12 +89,13 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
representation['quota'] = {
'quota_identity': instance.quota.quota_id,
'quota_weight': instance.quota.quota_weight,
'pos_sale_type': instance.quota.pos_sale_type,
'quota_livestock_allocations': quota_live_stock_allocation_info(
instance.quota
),
'quota_incentive_plans': quota_incentive_plans_info(instance.quota, rancher),
'quota_sale_license': instance.quota.sale_license,
'has_sale_license': instance.quota.is_in_valid_time()
'has_sale_license': instance.quota.is_in_valid_time(),
}
sale_limitation = SystemConfig.get(