base of product-quota & list cities by province
This commit is contained in:
@@ -27,10 +27,10 @@ class ProductCategory(BaseModel):
|
||||
|
||||
name = models.CharField(max_length=250, default='empty') # noqa
|
||||
type_choices = (
|
||||
('F', 'Free'), # free product
|
||||
('G', 'Governmental') # government product
|
||||
('free', 'Free'), # free product
|
||||
('gov', 'Governmental') # government product
|
||||
)
|
||||
type = models.CharField(max_length=3, choices=type_choices, default='empty')
|
||||
type = models.CharField(max_length=5, choices=type_choices, default='empty')
|
||||
img = models.CharField(max_length=100, default='empty')
|
||||
parent = models.ForeignKey(
|
||||
'self',
|
||||
@@ -50,10 +50,10 @@ class Product(BaseModel):
|
||||
""" Child of reference product - like: brown rice """
|
||||
name = models.CharField(max_length=250, default='empty') # noqa
|
||||
type_choices = (
|
||||
('F', 'Free'), # free product
|
||||
('G', 'Governmental') # government product
|
||||
('free', 'FREE'), # free product
|
||||
('gov', 'GOVERNMENTAL') # government product
|
||||
)
|
||||
type = models.CharField(max_length=3, choices=type_choices)
|
||||
type = models.CharField(max_length=5, choices=type_choices)
|
||||
img = models.CharField(max_length=100, default='empty')
|
||||
category = models.ForeignKey(
|
||||
ProductCategory,
|
||||
@@ -130,6 +130,14 @@ class AttributeValue(BaseModel):
|
||||
class Broker(BaseModel):
|
||||
""" Broker for product """
|
||||
|
||||
CALCULATION_CHOICES = (
|
||||
('K', 'Per Kilo'),
|
||||
('', ''),
|
||||
)
|
||||
BROKER_TYPES = (
|
||||
('public', 'PUBLIC'),
|
||||
('exclusive', 'EXCLUSIVE')
|
||||
)
|
||||
product = models.ForeignKey(
|
||||
Product,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -142,15 +150,13 @@ class Broker(BaseModel):
|
||||
related_name='product_organization',
|
||||
null=True
|
||||
)
|
||||
calculation_choices = (
|
||||
('K', 'Per Kilo'),
|
||||
('', ''),
|
||||
)
|
||||
|
||||
calculation_strategy = models.CharField(
|
||||
max_length=3,
|
||||
choices=calculation_choices,
|
||||
choices=CALCULATION_CHOICES,
|
||||
default='empty'
|
||||
)
|
||||
broker_type = models.CharField(choices=BROKER_TYPES, max_length=20, null=True)
|
||||
required = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
@@ -185,9 +191,32 @@ class SaleUnit(BaseModel):
|
||||
return super(SaleUnit, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class IncentivePlan(models.Model):
|
||||
class IncentivePlan(BaseModel):
|
||||
PLAN_TYPE_CHOICES = (
|
||||
('ILQ', 'increasing livestock quotas'),
|
||||
('SM', 'statistical/monitoring')
|
||||
)
|
||||
GROUP_CHOICES = (
|
||||
('industrial', 'Industrial'),
|
||||
('rural', 'Rural'),
|
||||
('nomadic', 'Nomadic')
|
||||
)
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
registering_organization = models.ForeignKey(
|
||||
UserRelations,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='incentive_plans',
|
||||
null=True
|
||||
)
|
||||
plan_type = models.CharField(choices=PLAN_TYPE_CHOICES, max_length=5, null=True)
|
||||
group = models.CharField(choices=GROUP_CHOICES, max_length=15, null=True)
|
||||
is_time_unlimited = models.BooleanField(default=False)
|
||||
start_date_limit = models.DateField(null=True, blank=True)
|
||||
end_date_limit = models.DateField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'registering_organization')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -196,7 +225,9 @@ class IncentivePlan(models.Model):
|
||||
return super(IncentivePlan, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Quota(models.Model):
|
||||
class Quota(BaseModel):
|
||||
quota_id = models.CharField(max_length=15, null=True)
|
||||
quota_code = models.CharField(max_length=15, null=True)
|
||||
product = models.ForeignKey(
|
||||
Product,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -206,7 +237,7 @@ class Quota(models.Model):
|
||||
month_choices = ArrayField(base_field=models.IntegerField(), null=True)
|
||||
group = models.CharField(
|
||||
max_length=50,
|
||||
choices=[("roostaei", "روستایی"), ("sanati", "صنعتی"), ("ashayeri", "عشایری")] # noqa
|
||||
choices=[("rural", "روستایی"), ("industrial", "صنعتی"), ("nomadic", "عشایری")] # noqa
|
||||
)
|
||||
has_distribution_limit = models.BooleanField(default=False)
|
||||
distribution_mode = models.CharField(max_length=50, blank=True, null=True)
|
||||
@@ -222,7 +253,7 @@ class Quota(models.Model):
|
||||
return super(Quota, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class QuotaIncentiveAssignment(models.Model):
|
||||
class QuotaIncentiveAssignment(BaseModel):
|
||||
quota = models.ForeignKey(
|
||||
Quota,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -244,7 +275,7 @@ class QuotaIncentiveAssignment(models.Model):
|
||||
return super(QuotaIncentiveAssignment, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class QuotaBrokerValue(models.Model):
|
||||
class QuotaBrokerValue(BaseModel):
|
||||
quota = models.ForeignKey(
|
||||
Quota,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -265,7 +296,7 @@ class QuotaBrokerValue(models.Model):
|
||||
return super(QuotaBrokerValue, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class QuotaLivestockAllocation(models.Model):
|
||||
class QuotaLivestockAllocation(BaseModel):
|
||||
quota = models.ForeignKey(
|
||||
"Quota",
|
||||
on_delete=models.CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user