From bfc2737ce58e3ce543608646b8e26750452587ec Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Mon, 16 Feb 2026 11:54:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(credits):=20simpl?= =?UTF-8?q?ify=20credit=20system=20by=20removing=20free=20credits=20and=20?= =?UTF-8?q?B2B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove free credits system (signup bonus, daily credits) and B2B organization credits to simplify the codebase. Credits now only come from purchases or gifts. Changes: - Remove freeCreditsRemaining, dailyFreeCredits, lastDailyResetAt from balances - Remove organizationBalances and creditAllocations tables from schema - Simplify transaction types to: purchase, usage, refund, gift - Remove B2B endpoints from credits controller - Remove checkDailyReset, allocateCredits, deductCredits from service - Add redeemPendingGifts method to auto-redeem gifts on registration - Update frontend to remove free credits display - Add database migration for the changes - Update all related tests to match simplified system --- apps/manacore/apps/web/src/lib/api/credits.ts | 4 +- .../dashboard/widgets/CreditsWidget.svelte | 4 - .../web/src/routes/(app)/credits/+page.svelte | 60 +- .../src/services/credit-client.service.ts | 10 +- .../src/__tests__/utils/mock-factories.ts | 7 +- .../src/__tests__/utils/test-helpers.ts | 2 - .../auth/services/better-auth.service.spec.ts | 58 +- .../src/auth/services/better-auth.service.ts | 70 +- .../src/common/guards/jwt-auth.guard.spec.ts | 7 +- .../src/config/configuration.ts | 5 +- .../src/config/env.validation.ts | 4 - .../src/credits/credits.controller.spec.ts | 419 +----- .../src/credits/credits.controller.ts | 53 +- .../src/credits/credits.service.spec.ts | 1279 +---------------- .../src/credits/credits.service.ts | 491 +------ .../src/credits/dto/allocate-credits.dto.ts | 17 - .../db/migrations/0001_simplify_credits.sql | 40 + .../src/db/schema/credits.schema.ts | 59 +- .../src/gifts/services/gift-code.service.ts | 85 +- .../services/referral-tracking.service.ts | 14 +- 20 files changed, 272 insertions(+), 2416 deletions(-) delete mode 100644 services/mana-core-auth/src/credits/dto/allocate-credits.dto.ts create mode 100644 services/mana-core-auth/src/db/migrations/0001_simplify_credits.sql diff --git a/apps/manacore/apps/web/src/lib/api/credits.ts b/apps/manacore/apps/web/src/lib/api/credits.ts index f6e937b58..b1dd2bd13 100644 --- a/apps/manacore/apps/web/src/lib/api/credits.ts +++ b/apps/manacore/apps/web/src/lib/api/credits.ts @@ -9,15 +9,13 @@ import { getManaAuthUrl } from './config'; // Types export interface CreditBalance { balance: number; - freeCreditsRemaining: number; totalEarned: number; totalSpent: number; - dailyFreeCredits: number; } export interface CreditTransaction { id: string; - type: 'purchase' | 'usage' | 'refund' | 'bonus' | 'expiry' | 'adjustment'; + type: 'purchase' | 'usage' | 'refund' | 'gift'; status: 'pending' | 'completed' | 'failed' | 'cancelled'; amount: number; balanceBefore: number; diff --git a/apps/manacore/apps/web/src/lib/components/dashboard/widgets/CreditsWidget.svelte b/apps/manacore/apps/web/src/lib/components/dashboard/widgets/CreditsWidget.svelte index 465b030b3..65d490f92 100644 --- a/apps/manacore/apps/web/src/lib/components/dashboard/widgets/CreditsWidget.svelte +++ b/apps/manacore/apps/web/src/lib/components/dashboard/widgets/CreditsWidget.svelte @@ -53,10 +53,6 @@ {$_('dashboard.widgets.credits.available')} {formatCredits(data.balance)} -
Verfügbare Credits
@@ -170,14 +168,6 @@Gratis-Credits heute
-- {balance?.freeCreditsRemaining ?? 0} / {balance?.dailyFreeCredits ?? 5} -
-Gesamt erhalten
@@ -281,11 +271,23 @@