pos client & quota limit organization blank
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 5.0 on 2025-07-22 04:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentication', '0027_remove_organizationstats_total_buyers_and_more'),
|
||||
('product', '0053_attribute_required'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='quota',
|
||||
name='limit_by_organizations',
|
||||
field=models.ManyToManyField(blank=True, null=True, related_name='quota_limits', to='authentication.organization'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='quotaincentiveassignment',
|
||||
name='heavy_value',
|
||||
field=models.PositiveBigIntegerField(default=0),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='quotaincentiveassignment',
|
||||
name='light_value',
|
||||
field=models.PositiveBigIntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0 on 2025-07-22 04:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentication', '0027_remove_organizationstats_total_buyers_and_more'),
|
||||
('product', '0054_alter_quota_limit_by_organizations_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='quota',
|
||||
name='limit_by_organizations',
|
||||
field=models.ManyToManyField(blank=True, related_name='quota_limits', to='authentication.organization'),
|
||||
),
|
||||
]
|
||||
@@ -341,7 +341,11 @@ class Quota(BaseModel):
|
||||
has_distribution_limit = models.BooleanField(default=False)
|
||||
distribution_mode = ArrayField(base_field=models.IntegerField(), blank=True, null=True)
|
||||
has_organization_limit = models.BooleanField(default=False)
|
||||
limit_by_organizations = models.ManyToManyField(Organization, related_name='quota_limits')
|
||||
limit_by_organizations = models.ManyToManyField(
|
||||
Organization,
|
||||
related_name='quota_limits',
|
||||
blank=True
|
||||
)
|
||||
base_price_factory = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
base_price_cooperative = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
final_price = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
|
||||
@@ -431,8 +435,8 @@ class QuotaIncentiveAssignment(BaseModel):
|
||||
related_name='quota_assignment',
|
||||
null=True
|
||||
)
|
||||
heavy_value = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
light_value = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
heavy_value = models.PositiveBigIntegerField(default=0)
|
||||
light_value = models.PositiveBigIntegerField(default=0)
|
||||
|
||||
def __str__(self):
|
||||
return f"Quota ({self.quota.id}) for {self.incentive_plan.name}"
|
||||
|
||||
@@ -121,7 +121,12 @@ class SaleUnitSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = product_models.SaleUnit
|
||||
fields = '__all__'
|
||||
fields = [
|
||||
"id",
|
||||
"product",
|
||||
"unit",
|
||||
"required",
|
||||
]
|
||||
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
|
||||
@@ -14,6 +14,10 @@ class QuotaSerializer(serializers.ModelSerializer):
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
if isinstance(instance, product_models.Quota):
|
||||
if instance.sale_unit:
|
||||
representation['sale_unit'] = product_serializers.SaleUnitSerializer(
|
||||
instance.sale_unit
|
||||
).data
|
||||
representation['incentive_plan'] = QuotaIncentiveAssignmentSerializer(
|
||||
instance.incentive_assignments.all(),
|
||||
many=True
|
||||
|
||||
Reference in New Issue
Block a user