diff --git a/app/Http/Controllers/SubscriptionController.php b/app/Http/Controllers/SubscriptionController.php index 39e6db5f..fbddaac5 100644 --- a/app/Http/Controllers/SubscriptionController.php +++ b/app/Http/Controllers/SubscriptionController.php @@ -4,7 +4,6 @@ namespace App\Http\Controllers; use App\Actions\Subscription\RefundSelfServe; use App\Features\SubscriptionExperiment; -use App\Models\AccountBalance; use App\Models\User; use App\Models\UserLead; use App\Services\Discord\DiscordWebhook; @@ -52,32 +51,14 @@ class SubscriptionController extends Controller } /** - * @return array{accountsCount: int, transactionsCount: int, categoriesCount: int, automationRulesCount: int, balancesByCurrency: array} + * @return array{accountsCount: int, transactionsCount: int, categoriesCount: int} */ private function getUserStats(User $user): array { - $accounts = $user->accounts()->get(); - - $balancesByCurrency = []; - foreach ($accounts as $account) { - $latestBalance = AccountBalance::query() - ->where('account_id', $account->id) - ->orderBy('balance_date', 'desc') - ->value('balance') ?? 0; - - $currency = $account->currency_code; - if (! isset($balancesByCurrency[$currency])) { - $balancesByCurrency[$currency] = 0; - } - $balancesByCurrency[$currency] += $latestBalance; - } - return [ - 'accountsCount' => $accounts->count(), + 'accountsCount' => $user->accounts()->count(), 'transactionsCount' => $user->transactions()->count(), 'categoriesCount' => $user->categories()->count(), - 'automationRulesCount' => $user->automationRules()->count(), - 'balancesByCurrency' => $balancesByCurrency, ]; } diff --git a/resources/js/pages/subscription/paywall.tsx b/resources/js/pages/subscription/paywall.tsx index 111d4a34..e5ddb2ac 100644 --- a/resources/js/pages/subscription/paywall.tsx +++ b/resources/js/pages/subscription/paywall.tsx @@ -20,7 +20,6 @@ import { ReceiptIcon, TrendingUpIcon, UsersIcon, - WalletIcon, } from 'lucide-react'; import { useEffect, useState } from 'react'; @@ -28,8 +27,6 @@ interface PaywallStats { accountsCount: number; transactionsCount: number; categoriesCount: number; - automationRulesCount: number; - balancesByCurrency: Record; } interface ExperimentOffer { @@ -210,41 +207,6 @@ function StatItem({ ); } -function BalanceDisplay({ - balancesByCurrency, -}: { - balancesByCurrency: Record; -}) { - const locale = useLocale(); - const entries = Object.entries(balancesByCurrency); - - if (entries.length === 0) { - return null; - } - - return ( -
- -
- {entries.map(([currency, amount]) => ( - - {formatCurrency( - Math.abs(amount), - currency, - locale, - 0, - 0, - )} - - ))} -
- - {__('Balance')} - -
- ); -} - function FinancialSnapshot({ stats }: { stats: PaywallStats }) { const hasData = stats.accountsCount > 0 || @@ -282,11 +244,6 @@ function FinancialSnapshot({ stats }: { stats: PaywallStats }) { delay={300} /> )} - {Object.keys(stats.balancesByCurrency).length > 0 && ( - - )} ); diff --git a/tests/Feature/SubscriptionTest.php b/tests/Feature/SubscriptionTest.php index 3b41ad8a..898bb6ae 100644 --- a/tests/Feature/SubscriptionTest.php +++ b/tests/Feature/SubscriptionTest.php @@ -2,7 +2,6 @@ use App\Http\Middleware\HandleInertiaRequests; use App\Models\Account; -use App\Models\AccountBalance; use App\Models\BankingConnection; use App\Models\Category; use App\Models\Transaction; @@ -50,7 +49,6 @@ test('paywall page includes user stats', function () { $user = User::factory()->onboarded()->create(); $account = Account::factory()->for($user)->create(['currency_code' => 'USD']); - AccountBalance::factory()->for($account)->create(['balance' => 150000]); Transaction::factory()->count(3)->for($user)->for($account)->create(); Category::factory()->count(2)->for($user)->create(); @@ -64,11 +62,8 @@ test('paywall page includes user stats', function () { ->has('stats.accountsCount') ->has('stats.transactionsCount') ->has('stats.categoriesCount') - ->has('stats.automationRulesCount') - ->has('stats.balancesByCurrency') ->where('stats.accountsCount', 1) ->where('stats.transactionsCount', 3) - ->where('stats.balancesByCurrency.USD', 150000) ); });