fix : free plan

This commit is contained in:
morteza-mortezai
2025-11-13 11:00:08 +03:30
parent bec0ba472e
commit 88349e3b7d
2 changed files with 3 additions and 15 deletions
@@ -323,25 +323,12 @@ export class SubscriptionsService {
const plan = await queryRunner.manager.findOne(SubscriptionPlan, {
where: { id: dto.planId, service: { id: dto.serviceId } },
relations: { service: true, directDiscount: true, }
relations: { service: true, directDiscount: true },
});
if (!plan) throw new BadRequestException(SubscriptionMessage.NOT_FOUND);
if (plan.isFree) {
isFree = true;
const existingFreePlanSubscription = await queryRunner.manager.findOne(UserSubscription, {
where: {
user: { id: userId },
plan: { isFree: true },
},
relations: {
plan: true,
},
});
if (existingFreePlanSubscription) {
throw new BadRequestException(SubscriptionMessage.FREE_PLAN_LIMIT_EXCEEDED);
}
throw new BadRequestException(SubscriptionMessage.FREE_PLAN_NOT_ALLOWED);
}
const startDate =