fix: Convert Jalali date to datetime for order creation timestamp
This commit is contained in:
@@ -17,7 +17,7 @@ API_DOMAIN = os.getenv("API_DOMAIN")
|
|||||||
|
|
||||||
# API Keys and Tokens
|
# API Keys and Tokens
|
||||||
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
||||||
TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
TELEGRAM_BOT_TOKEN = '7068288679:AAGecMnyt9A6R78OQu8nQeISMK1LepX718g'
|
||||||
VAPID_PRIVATE_KEY = os.getenv("VAPID_PRIVATE_KEY")
|
VAPID_PRIVATE_KEY = os.getenv("VAPID_PRIVATE_KEY")
|
||||||
|
|
||||||
# Email Configuration
|
# Email Configuration
|
||||||
|
|||||||
@@ -142,6 +142,20 @@ def create_shop_orders_on_payment(sender, instance: OrderModel, created, **kwarg
|
|||||||
address_province = instance.address.province
|
address_province = instance.address.province
|
||||||
address_recipient_name = instance.address.name
|
address_recipient_name = instance.address.name
|
||||||
|
|
||||||
|
# Convert Jalali date to datetime if needed
|
||||||
|
order_created_datetime = None
|
||||||
|
if instance.created_at:
|
||||||
|
try:
|
||||||
|
# If it's already a datetime, use it
|
||||||
|
if hasattr(instance.created_at, 'hour'):
|
||||||
|
order_created_datetime = instance.created_at
|
||||||
|
else:
|
||||||
|
# If it's a date, convert to datetime at midnight
|
||||||
|
from datetime import datetime, time
|
||||||
|
order_created_datetime = datetime.combine(instance.created_at, time.min)
|
||||||
|
except Exception:
|
||||||
|
order_created_datetime = None
|
||||||
|
|
||||||
shop_order = ShopOrderModel.objects.create(
|
shop_order = ShopOrderModel.objects.create(
|
||||||
order=instance,
|
order=instance,
|
||||||
shop=shop,
|
shop=shop,
|
||||||
@@ -165,7 +179,7 @@ def create_shop_orders_on_payment(sender, instance: OrderModel, created, **kwarg
|
|||||||
commission_amount=commission_amount,
|
commission_amount=commission_amount,
|
||||||
tax_amount=allocated_tax,
|
tax_amount=allocated_tax,
|
||||||
payable_amount=payable,
|
payable_amount=payable,
|
||||||
order_created_at=instance.created_at,
|
order_created_at=order_created_datetime,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create ShopOrderItem rows linking to original OrderItemModel
|
# Create ShopOrderItem rows linking to original OrderItemModel
|
||||||
|
|||||||
Reference in New Issue
Block a user