import { Type } from 'class-transformer' import { CountryCode } from '../utils' import { BaseModel } from './base.model' import { IntervalInMonths, Intervals, PaymentProviders } from './enums' import { Feature, FeatureValue } from './vo' export class PlanFeature extends BaseModel { plan_id: string feature: FeatureValue provider: PaymentProviders country_code: CountryCode quantity: number interval: Intervals price: number order: number @Type(() => Feature) plan_feature?: Feature get description(): string { return this.plan_feature.getDescriptionByCountryCode(this.country_code) } get intervalInMonths(): number { if (!IntervalInMonths[this.interval]) throw new Error('Actual interval not processable') return IntervalInMonths[this.interval] } }