update: fix

This commit is contained in:
mahyargdz
2025-04-20 12:30:13 +03:30
parent 1c0ef1e1e1
commit b4dd3d2e01
6 changed files with 293 additions and 97 deletions
@@ -37,7 +37,11 @@ export class SubscriptionsService {
const danakService = await this.danakServices.findServiceById(createDto.serviceId);
if (!danakService) throw new BadRequestException(ServiceMessage.SERVICE_NOT_FOUND_BY_ID);
const subscriptions = createDto.subs.map((sub) => ({ ...sub, service: { id: createDto.serviceId } }));
const subscriptions = createDto.subs.map((sub) => ({
...sub,
service: { id: createDto.serviceId },
originalPrice: new Decimal(sub.price),
}));
const subscriptionNames = createDto.subs.map((sub) => sub.name);
const existingSubscriptions = await this.subscriptionsPlanRepository.find({
@@ -124,7 +128,10 @@ export class SubscriptionsService {
}
if (updateDto.duration) subscription.duration = updateDto.duration;
if (updateDto.price) subscription.price = new Decimal(updateDto.price);
if (updateDto.price) {
subscription.price = new Decimal(updateDto.price);
subscription.originalPrice = new Decimal(updateDto.price);
}
await this.subscriptionsPlanRepository.save(subscription);