Add subcription feature
This commit is contained in:
@@ -3,7 +3,7 @@ Coupon system for subscription discounts and promotions.
|
||||
Supports trial extensions, percentage discounts, and fixed amount discounts.
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
@@ -32,7 +32,7 @@ class Coupon:
|
||||
|
||||
def is_valid(self) -> bool:
|
||||
"""Check if coupon is currently valid"""
|
||||
now = datetime.utcnow()
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
# Check if active
|
||||
if not self.active:
|
||||
@@ -60,7 +60,7 @@ class Coupon:
|
||||
if not self.active:
|
||||
return False, "Coupon is inactive"
|
||||
|
||||
now = datetime.utcnow()
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
if now < self.valid_from:
|
||||
return False, "Coupon is not yet valid"
|
||||
@@ -98,7 +98,7 @@ def calculate_trial_end_date(base_trial_days: int, extension_days: int) -> datet
|
||||
"""Calculate trial end date with coupon extension"""
|
||||
from datetime import timedelta
|
||||
total_days = base_trial_days + extension_days
|
||||
return datetime.utcnow() + timedelta(days=total_days)
|
||||
return datetime.now(timezone.utc) + timedelta(days=total_days)
|
||||
|
||||
|
||||
def format_discount_description(coupon: Coupon) -> str:
|
||||
|
||||
Reference in New Issue
Block a user