1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-07 19:07:45 +01:00

[PM-16664] Fix annual pricing for billable providers (#12662)

This commit is contained in:
Jonas Hendrickx 2025-01-03 10:30:25 +01:00 committed by GitHub
parent aeba2b3c73
commit b0f5971287
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 6 deletions

View File

@ -38,12 +38,14 @@
}}
</td>
<td bitCell class="tw-text-right tw-py-3">
{{ ((100 - subscription.discountPercentage) / 100) * i.cost | currency: "$" }} /{{
"month" | i18n
{{
((100 - subscription.discountPercentage) / 100) * getMonthlyCost(i)
| currency: "$"
}}
/ {{ "month" | i18n }}
<div *ngIf="subscription.discountPercentage">
<bit-hint class="tw-text-sm tw-line-through">
{{ i.cost | currency: "$" }} /{{ "month" | i18n }}
{{ getMonthlyCost(i) | currency: "$" }} / {{ "month" | i18n }}
</bit-hint>
</div>
</td>
@ -52,9 +54,8 @@
<tr bitRow>
<td bitCell class="tw-pl-0 tw-py-3"></td>
<td bitCell class="tw-text-right">
<span class="tw-font-bold">Total:</span> {{ totalCost | currency: "$" }} /{{
"month" | i18n
}}
<span class="tw-font-bold">Total:</span>
{{ getTotalMonthlyCost() | currency: "$" }} / {{ "month" | i18n }}
</td>
</tr>
</ng-container>

View File

@ -113,4 +113,20 @@ export class ProviderSubscriptionComponent implements OnInit, OnDestroy {
}
});
}
protected getMonthlyCost(plan: ProviderPlanResponse): number {
return plan.cadence === "Monthly" ? plan.cost : plan.cost / 12;
}
protected getDiscountedMonthlyCost(plan: ProviderPlanResponse): number {
return ((100 - this.subscription.discountPercentage) / 100) * this.getMonthlyCost(plan);
}
protected getTotalMonthlyCost(): number {
let totalCost: number = 0;
for (const plan of this.subscription.plans) {
totalCost += this.getDiscountedMonthlyCost(plan);
}
return totalCost;
}
}