Add subcription feature 5
This commit is contained in:
@@ -214,8 +214,8 @@ async def register_bakery(
|
||||
subscription_id=str(existing_subscription.id)
|
||||
)
|
||||
else:
|
||||
# Create starter subscription with 14-day trial
|
||||
trial_end_date = datetime.now(timezone.utc) + timedelta(days=14)
|
||||
# Create starter subscription with 0-day trial
|
||||
trial_end_date = datetime.now(timezone.utc)
|
||||
next_billing_date = trial_end_date
|
||||
|
||||
await subscription_repo.create_subscription({
|
||||
@@ -229,10 +229,10 @@ async def register_bakery(
|
||||
await session.commit()
|
||||
|
||||
logger.info(
|
||||
"Default free trial subscription created for new tenant",
|
||||
"Default subscription created for new tenant",
|
||||
tenant_id=str(result.id),
|
||||
plan="starter",
|
||||
trial_days=14
|
||||
trial_days=0
|
||||
)
|
||||
except Exception as subscription_error:
|
||||
logger.error(
|
||||
|
||||
@@ -47,7 +47,7 @@ class TenantSettings(BaseServiceSettings):
|
||||
|
||||
# Subscription Plans
|
||||
DEFAULT_PLAN: str = os.getenv("DEFAULT_PLAN", "basic")
|
||||
TRIAL_PERIOD_DAYS: int = int(os.getenv("TRIAL_PERIOD_DAYS", "14"))
|
||||
TRIAL_PERIOD_DAYS: int = int(os.getenv("TRIAL_PERIOD_DAYS", "0"))
|
||||
|
||||
# Plan Limits
|
||||
BASIC_PLAN_LOCATIONS: int = int(os.getenv("BASIC_PLAN_LOCATIONS", "1"))
|
||||
|
||||
@@ -107,7 +107,7 @@ class CouponRepository:
|
||||
self,
|
||||
code: str,
|
||||
tenant_id: Optional[str],
|
||||
base_trial_days: int = 14
|
||||
base_trial_days: int = 0
|
||||
) -> tuple[bool, Optional[CouponRedemption], Optional[str]]:
|
||||
"""
|
||||
Redeem a coupon for a tenant.
|
||||
@@ -289,9 +289,9 @@ class CouponRepository:
|
||||
}
|
||||
|
||||
if coupon.discount_type == DiscountType.TRIAL_EXTENSION:
|
||||
trial_end = calculate_trial_end_date(14, coupon.discount_value)
|
||||
trial_end = calculate_trial_end_date(0, coupon.discount_value)
|
||||
preview["trial_end_date"] = trial_end.isoformat()
|
||||
preview["total_trial_days"] = 14 + coupon.discount_value
|
||||
preview["total_trial_days"] = 0 + coupon.discount_value
|
||||
|
||||
return preview
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class CouponService:
|
||||
self,
|
||||
coupon_code: str,
|
||||
tenant_id: str,
|
||||
base_trial_days: int = 14
|
||||
base_trial_days: int = 0
|
||||
) -> Tuple[bool, Optional[Dict[str, Any]], Optional[str]]:
|
||||
"""
|
||||
Redeem a coupon for a tenant
|
||||
|
||||
@@ -824,7 +824,7 @@ class SubscriptionOrchestrationService:
|
||||
self,
|
||||
tenant_id: str,
|
||||
coupon_code: str,
|
||||
base_trial_days: int = 14
|
||||
base_trial_days: int = 0
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Orchestrate coupon redemption workflow
|
||||
|
||||
Reference in New Issue
Block a user