@@ -143,6 +143,7 @@ export type PromoCodeUtm = Utm;
143143 * Normalizes promo code value before DB lookup.
144144 *
145145 * @param value - raw promo code value
146+ * @returns normalized promo code value
146147 */
147148export function normalizePromoCodeValue ( value : string ) : string {
148149 return value . trim ( ) . toUpperCase ( ) ;
@@ -152,6 +153,7 @@ export function normalizePromoCodeValue(value: string): string {
152153 * Checks if promo value format is allowed.
153154 *
154155 * @param value - normalized promo code value
156+ * @returns whether value has allowed promo code format
155157 */
156158function isAllowedPromoValue ( value : string ) : boolean {
157159 return Boolean ( value ) && PROMO_CODE_REGEXP . test ( value ) ;
@@ -161,6 +163,7 @@ function isAllowedPromoValue(value: string): boolean {
161163 * Returns whether plan is available for purchase (not hidden).
162164 *
163165 * @param plan - tariff plan
166+ * @returns whether plan can be selected for paid purchase or grant_plan promo
164167 */
165168function isPlanAvailableForPurchase ( plan : PlanModel ) : boolean {
166169 return plan . isHidden !== true ;
@@ -171,6 +174,7 @@ function isPlanAvailableForPurchase(plan: PlanModel): boolean {
171174 *
172175 * @param benefit - promo benefit
173176 * @param plan - selected plan
177+ * @returns whether benefit can be applied to the selected plan
174178 */
175179function isPlanApplicable ( benefit : PromoCodeBenefit , plan : PlanModel ) : boolean {
176180 if ( benefit . type === 'grant_plan' ) {
@@ -188,6 +192,7 @@ function isPlanApplicable(benefit: PromoCodeBenefit, plan: PlanModel): boolean {
188192 * Returns whether discount promo can affect plan price.
189193 *
190194 * @param plan - tariff plan
195+ * @returns whether plan is paid and available for purchase
191196 */
192197function isDiscountablePlan ( plan : PlanModel ) : boolean {
193198 return plan . monthlyCharge > 0 && isPlanAvailableForPurchase ( plan ) ;
@@ -198,6 +203,7 @@ function isDiscountablePlan(plan: PlanModel): boolean {
198203 *
199204 * @param benefit - promo benefit
200205 * @param plan - selected plan
206+ * @returns calculated promo price for selected plan
201207 */
202208export function calculatePromoCodePlanPrice ( benefit : PromoCodeBenefit , plan : PlanModel ) : PromoCodePlanPrice {
203209 const originalAmount = plan . monthlyCharge ;
0 commit comments