add incentive plan id to rancher distribution info
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import datetime
|
||||
from simple_history.models import HistoricalRecords
|
||||
from django.db import models
|
||||
from apps.core.models import BaseModel
|
||||
from apps.authorization.models import UserRelations
|
||||
from apps.authentication.models import OrganizationType, Organization
|
||||
# from apps.warehouse.models import InventoryQuotaSaleItem
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from simple_history.models import HistoricalRecords
|
||||
from apps.authorization.models import UserRelations
|
||||
from apps.livestock.models import LiveStockType
|
||||
from apps.core.models import BaseModel
|
||||
from apps.herd.models import Rancher
|
||||
from datetime import datetime
|
||||
from django.db import models
|
||||
import jdatetime
|
||||
# import datetime
|
||||
|
||||
|
||||
class LivestockGroup(models.TextChoices):
|
||||
@@ -469,6 +470,31 @@ class QuotaStats(BaseModel):
|
||||
return super(QuotaStats, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
# class RancherQuotaUsage(BaseModel):
|
||||
# # transaction = models.ForeignKey("InventoryQuotaSaleTransaction", on_delete=models.CASCADE)
|
||||
# rancher = models.ForeignKey(
|
||||
# Rancher,
|
||||
# on_delete=models.CASCADE,
|
||||
# related_name='usages',
|
||||
# null=True
|
||||
# )
|
||||
# livestock_type = models.ForeignKey(
|
||||
# "LiveStockType",
|
||||
# on_delete=models.CASCADE,
|
||||
# related_name='usages',
|
||||
# null=True
|
||||
# )
|
||||
# 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)
|
||||
# incentive_plan = models.ForeignKey(
|
||||
# "IncentivePlan",
|
||||
# null=True,
|
||||
# blank=True,
|
||||
# on_delete=models.SET_NULL
|
||||
# )
|
||||
|
||||
|
||||
class QuotaIncentiveAssignment(BaseModel):
|
||||
""" assign incentive plan to quota """
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ def quota_incentive_plans_info(quota: Quota, rancher: Rancher) -> typing.Any:
|
||||
).filter(rancher=rancher, livestock_type=plan.livestock_type)
|
||||
|
||||
incentive_plans_data = {
|
||||
'id': plan.incentive_plan.id,
|
||||
'name': plan.incentive_plan.name,
|
||||
'livestock_type': plan.livestock_type.name if plan.livestock_type else "",
|
||||
'livestock_type_en': plan.livestock_type.en_name if plan.livestock_type else "",
|
||||
|
||||
Reference in New Issue
Block a user