(null);
-const formatPrice = (cents: number): string => {
- return '$' + (cents / 100).toFixed(0);
-};
-
const getPrice = (plan: Plan): string => {
- return formatPrice(isYearly.value ? plan.yearly_price / 12 : plan.monthly_price);
-};
-
-const getTotalPrice = (plan: Plan): string => {
- return formatPrice(isYearly.value ? plan.yearly_price : plan.monthly_price);
-};
-
-const getSavings = (plan: Plan): number => {
- const monthlyTotal = plan.monthly_price * 12;
- const yearlyTotal = plan.yearly_price;
- return Math.round(((monthlyTotal - yearlyTotal) / monthlyTotal) * 100);
+ const key = `billing.subscribe.prices.${plan.slug}.${isYearly.value ? 'yearly' : 'monthly'}`;
+ return trans(key);
};
const formatRetention = (days: number): string => {
@@ -138,7 +123,7 @@ const isPopular = (plan: Plan): boolean => {
{{ plan.name }}
{{ getPrice(plan) }}
- /{{ $t('billing.subscribe.per_month') }}
+ /{{ isYearly ? $t('billing.subscribe.per_year') : $t('billing.subscribe.per_month') }}
{{ isYearly ? $t('billing.subscribe.billed_yearly') : $t('billing.subscribe.billed_monthly') }}
diff --git a/resources/js/pages/settings/account/Billing.vue b/resources/js/pages/settings/account/Billing.vue
index 21e919d7..6c4ca1bf 100644
--- a/resources/js/pages/settings/account/Billing.vue
+++ b/resources/js/pages/settings/account/Billing.vue
@@ -1,6 +1,7 @@
@@ -86,7 +85,7 @@ const formatPrice = (cents: number): string => {
{{ $t('billing.plan.price') }}
- {{ formatPrice(plan?.monthly_price ?? 0) }}/{{ $t('billing.plan.month') }}
+ {{ monthlyPrice(plan?.slug) }}/{{ $t('billing.plan.month') }}
diff --git a/tests/Feature/PlanSeederTest.php b/tests/Feature/PlanSeederTest.php
index b1fad711..b551cd98 100644
--- a/tests/Feature/PlanSeederTest.php
+++ b/tests/Feature/PlanSeederTest.php
@@ -14,8 +14,6 @@
$starter = Plan::where('slug', Slug::Starter)->first();
expect($starter->name)->toBe('Starter')
- ->and($starter->monthly_price)->toBe(1900)
- ->and($starter->yearly_price)->toBe(19000)
->and($starter->social_account_limit)->toBe(5)
->and($starter->member_limit)->toBe(1)
->and($starter->workspace_limit)->toBe(1)
@@ -26,8 +24,6 @@
$max = Plan::where('slug', Slug::Max)->first();
expect($max->name)->toBe('Max')
- ->and($max->monthly_price)->toBe(9900)
- ->and($max->yearly_price)->toBe(99000)
->and($max->social_account_limit)->toBe(100)
->and($max->member_limit)->toBe(20)
->and($max->workspace_limit)->toBe(50)
diff --git a/tests/Feature/PlanTest.php b/tests/Feature/PlanTest.php
index ea603f64..e32fc927 100644
--- a/tests/Feature/PlanTest.php
+++ b/tests/Feature/PlanTest.php
@@ -11,15 +11,11 @@
$plan = Plan::factory()->create([
'slug' => Slug::Pro,
'name' => 'Pro',
- 'monthly_price' => 3900,
- 'yearly_price' => 39000,
]);
expect($plan)->toBeInstanceOf(Plan::class)
->and($plan->slug)->toBe(Slug::Pro)
->and($plan->name)->toBe('Pro')
- ->and($plan->monthly_price)->toBe(3900)
- ->and($plan->yearly_price)->toBe(39000)
->and($plan->is_archived)->toBeFalse();
});
@@ -40,18 +36,6 @@
expect(Plan::active()->count())->toBe($activeBefore - 1);
});
-test('formatted monthly price returns dollar format', function () {
- $plan = Plan::where('slug', Slug::Starter)->first();
-
- expect($plan->formattedMonthlyPrice())->toBe('$19');
-});
-
-test('formatted yearly price returns dollar format', function () {
- $plan = Plan::where('slug', Slug::Starter)->first();
-
- expect($plan->formattedYearlyPrice())->toBe('$190');
-});
-
test('integer fields are cast correctly', function () {
$plan = Plan::where('slug', Slug::Starter)->first();