fix - comment quota stat on sale in warehouse signals
This commit is contained in:
@@ -8,17 +8,20 @@ class QuotaStatsService:
|
|||||||
|
|
||||||
# origin org
|
# origin org
|
||||||
assigner = distribution.assigner_organization
|
assigner = distribution.assigner_organization
|
||||||
|
print(assigner)
|
||||||
# destination org
|
# destination org
|
||||||
assigned = distribution.assigned_organization
|
assigned = distribution.assigned_organization
|
||||||
print(assigned)
|
|
||||||
# ================ origin ================
|
# ================ origin ================
|
||||||
assigner_stat, _ = OrganizationQuotaStats.objects.get_or_create(
|
assigner_stat, created = OrganizationQuotaStats.objects.get_or_create(
|
||||||
organization=assigner,
|
organization=assigner,
|
||||||
quota=quota,
|
quota=quota,
|
||||||
stat_type='distribution'
|
|
||||||
)
|
)
|
||||||
|
if created:
|
||||||
|
assigner_stat.stat_type = 'distribution'
|
||||||
|
assigner_stat.save()
|
||||||
|
print(assigner_stat.remaining_amount)
|
||||||
assigner_stat.remaining_amount -= distribution.weight
|
assigner_stat.remaining_amount -= distribution.weight
|
||||||
|
print(assigner_stat.remaining_amount)
|
||||||
assigner_stat.total_distributed += distribution.weight
|
assigner_stat.total_distributed += distribution.weight
|
||||||
assigner_stat.save()
|
assigner_stat.save()
|
||||||
|
|
||||||
@@ -60,8 +63,9 @@ class QuotaStatsService:
|
|||||||
assigner_stat.total_distributed += diff
|
assigner_stat.total_distributed += diff
|
||||||
print(assigner_stat.total_distributed, diff)
|
print(assigner_stat.total_distributed, diff)
|
||||||
assigner_stat.save()
|
assigner_stat.save()
|
||||||
|
print(assigned_stat.total_amount)
|
||||||
assigned_stat.total_amount += diff
|
assigned_stat.total_amount += diff
|
||||||
|
print(assigned_stat.total_amount)
|
||||||
assigned_stat.remaining_amount += diff
|
assigned_stat.remaining_amount += diff
|
||||||
assigned_stat.save()
|
assigned_stat.save()
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from django.db.models import Sum
|
|||||||
from django.db.models.signals import post_save, post_delete
|
from django.db.models.signals import post_save, post_delete
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from apps.product.models import QuotaDistribution, OrganizationQuotaStats
|
from apps.product.models import QuotaDistribution
|
||||||
from .models import InventoryEntry, InventoryQuotaSaleItem
|
from .models import InventoryEntry, InventoryQuotaSaleItem
|
||||||
|
|
||||||
|
|
||||||
@@ -69,16 +69,16 @@ def update_distribution_warehouse_sold_and_balance(sender, instance: InventoryQu
|
|||||||
else:
|
else:
|
||||||
print("quota distribution is null - warehouse app signals")
|
print("quota distribution is null - warehouse app signals")
|
||||||
|
|
||||||
|
# @receiver(post_save, sender=InventoryQuotaSaleItem)
|
||||||
@receiver(post_save, sender=InventoryQuotaSaleItem)
|
# def update_quota_stats_on_sale(sender, instance: InventoryQuotaSaleItem, created, **kwargs):
|
||||||
def update_quota_stats_on_sale(sender, instance: InventoryQuotaSaleItem, created, **kwargs):
|
# if instance.transaction.transaction_status == 'success':
|
||||||
if instance.transaction.transaction_status == 'success':
|
# return
|
||||||
return
|
#
|
||||||
|
# stats = OrganizationQuotaStats.objects.filter(
|
||||||
stats = OrganizationQuotaStats.objects.filter(
|
# organization=instance.quota_distribution.assigned_organization,
|
||||||
organization=instance.quota_distribution.assigned_organization,
|
# quota=instance.quota_distribution.quota
|
||||||
quota=instance.quota_distribution.quota
|
# ).first()
|
||||||
).first()
|
#
|
||||||
|
# if stats:
|
||||||
if stats:
|
# stats.update_amounts()
|
||||||
stats.update_amounts()
|
# برای محصولات ازاد چک شود و کنترل
|
||||||
|
|||||||
Reference in New Issue
Block a user