Add subcription feature 5

This commit is contained in:
Urtzi Alfaro
2026-01-16 09:55:54 +01:00
parent 483a9f64cd
commit 6b43116efd
51 changed files with 1428 additions and 312 deletions

View File

@@ -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(

View File

@@ -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"))

View File

@@ -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

View File

@@ -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

View File

@@ -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