feat: add daily report functionality and settlement status to shop orders

This commit is contained in:
Parsa Nazer
2026-02-09 11:08:39 +03:30
parent 0771a286b2
commit bd7c7252c7
6 changed files with 78 additions and 11 deletions
+9 -2
View File
@@ -1,4 +1,4 @@
from .models import ShopOrderModel, ShopOrderItem
from .models import ShopOrderModel, ShopOrderItem, ShopDailyReport
from django.db import transaction
from django.db.models.signals import post_save
from django.db.models.signals import pre_save
@@ -248,4 +248,11 @@ def send_invoice_to_shop_telegram(sender, instance: ShopOrderModel, created, **k
shop_order_id=instance.pk,
chat_id=instance.shop.telegram_chat_id,
bot_token=bot_token
)
)
@receiver(post_save, sender=ShopDailyReport)
def update_shop_orders_settlement_status(sender, instance: ShopDailyReport, **kwargs):
"""When a ShopDailyReport's is_settled status changes, update all related ShopOrderModel instances."""
# Update all shop orders linked to this daily report
instance.shop_orders.update(is_settled=instance.is_settled)