update: add is free to the subs plan
This commit is contained in:
@@ -48,7 +48,9 @@ export class SubscriptionsService {
|
||||
const subscriptions = createDto.subs.map((sub) => ({
|
||||
...sub,
|
||||
service: { id: createDto.serviceId },
|
||||
originalPrice: new Decimal(sub.price),
|
||||
price: sub.price < 100_000 ? new Decimal(0) : new Decimal(sub.price),
|
||||
originalPrice: sub.price < 100_000 ? new Decimal(0) : new Decimal(sub.price),
|
||||
isFree: sub.price < 100_000,
|
||||
}));
|
||||
|
||||
const subscriptionNames = createDto.subs.map((sub) => sub.name);
|
||||
@@ -134,11 +136,14 @@ export class SubscriptionsService {
|
||||
|
||||
if (updateDto.duration) subscription.duration = updateDto.duration;
|
||||
if (updateDto.price) {
|
||||
subscription.price = new Decimal(updateDto.price);
|
||||
subscription.originalPrice = new Decimal(updateDto.price);
|
||||
subscription.price = updateDto.price < 100_000 ? new Decimal(0) : new Decimal(updateDto.price);
|
||||
subscription.originalPrice = updateDto.price < 100_000 ? new Decimal(0) : new Decimal(updateDto.price);
|
||||
}
|
||||
|
||||
await this.subscriptionsPlanRepository.save(subscription);
|
||||
await this.subscriptionsPlanRepository.save({
|
||||
...subscription,
|
||||
isFree: updateDto.price ? updateDto.price < 100_000 : false,
|
||||
});
|
||||
|
||||
return {
|
||||
message: SubscriptionMessage.UPDATED,
|
||||
|
||||
Reference in New Issue
Block a user