Compare commits

...

27 Commits

Author SHA1 Message Date
m
08399bbb0a feat: add Patentprozesskostenrechner at /kosten/rechner
Full patent litigation cost calculator supporting:
- DE courts: LG, OLG, BGH (NZB/Revision), BPatG, BGH nullity
- UPC: first instance + appeal with SME reduction
- All 5 GKG/RVG fee schedule versions (2005-2025)
- Per-instance config: attorneys, patent attorneys, hearing, clients
- Live cost breakdown with per-instance detail cards
- DE vs UPC comparison bar chart
- Streitwert slider with presets (500 - 30M EUR)
- German labels, EUR formatting, responsive layout

New files:
- lib/costs/types.ts, fee-tables.ts, calculator.ts (pure calculation)
- components/costs/CostCalculator, InstanceCard, UPCCard, CostSummary, CostComparison
- app/(app)/kosten/rechner/page.tsx

Sidebar: added "Kostenrechner" with Calculator icon between Berichte and AI Analyse.
Types: added FeeCalculateRequest/Response to lib/types.ts.
2026-03-31 17:42:11 +02:00
m
d4092acc33 docs: Patentprozesskostenrechner implementation plan 2026-03-31 17:31:37 +02:00
m
7c70649494 docs: add Patentprozesskostenrechner implementation plan
Comprehensive analysis of the Excel-based patent litigation cost calculator
with implementation plan for the web version:

- Fee calculation logic (GKG/RVG step-based accumulator, all multipliers)
- Exact fee schedule data for all 5 versions (extracted from Excel)
- UPC fee structure research (fixed fees, value-based brackets, recoverable costs)
- Architecture: new page at /kosten/rechner within KanzlAI-mGMT (pure frontend)
- Complete input/output specifications
- 3 bugs to fix from the Excel (VAT formula, wrong fee type, missing expert fees)
- Side-by-side DE vs UPC cost comparison data
2026-03-31 17:28:39 +02:00
m
3599e302df feat: redesign Fristenrechner — cards, no tabs, inline calculation 2026-03-30 21:00:14 +02:00
m
899b461833 feat: redesign Fristenrechner as single-flow card-based UI
Replace the Schnell/Wizard tab layout with a unified flow:
1. Proceeding type selection via compact clickable cards grouped
   by jurisdiction + category (UPC Hauptverfahren, im Verfahren,
   Rechtsbehelfe, Deutsche Patentverfahren)
2. Vertical deadline rule list for the selected type showing name,
   duration, rule code, and acting party
3. Inline expansion on click with date picker, auto-calculated due
   date (via selected_rule_ids API), holiday/weekend adjustment
   note, and save-to-case option

Old DeadlineCalculator.tsx and DeadlineWizard.tsx are no longer
imported but kept for reference.
2026-03-30 20:55:46 +02:00
m
260f65ea02 feat: auto-calculate deadlines on proceeding type selection (no click needed) 2026-03-30 19:41:02 +02:00
m
501b573967 fix: use typed category field instead of Record cast 2026-03-30 19:37:52 +02:00
m
23b8ef4bba chore: gitignore server binary and local state files 2026-03-30 19:34:34 +02:00
m
54c6eb8dae feat: 15 UPC proceeding types in 3 groups + category field
Added 10 new UPC types: DNI, EPO, AMD, CCI, EVP, DAM, COS, REH, DEF, RST.
Grouped as: Hauptverfahren / Verfahren im Verfahren / Rechtsbehelfe.
Frontend dropdown shows sub-groups within jurisdiction. German names throughout.
2026-03-30 19:34:07 +02:00
m
967f2f6d09 feat: direct SMTP email sending via Hostinger (replaces m CLI) 2026-03-30 17:28:40 +02:00
m
e5387734aa fix: use mgmt@msbls.de as default MAIL_FROM (alias now exists) 2026-03-30 17:28:11 +02:00
m
6cb87c6868 feat: replace m CLI email with direct SMTP over TLS
The m CLI isn't available in Docker containers. Replace exec.Command("m", "mail", "send")
with direct SMTP using crypto/tls + net/smtp (implicit TLS on port 465).

Env vars: SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS, MAIL_FROM
Gracefully skips sending if SMTP is not configured.

Note: mgmt@msbls.de rejected by Hostinger as not owned by mail@msbls.de.
Default from address set to mail@msbls.de until alias is created.
2026-03-30 17:23:54 +02:00
m
d38719db2f fix: add email field to UserTenant TypeScript type 2026-03-30 17:19:15 +02:00
m
b21efccfb5 fix: add MAIL_FROM env (default mgmt@msbls.de) + graceful fallback when m CLI unavailable 2026-03-30 17:10:25 +02:00
m
f51d189a3b fix: show member email instead of UUID in team management 2026-03-30 17:09:14 +02:00
m
481b299e03 test: comprehensive integration tests for all API endpoints 2026-03-30 14:43:32 +02:00
m
68d48100b9 test: comprehensive integration tests for all API endpoints
Replace the existing integration test suite with a complete test covering
every registered API route. Tests use httptest with the real router and
a real DB connection (youpc.org mgmt schema).

Endpoint groups tested:
- Health, Auth (JWT validation, expired/invalid/wrong-secret)
- Current user (GET /api/me)
- Tenants (CRUD, auto-assign)
- Cases (CRUD with search/status filters)
- Parties (CRUD)
- Deadlines (CRUD, complete, batch create)
- Appointments (CRUD)
- Notes (CRUD)
- Dashboard
- Proceeding types & deadline rules
- Deadline calculator & determination (timeline, determine)
- Reports (cases, deadlines, workload, billing)
- Templates (CRUD, render)
- Time entries (CRUD, summary)
- Invoices (CRUD, status update)
- Billing rates (list, upsert)
- Notifications (list, unread count, mark read, preferences)
- Audit log (list, filtered)
- Case assignments (assign, unassign)
- Documents (list, meta)
- AI endpoints (availability check)
- Critical path E2E (case -> deadline -> appointment -> note -> time entry -> dashboard -> complete)
2026-03-30 14:41:59 +02:00
m
40a11a4c49 feat: group proceeding types by jurisdiction (UPC/DE) + add German patent proceedings 2026-03-30 14:33:28 +02:00
m
eca0cde5e7 fix: timeline 404 + calculate endpoint fixes 2026-03-30 14:32:51 +02:00
m
cf3711b2e4 fix: update seed files to use mgmt schema after migration
The search_path was changed from kanzlai to mgmt but seed files
still referenced the old schema. Also added missing is_spawn and
spawn_label columns to mgmt.deadline_rules via direct DB migration.

Root cause of timeline 404 / calculate+determine 400: the ruleColumns
query selected is_spawn and spawn_label which didn't exist in the
mgmt.deadline_rules table, causing all deadline rule queries to fail.
2026-03-30 14:30:40 +02:00
m
dea49f6f8e feat: group proceeding types by jurisdiction in UI dropdowns
- DeadlineCalculator: use optgroup to group by UPC/DE
- DeadlineWizard: add section headers for each jurisdiction
- CaseForm: replace hardcoded TYPE_OPTIONS with API-fetched
  proceeding types grouped by jurisdiction
- Added 3 new DE proceeding types to DB: DE_PATENT,
  DE_NULLITY, DE_OPPOSITION
2026-03-30 14:29:42 +02:00
m
5e401d2eac fix: default deadline calculator date to today 2026-03-30 14:21:08 +02:00
m
3f90904e0c fix: update search_path from kanzlai to mgmt after migration 2026-03-30 14:18:35 +02:00
m
f285d4451d refactor: switch to youpc.org Supabase, remove separate YouPCDatabaseURL 2026-03-30 14:09:52 +02:00
m
bf1b1cdd82 refactor: remove YouPCDatabaseURL, use same DB connection for case finder
Now that KanzlAI is on the youpc.org Supabase instance, the separate
YouPCDatabaseURL connection is unnecessary. The main database connection
can query mlex.* tables directly since they're on the same Postgres.

- Remove YouPCDatabaseURL from config
- Remove separate sqlx.Connect block in main.go
- Pass main database handle as youpcDB parameter to router
- Update CLAUDE.md: mgmt schema in youpc.org (was kanzlai in flexsiebels)
2026-03-30 14:01:19 +02:00
m
9d89b97ad5 fix: open reports endpoints to all roles, only billing restricted 2026-03-30 13:44:04 +02:00
m
2f572fafc9 fix: wire all missing routes (reports, time entries, invoices, templates, billing) 2026-03-30 13:14:18 +02:00
32 changed files with 4485 additions and 365 deletions

6
.gitignore vendored
View File

@@ -46,3 +46,9 @@ tmp/
# TypeScript
*.tsbuildinfo
.worktrees/
backend/server
backend/.m/
.m/inbox_lastread
backend/server
backend/.m/
.m/inbox_lastread

View File

@@ -18,7 +18,7 @@ frontend/ Next.js 15 (TypeScript, Tailwind CSS, App Router)
- **Frontend:** Next.js 15 with TypeScript, Tailwind CSS v4, App Router, Bun
- **Backend:** Go (standard library HTTP server)
- **Database:** Supabase (PostgreSQL) — `kanzlai` schema in flexsiebels instance
- **Database:** Supabase (PostgreSQL) — `mgmt` schema in youpc.org instance
- **Deploy:** Dokploy on mLake, domain: kanzlai.msbls.de
## Development

View File

@@ -5,7 +5,6 @@ import (
"net/http"
"os"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"mgit.msbls.de/m/KanzlAI-mGMT/internal/auth"
@@ -34,21 +33,6 @@ func main() {
authMW := auth.NewMiddleware(cfg.SupabaseJWTSecret, database)
// Optional: connect to youpc.org database for similar case finder
var youpcDB *sqlx.DB
if cfg.YouPCDatabaseURL != "" {
youpcDB, err = sqlx.Connect("postgres", cfg.YouPCDatabaseURL)
if err != nil {
slog.Warn("failed to connect to youpc.org database — similar case finder disabled", "error", err)
youpcDB = nil
} else {
youpcDB.SetMaxOpenConns(5)
youpcDB.SetMaxIdleConns(2)
defer youpcDB.Close()
slog.Info("connected to youpc.org database for similar case finder")
}
}
// Start CalDAV sync service
calDAVSvc := services.NewCalDAVService(database)
calDAVSvc.Start()
@@ -59,7 +43,7 @@ func main() {
notifSvc.Start()
defer notifSvc.Stop()
handler := router.New(database, authMW, cfg, calDAVSvc, notifSvc, youpcDB)
handler := router.New(database, authMW, cfg, calDAVSvc, notifSvc, database)
slog.Info("starting KanzlAI API server", "port", cfg.Port)
if err := http.ListenAndServe(":"+cfg.Port, handler); err != nil {

View File

@@ -14,7 +14,13 @@ type Config struct {
SupabaseJWTSecret string
AnthropicAPIKey string
FrontendOrigin string
YouPCDatabaseURL string // read-only connection to youpc.org Supabase for similar case finder
// SMTP settings (optional — email sending disabled if SMTPHost is empty)
SMTPHost string
SMTPPort string
SMTPUser string
SMTPPass string
MailFrom string
}
func Load() (*Config, error) {
@@ -27,7 +33,12 @@ func Load() (*Config, error) {
SupabaseJWTSecret: os.Getenv("SUPABASE_JWT_SECRET"),
AnthropicAPIKey: os.Getenv("ANTHROPIC_API_KEY"),
FrontendOrigin: getEnv("FRONTEND_ORIGIN", "https://kanzlai.msbls.de"),
YouPCDatabaseURL: os.Getenv("YOUPC_DATABASE_URL"),
SMTPHost: os.Getenv("SMTP_HOST"),
SMTPPort: getEnv("SMTP_PORT", "465"),
SMTPUser: os.Getenv("SMTP_USER"),
SMTPPass: os.Getenv("SMTP_PASS"),
MailFrom: getEnv("MAIL_FROM", "mgmt@msbls.de"),
}
if cfg.DatabaseURL == "" {

View File

@@ -13,8 +13,8 @@ func Connect(databaseURL string) (*sqlx.DB, error) {
return nil, fmt.Errorf("connecting to database: %w", err)
}
// Set search_path so queries use kanzlai schema by default
if _, err := db.Exec("SET search_path TO kanzlai, public"); err != nil {
// Set search_path so queries use mgmt schema by default
if _, err := db.Exec("SET search_path TO mgmt, public"); err != nil {
db.Close()
return nil, fmt.Errorf("setting search_path: %w", err)
}

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,7 @@ type ProceedingType struct {
Name string `db:"name" json:"name"`
Description *string `db:"description" json:"description,omitempty"`
Jurisdiction *string `db:"jurisdiction" json:"jurisdiction,omitempty"`
Category *string `db:"category" json:"category,omitempty"`
DefaultColor string `db:"default_color" json:"default_color"`
SortOrder int `db:"sort_order" json:"sort_order"`
IsActive bool `db:"is_active" json:"is_active"`

View File

@@ -20,6 +20,7 @@ type UserTenant struct {
UserID uuid.UUID `db:"user_id" json:"user_id"`
TenantID uuid.UUID `db:"tenant_id" json:"tenant_id"`
Role string `db:"role" json:"role"`
Email string `db:"email" json:"email"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
}

View File

@@ -215,10 +215,10 @@ func New(db *sqlx.DB, authMW *auth.Middleware, cfg *config.Config, calDAVSvc *se
scoped.HandleFunc("GET /api/caldav/status", calDAVH.GetStatus)
}
// Reports — billing permission (partners + owners)
scoped.HandleFunc("GET /api/reports/cases", perm(auth.PermManageBilling, reportH.Cases))
scoped.HandleFunc("GET /api/reports/deadlines", perm(auth.PermManageBilling, reportH.Deadlines))
scoped.HandleFunc("GET /api/reports/workload", perm(auth.PermManageBilling, reportH.Workload))
// Reports — cases/deadlines/workload open to all, billing restricted
scoped.HandleFunc("GET /api/reports/cases", reportH.Cases)
scoped.HandleFunc("GET /api/reports/deadlines", reportH.Deadlines)
scoped.HandleFunc("GET /api/reports/workload", reportH.Workload)
scoped.HandleFunc("GET /api/reports/billing", perm(auth.PermManageBilling, reportH.Billing))
// Time entries — all can view/create, tied to cases

View File

@@ -2,9 +2,12 @@ package services
import (
"context"
"crypto/tls"
"fmt"
"log/slog"
"os/exec"
"net"
"net/smtp"
"os"
"strings"
"sync"
"time"
@@ -457,18 +460,85 @@ type UpdatePreferencesInput struct {
DailyDigest bool `json:"daily_digest"`
}
// SendEmail sends an email using the `m mail send` CLI command.
// SendEmail sends an email via direct SMTP over TLS.
// Requires SMTP_HOST, SMTP_USER, SMTP_PASS env vars. Falls back to no-op if unconfigured.
func SendEmail(to, subject, body string) error {
cmd := exec.Command("m", "mail", "send",
"--to", to,
"--subject", subject,
"--body", body,
"--yes")
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("m mail send failed: %w (output: %s)", err, string(output))
host := os.Getenv("SMTP_HOST")
port := os.Getenv("SMTP_PORT")
user := os.Getenv("SMTP_USER")
pass := os.Getenv("SMTP_PASS")
from := os.Getenv("MAIL_FROM")
if port == "" {
port = "465"
}
slog.Info("email sent", "to", to, "subject", subject)
if from == "" {
from = "mgmt@msbls.de"
}
if host == "" || user == "" || pass == "" {
slog.Warn("SMTP not configured, skipping email", "to", to, "subject", subject)
return nil
}
// Build RFC 2822 message
msg := fmt.Sprintf("From: \"KanzlAI-mGMT\" <%s>\r\n"+
"To: %s\r\n"+
"Subject: [KanzlAI] %s\r\n"+
"MIME-Version: 1.0\r\n"+
"Content-Type: text/plain; charset=utf-8\r\n"+
"Date: %s\r\n"+
"\r\n%s",
from, to, subject,
time.Now().Format(time.RFC1123Z),
body)
addr := net.JoinHostPort(host, port)
// Connect with implicit TLS (port 465)
tlsConfig := &tls.Config{ServerName: host}
conn, err := tls.Dial("tcp", addr, tlsConfig)
if err != nil {
return fmt.Errorf("smtp tls dial: %w", err)
}
client, err := smtp.NewClient(conn, host)
if err != nil {
conn.Close()
return fmt.Errorf("smtp new client: %w", err)
}
defer client.Close()
// Authenticate
auth := smtp.PlainAuth("", user, pass, host)
if err := client.Auth(auth); err != nil {
return fmt.Errorf("smtp auth: %w", err)
}
// Send
if err := client.Mail(from); err != nil {
return fmt.Errorf("smtp mail from: %w", err)
}
if err := client.Rcpt(to); err != nil {
return fmt.Errorf("smtp rcpt to: %w", err)
}
w, err := client.Data()
if err != nil {
return fmt.Errorf("smtp data: %w", err)
}
if _, err := w.Write([]byte(msg)); err != nil {
return fmt.Errorf("smtp write: %w", err)
}
if err := w.Close(); err != nil {
return fmt.Errorf("smtp close data: %w", err)
}
if err := client.Quit(); err != nil {
slog.Warn("smtp quit error (non-fatal)", "error", err)
}
slog.Info("email sent via SMTP", "from", from, "to", to, "subject", subject)
return nil
}

View File

@@ -139,7 +139,11 @@ func (s *TenantService) FirstTenantForUser(ctx context.Context, userID uuid.UUID
func (s *TenantService) ListMembers(ctx context.Context, tenantID uuid.UUID) ([]models.UserTenant, error) {
var members []models.UserTenant
err := s.db.SelectContext(ctx, &members,
`SELECT user_id, tenant_id, role, created_at FROM user_tenants WHERE tenant_id = $1 ORDER BY created_at`,
`SELECT ut.user_id, ut.tenant_id, ut.role, ut.created_at, COALESCE(au.email, '') as email
FROM user_tenants ut
LEFT JOIN auth.users au ON au.id = ut.user_id
WHERE ut.tenant_id = $1
ORDER BY ut.created_at`,
tenantID,
)
if err != nil {

View File

@@ -2,7 +2,7 @@
-- Creates 1 test tenant, 5 cases with deadlines and appointments
-- Run with: psql $DATABASE_URL -f demo_data.sql
SET search_path TO kanzlai, public;
SET search_path TO mgmt, public;
-- Demo tenant
INSERT INTO tenants (id, name, slug, settings) VALUES

View File

@@ -1,6 +1,6 @@
-- UPC Proceeding Timeline: Full event tree with conditional deadlines
-- Ported from youpc.org migrations 039 + 040
-- Run against kanzlai schema in flexsiebels Supabase instance
-- Run against mgmt schema in youpc.org Supabase instance
-- ========================================
-- 1. Add is_spawn + spawn_label columns

514
docs/kostenrechner-plan.md Normal file
View File

@@ -0,0 +1,514 @@
# Patentprozesskostenrechner — Implementation Plan
**Date:** 2026-03-31
**Source:** Analysis of `Patentprozesskostenrechner.xlsm` (c) 2021 M. Siebels
**Status:** Research complete, ready for implementation
---
## 1. Fee Calculation Logic Summary
The calculator computes costs for German patent litigation using two fee systems:
### GKG (Gerichtskostengesetz) — Court Fees
A **step-based accumulator**. The Streitwert is divided into brackets, each with a step size and per-step increment. The algorithm:
1. Start with the minimum fee (first row of the fee table)
2. For each bracket: compute `steps = ceil(portion_in_bracket / step_size)`
3. Accumulate: `fee += steps * increment`
4. Result = "einfache Gebühr" (1.0x base fee)
5. Multiply by the instance-specific factor (e.g., 3.0x for LG, 4.0x for OLG)
For Streitwert > EUR 500,000 (post-2025 schedule): `base = 4,138 + ceil((Streitwert - 500,000) / 50,000) * 210`
### RVG (Rechtsanwaltsvergütungsgesetz) — Attorney Fees
Same step-based lookup but with its own column in the fee table. Per attorney, the formula is:
```
attorney_cost = (VG_factor * base_RVG + increase_fee + TG_factor * base_RVG + Pauschale) * (1 + VAT)
```
Where:
- **VG** = Verfahrensgebühr (procedural fee): 1.3x (LG/BPatG), 1.6x (OLG/BGH nullity), 2.3x (BGH NZB/Rev for RA)
- **TG** = Terminsgebühr (hearing fee): 1.2x or 1.5x (BGH), only if hearing held
- **Increase fee** (Nr. 1008 VV RVG): `MIN((clients - 1) * 0.3, 2.0) * base_RVG` for multiple clients
- **Pauschale** = EUR 20 (Auslagenpauschale Nr. 7002 VV RVG)
### PatKostG — Patent Court Fees
BPatG nullity uses PatKostG instead of GKG for court fees (but same step-based lookup from the same table). DPMA/BPatG cancellation uses fixed fees (EUR 300 / EUR 500).
### Instance Multipliers (Complete Reference)
| Instance | Court Fee Factor | Source | Fee Basis |
|---|---|---|---|
| **LG** (infringement 1st) | 3.0x GKG | Nr. 1210 Anl. 1 GKG | GKG |
| **OLG** (infringement appeal) | 4.0x GKG | Nr. 1420 KV GKG | GKG |
| **BGH NZB** (leave to appeal) | 2.0x GKG | Nr. 1242 KV GKG | GKG |
| **BGH Revision** | 5.0x GKG | Nr. 1230 KV GKG | GKG |
| **BPatG** (nullity 1st) | 4.5x | Nr. 402 100 Anl. PatKostG | PatKostG |
| **BGH** (nullity appeal) | 6.0x GKG | Nr. 1250 KV GKG | GKG |
| **DPMA** (cancellation) | EUR 300 flat | Nr. 323 100 Anl. PatKostG | Fixed |
| **BPatG** (cancellation appeal) | EUR 500 flat | Nr. 401 100 Anl. PatKostG | Fixed |
| Instance | RA VG Factor | RA TG Factor | PA VG Factor | PA TG Factor |
|---|---|---|---|---|
| **LG** | 1.3x | 1.2x | 1.3x | 1.2x |
| **OLG** | 1.6x | 1.2x | 1.6x | 1.2x |
| **BGH NZB** | 2.3x | 1.2x | 1.6x | 1.2x |
| **BGH Revision** | 2.3x | 1.5x | 1.6x | 1.5x |
| **BPatG** (nullity) | 1.3x | 1.2x | 1.3x | 1.2x |
| **BGH** (nullity appeal) | 1.6x | 1.5x | 1.6x | 1.5x |
| **DPMA** | 1.3x | 1.2x | — | — |
| **BPatG** (cancellation) | 1.3x | 1.2x | — | — |
---
## 2. Fee Schedule Data (JSON)
Five historical versions of the fee table. Each row: `[upperBound, stepSize, gkgIncrement, rvgIncrement]`.
Each row: `[upperBound, stepSize, gkgIncrement, rvgIncrement]`. Values extracted directly from the Excel ListObjects. Note: increments are decimal (e.g., 51.5 EUR per step). The last bracket uses a very large upper bound (effectively infinity).
```json
{
"feeSchedules": {
"2005": {
"label": "GKG/RVG 2006-09-01",
"validFrom": "2006-09-01",
"brackets": [
[300, 300, 25, 25],
[1500, 300, 10, 20],
[5000, 500, 8, 28],
[10000, 1000, 15, 37],
[25000, 3000, 23, 40],
[50000, 5000, 29, 72],
[200000, 15000, 100, 77],
[500000, 30000, 150, 118],
[Infinity, 50000, 150, 150]
]
},
"2013": {
"label": "GKG/RVG 2013-08-01",
"validFrom": "2013-08-01",
"brackets": [
[500, 300, 35, 45],
[2000, 500, 18, 35],
[10000, 1000, 19, 51],
[25000, 3000, 26, 46],
[50000, 5000, 35, 75],
[200000, 15000, 120, 85],
[500000, 30000, 179, 120],
[Infinity, 50000, 180, 150]
]
},
"2021": {
"label": "GKG/RVG 2021-01-01",
"validFrom": "2021-01-01",
"brackets": [
[500, 300, 38, 49],
[2000, 500, 20, 39],
[10000, 1000, 21, 56],
[25000, 3000, 29, 52],
[50000, 5000, 38, 81],
[200000, 15000, 132, 94],
[500000, 30000, 198, 132],
[Infinity, 50000, 198, 165]
]
},
"2025": {
"label": "GKG/RVG 2025-06-01",
"validFrom": "2025-06-01",
"brackets": [
[500, 300, 40, 51.5],
[2000, 500, 21, 41.5],
[10000, 1000, 22.5, 59.5],
[25000, 3000, 30.5, 55],
[50000, 5000, 40.5, 86],
[200000, 15000, 140, 99.5],
[500000, 30000, 210, 140],
[Infinity, 50000, 210, 175]
]
},
"Aktuell": {
"label": "Aktuell (= 2025-06-01)",
"validFrom": "2025-06-01",
"aliasOf": "2025"
}
},
"constants": {
"erhoehungsfaktor": 0.3,
"erhoehungsfaktorMax": 2.0,
"auslagenpauschale": 20
}
}
```
**Notes on the data:**
- The 2005 version has 9 brackets (starts at 300, not 500). Older versions differ more than expected.
- Increments are **not integers** in the 2025 version (e.g., 51.5, 41.5, 59.5) — the implementation must handle decimal arithmetic.
- The last bracket upper bound is `1e+20` in the Excel (effectively infinity). Use `Infinity` in TypeScript or a sentinel value.
- "Aktuell" is currently identical to "2025" — implement as an alias that can diverge when fees are next updated.
### UPC Fee Data (New — Not in Excel)
```json
{
"upcFees": {
"pre2026": {
"label": "UPC (vor 2026)",
"validFrom": "2023-06-01",
"fixedFees": {
"infringement": 11000,
"counterclaim_infringement": 11000,
"non_infringement": 11000,
"license_compensation": 11000,
"determine_damages": 3000,
"revocation_standalone": 20000,
"counterclaim_revocation": 20000,
"provisional_measures": 11000
},
"valueBased": [
{ "maxValue": 500000, "fee": 0 },
{ "maxValue": 750000, "fee": 2500 },
{ "maxValue": 1000000, "fee": 4000 },
{ "maxValue": 1500000, "fee": 8000 },
{ "maxValue": 2000000, "fee": 13000 },
{ "maxValue": 3000000, "fee": 20000 },
{ "maxValue": 4000000, "fee": 26000 },
{ "maxValue": 5000000, "fee": 32000 },
{ "maxValue": 6000000, "fee": 39000 },
{ "maxValue": 7000000, "fee": 46000 },
{ "maxValue": 8000000, "fee": 52000 },
{ "maxValue": 9000000, "fee": 58000 },
{ "maxValue": 10000000, "fee": 65000 },
{ "maxValue": 15000000, "fee": 75000 },
{ "maxValue": 20000000, "fee": 100000 },
{ "maxValue": 25000000, "fee": 125000 },
{ "maxValue": 30000000, "fee": 150000 },
{ "maxValue": 50000000, "fee": 250000 },
{ "maxValue": null, "fee": 325000 }
],
"recoverableCosts": [
{ "maxValue": 250000, "ceiling": 38000 },
{ "maxValue": 500000, "ceiling": 56000 },
{ "maxValue": 1000000, "ceiling": 112000 },
{ "maxValue": 2000000, "ceiling": 200000 },
{ "maxValue": 4000000, "ceiling": 400000 },
{ "maxValue": 8000000, "ceiling": 600000 },
{ "maxValue": 16000000, "ceiling": 800000 },
{ "maxValue": 30000000, "ceiling": 1200000 },
{ "maxValue": 50000000, "ceiling": 1500000 },
{ "maxValue": null, "ceiling": 2000000 }
],
"smReduction": 0.40
},
"2026": {
"label": "UPC (ab 2026)",
"validFrom": "2026-01-01",
"fixedFees": {
"infringement": 14600,
"counterclaim_infringement": 14600,
"non_infringement": 14600,
"license_compensation": 14600,
"determine_damages": 4000,
"revocation_standalone": 26500,
"counterclaim_revocation": 26500,
"provisional_measures": 14600
},
"valueBased": "TODO: exact 2026 table not yet published in extractable form. Estimated ~32% increase on pre-2026 values. Replace with official data when available.",
"smReduction": 0.50
}
}
}
```
---
## 3. Architecture Decision
### Recommendation: New page within KanzlAI-mGMT at `/kosten/rechner`
**Reasons:**
1. **Existing infrastructure**: KanzlAI already has billing/cost infrastructure (time tracking, invoices, RVG rates). The Kostenrechner is a natural extension.
2. **Shared UI patterns**: Sidebar nav, card layout, Tailwind styling, Recharts for any comparison charts — all already established.
3. **Future integration**: Cost calculations can link to cases (attach estimated costs to a case), feed into Prozesskostensicherheit calculations, and inform billing.
4. **No auth required for core calculator**: The page can work without login (public tool for marketing), but logged-in users get case-linking and save functionality.
5. **No backend needed initially**: All fee calculations are deterministic lookups + arithmetic — pure frontend. Data lives as static JSON/TypeScript constants.
**Against standalone deployment:**
- Maintaining a separate deploy adds operational overhead for zero benefit
- Can't integrate with cases or billing later without cross-origin complexity
- Duplicates styling/build tooling
### Proposed Route Structure
```
/kosten/ — Overview page (links to sub-calculators)
/kosten/rechner — Patentprozesskostenrechner (main calculator)
/kosten/rechner/vergleich — (future) Venue comparison tool (DE vs UPC)
```
### Frontend Architecture
```
frontend/src/
app/(app)/kosten/
page.tsx — Overview
rechner/
page.tsx — Calculator page (client component)
lib/
costs/
fee-tables.ts — All fee schedule data (GKG, RVG, UPC)
calculator.ts — Pure calculation functions
types.ts — TypeScript types for inputs/outputs
components/
costs/
CostCalculator.tsx — Main calculator component
InstanceCard.tsx — Per-instance input card (LG, OLG, etc.)
CostSummary.tsx — Results display with breakdown
CostComparison.tsx — (future) Side-by-side venue comparison
```
**No backend changes needed.** All calculation logic is client-side. If we later want to save calculations to a case, we add one API endpoint.
---
## 4. All Inputs
### Global Inputs
| Input | Type | Range | Default | Description |
|---|---|---|---|---|
| `vatRate` | enum | 0%, 16%, 19% | 0% | Umsatzsteuer |
| `streitwert` | number | 50030,000,000 | 100,000 | Amount in dispute (EUR) |
| `erhoehungsStreitwert` | number | >= streitwert | = streitwert | Increased amount (for Erhoehungsgebuehr) |
| `proceedingType` | enum | infringement, nullity, cancellation, security | infringement | Which proceeding to calculate |
### Per-Instance Inputs (Infringement: LG, OLG, BGH-NZB, BGH-Rev)
| Input | Type | Default | Description |
|---|---|---|---|
| `enabled` | boolean | true (LG), false (others) | Include this instance |
| `feeVersion` | enum | "Aktuell" | Fee schedule version (2005/2013/2021/2025/Aktuell) |
| `numAttorneys` | integer >= 0 | 1 | Rechtsanwälte |
| `numPatentAttorneys` | integer >= 0 | 1 | Patentanwälte |
| `oralHearing` | boolean | true | Mündliche Verhandlung held? |
| `expertFees` | number >= 0 | 0 | Sachverständigenvergütung (EUR) |
| `terminationType` | enum | "Urteil" | How case ended (Urteil/Vergleich/Klagerücknahme/etc.) |
| `numClients` | integer >= 1 | 1 | Mandanten (for Erhöhungsgebühr) |
### Per-Instance Inputs (Nullity: BPatG, BGH)
Same structure as infringement instances.
### Per-Instance Inputs (Cancellation: DPMA, BPatG)
Same structure but no patent attorneys at DPMA level, fixed court fees.
### UPC-Specific Inputs (New)
| Input | Type | Default | Description |
|---|---|---|---|
| `actionType` | enum | "infringement" | UPC action type (affects fixed fee + value-based applicability) |
| `feeVersion` | enum | "2026" | pre-2026 or 2026 |
| `isSME` | boolean | false | Small/micro enterprise (40%/50% court fee reduction) |
| `includeAppeal` | boolean | false | Include Court of Appeal |
| `includeRevocation` | boolean | false | Include counterclaim for revocation |
---
## 5. All Outputs
### Per-Instance Breakdown
| Output | Description |
|---|---|
| Court fee (base) | e.g., "3.0x GKG = EUR 18,714" |
| Expert fees | If applicable |
| **Court subtotal** | Court fee + expert fees |
| Per-attorney cost | VG + Erhöhung + TG + Pauschale, before VAT |
| Per-attorney cost (incl. VAT) | × (1 + VAT) |
| Attorney subtotal | Per-attorney × num_attorneys |
| Patent attorney subtotal | Same calculation × num_patent_attorneys |
| **Instance total** | Court subtotal + attorney subtotal + patent attorney subtotal |
### Summary Totals (Infringement)
| Output | Description |
|---|---|
| Gesamtkosten bei Nichtzulassung | LG + OLG + BGH-NZB |
| Gesamtkosten bei Revision | LG + OLG + BGH-Rev |
### Summary Totals (Nullity)
| Output | Description |
|---|---|
| Gesamtkosten Nichtigkeitsverfahren | BPatG + BGH |
### Summary Totals (Cancellation)
| Output | Description |
|---|---|
| Gesamtkosten Löschungsverfahren | DPMA + BPatG |
### Security for Costs (Prozesskostensicherheit)
| Output | Description |
|---|---|
| 1. Instanz | 2.5x RA + increase + 2.5x PA + increase + EUR 5,000 |
| 2. Instanz | 2.8x RA + increase + 2.8x PA + increase + 4.0x court + EUR 5,000 |
| NZB | 2.3x RA + increase + 2.3x PA + increase |
| Total (incl. VAT) | Sum × (1 + VAT) |
### UPC Outputs (New)
| Output | Description |
|---|---|
| Fixed court fee | Per action type |
| Value-based fee | Per Streitwert bracket |
| Total court fees | Fixed + value-based |
| Court fees (SME) | With 40%/50% reduction |
| Recoverable costs ceiling | Per Streitwert bracket |
| Appeal court fees | If appeal enabled |
| **Total cost risk** | All court fees + recoverable costs ceiling |
### Fee Schedule Reference (Quick Lookup)
| Output | Description |
|---|---|
| Base 1.0x GKG fee | For each fee version at given Streitwert |
| Base 1.0x RVG fee | For each fee version at given Streitwert |
---
## 6. Bugs to Fix (from Excel)
### Bug 1: Prozesskostensicherheit VAT Formula (CRITICAL)
- **Location:** Excel cell C31 on Prozesskostensicherheit sheet
- **Problem:** Formula `=C30*(1-Umsatzsteuer)` subtracts VAT instead of adding it
- **Label says:** "inkl. Umsatzsteuer" (including VAT)
- **Fix:** `=C30*(1+Umsatzsteuer)` → in web version: `total * (1 + vatRate)`
- **Impact:** 32% error when VAT = 19% (EUR 35,394 vs correct EUR 51,998)
- **Why hidden:** Default VAT is 0%, so `1-0 = 1+0 = 1` — bug only manifests with non-zero VAT
### Bug 2: Prozesskostensicherheit Uses Wrong Fee Type
- **Location:** Excel cell C22 on Prozesskostensicherheit sheet
- **Problem:** `mGebuehrensatz(Streitwert, 1, SelectedVersion)` — parameter `1` selects RVG (attorney) fees
- **Should be:** `mGebuehrensatz(Streitwert, 0, SelectedVersion)` — parameter `0` selects GKG (court) fees
- **Context:** This cell calculates "4-fache Gerichts-Verfahrensgebühr (Nr. 1420 KV)" — clearly a court fee
- **Fix:** Use GKG fee schedule for court fee calculations
- **Impact:** GKG and RVG fees differ, so the result is always wrong
### Bug 3: Nichtigkeitsverfahren Missing Expert Fees in Total
- **Location:** Excel cell D24 on Nichtigkeitsverfahren sheet
- **Problem:** `=C23+C13` adds attorney total (C23) + bare court fee (C13), but C13 is only the 4.5x fee line item
- **Should be:** `=C23+C15` where C15 is the Zwischensumme (court fees + expert fees)
- **Fix:** Include expert fees subtotal in instance total
- **Impact:** Expert fees are silently dropped from the BPatG total. Consistent with Verletzungsverfahren pattern where D26 = C25 + C17 (uses Zwischensumme)
---
## 7. UPC Fee Structure (New Feature)
### How UPC Fees Differ from German Courts
| Aspect | German Courts (GKG/RVG) | UPC |
|---|---|---|
| **Court fee model** | Step-based accumulator | Fixed fee + bracket lookup |
| **Attorney fees** | RVG statutory table | Contractual (market rates) |
| **Recoverable costs** | RVG-based (predictable) | Ceiling table (much higher) |
| **Scope** | Single country | Pan-European |
| **Nullity** | Separate BPatG proceeding | Counterclaim in same action |
### UPC Court Fees: Two Components
1. **Fixed fee** — always due, depends on action type:
- Infringement: EUR 14,600 (2026) / EUR 11,000 (pre-2026)
- Revocation: EUR 26,500 (2026) / EUR 20,000 (pre-2026) — flat, no value-based component
- Appeal: same fixed fees as first instance
2. **Value-based fee** — only for infringement-type actions when Streitwert > EUR 500,000:
- 19 brackets from EUR 0 (≤500k) to EUR 325,000 (>50M) — pre-2026
- ~32% increase in 2026 (exact table pending official publication)
- Revocation actions have NO value-based fee
3. **SME reduction**: 50% (2026) / 40% (pre-2026) on all court fees
### Recoverable Costs Ceilings (Attorney Fee Caps)
Per instance, the losing party reimburses up to:
| Streitwert | Ceiling |
|---|---|
| ≤ EUR 250,000 | EUR 38,000 |
| ≤ EUR 500,000 | EUR 56,000 |
| ≤ EUR 1,000,000 | EUR 112,000 |
| ≤ EUR 2,000,000 | EUR 200,000 |
| ≤ EUR 4,000,000 | EUR 400,000 |
| ≤ EUR 8,000,000 | EUR 600,000 |
| ≤ EUR 16,000,000 | EUR 800,000 |
| ≤ EUR 30,000,000 | EUR 1,200,000 |
| ≤ EUR 50,000,000 | EUR 1,500,000 |
| > EUR 50,000,000 | EUR 2,000,000 |
Court can raise ceiling by 50% (cases ≤1M) or 25% (150M). Expert/translator fees recoverable separately on top.
### Cost Comparison (Key Insight)
At EUR 3M Streitwert (infringement, 1st instance):
| | UPC (2026) | German LG |
|---|---|---|
| Court fees | ~EUR 41,000 | EUR 43,914 |
| Recoverable attorney costs | up to EUR 400,000 | ~EUR 100,388 |
| **Total cost risk** | **~EUR 441,000** | **~EUR 144,302** |
**Key takeaway:** UPC court fees are comparable to or lower than German courts. But recoverable attorney costs are 35x higher, making total cost risk at UPC roughly 23x German courts. This is the critical information patent litigators need.
### UPC Sources
- Rule 370 RoP (court fees), Rule 152 RoP (recoverable costs), Art. 69 UPCA
- UPC Administrative Committee fee table AC/05/08072022 (pre-2026)
- UPC Administrative Committee amendment, 4 Nov 2025 (2026 changes)
- Scale of Ceilings for Recoverable Costs: D-AC/10/24042023
- Maiwald MAIinsight April 2025 (practitioner analysis with verified figures)
---
## 8. Implementation Recommendations
### Phase 1: Core Calculator (MVP)
- Implement `fee-tables.ts` with all 5 GKG/RVG schedule versions as typed constants
- Implement `calculator.ts` with pure functions: `computeBaseFee(streitwert, isRVG, version)`, per-instance calculations, totals
- Build the UI as a single `"use client"` page at `/kosten/rechner`
- Card-based layout: global inputs at top, collapsible instance cards, results summary at bottom
- Fix all 3 bugs in the implementation (don't port them from Excel)
- German language UI throughout
### Phase 2: UPC Extension
- Add UPC fee data and calculation functions (bracket lookup, not step-based)
- Add UPC section to the calculator (separate card or tab)
- Add venue comparison view: side-by-side DE vs UPC for the same Streitwert
### Phase 3: Integration
- Allow saving calculations to a case (requires one backend endpoint)
- PDF export of cost breakdown
- Wire up Verfahrensbeendigung (termination type affects fee multipliers)
### Data Extraction TODO
Before implementation begins, the exact fee table values must be extracted from the Excel file. The analysis doc describes the structure but doesn't list every cell value. The implementer should either:
1. Open the Excel and manually read the Hebesaetze sheet values, or
2. Use a Python script with `openpyxl` to extract the ListObject data programmatically
This is critical — the older fee versions (2005, 2013, 2021) have different step sizes and increments.

View File

@@ -0,0 +1,391 @@
# UPC Fee Structure Research
> Research date: 2026-03-31
> Status: Complete (pre-2026 tables verified from official sources; 2026 amendments documented with confirmed changes)
> Purpose: Data for implementing a patent litigation cost calculator
## Overview
The UPC fee system consists of:
1. **Fixed fees** (always due, depend on action type)
2. **Value-based fees** (additional, for infringement-type actions with value > EUR 500,000)
3. **Recoverable costs ceilings** (caps on lawyer fees the losing party must reimburse)
Legal basis: Rule 370 RoP (court fees), Rule 152 RoP (recoverable costs), Art. 69 UPCA (cost allocation).
---
## 1. Fixed Court Fees (Court of First Instance)
### Pre-2026 Schedule (actions filed before 1 Jan 2026)
| Action Type | Fixed Fee |
|---|---|
| Infringement action | EUR 11,000 |
| Counterclaim for infringement | EUR 11,000 |
| Declaration of non-infringement | EUR 11,000 |
| Compensation for license of right | EUR 11,000 |
| Application to determine damages | EUR 3,000 |
| **Standalone revocation action** | **EUR 20,000** (flat, no value-based fee) |
| **Counterclaim for revocation** | **EUR 20,000** (flat, no value-based fee) |
| Application for provisional measures | EUR 11,000 |
| Order to preserve evidence | EUR 350 |
| Order for inspection | EUR 350 |
| Order to freeze assets | EUR 1,000 |
| Protective letter filing | EUR 200 |
| Protective letter extension (per 6 months) | EUR 100 |
| Action against EPO decision | EUR 1,000 |
| Re-establishment of rights | EUR 350 |
| Review case management order | EUR 300 |
| Set aside decision by default | EUR 1,000 |
### 2026 Schedule (actions filed from 1 Jan 2026)
~33% increase across the board:
| Action Type | Old Fee | New Fee (2026) | Change |
|---|---|---|---|
| Infringement action | EUR 11,000 | **EUR 14,600** | +33% |
| Counterclaim for infringement | EUR 11,000 | **EUR 14,600** | +33% |
| Declaration of non-infringement | EUR 11,000 | **EUR 14,600** | +33% |
| Standalone revocation action | EUR 20,000 | **EUR 26,500** | +33% |
| Counterclaim for revocation | EUR 20,000 | **EUR 26,500** | +33% |
| Application for provisional measures | EUR 11,000 | **EUR 14,600** | +33% |
| Application to determine damages | EUR 3,000 | **EUR 4,000** | +33% |
| Order to preserve evidence | EUR 350 | **EUR 5,000** | +1,329% |
| Order for inspection | EUR 350 | **EUR 5,000** | +1,329% |
| Order to freeze assets | EUR 1,000 | **EUR 5,000** | +400% |
| Protective letter filing | EUR 200 | **EUR 300** | +50% |
| Protective letter extension | EUR 100 | **EUR 130** | +30% |
| Application for rehearing | EUR 2,500 | **EUR 14,600** | +484% |
**Key 2026 change**: Provisional measures now also have a **value-based fee** (new). The value is deemed to be 2/3 of the value of the merits proceedings.
---
## 2. Value-Based Fees (Additional to Fixed Fee)
Applies to: infringement actions, counterclaim for infringement, declaration of non-infringement, compensation for license of right, application to determine damages.
Does NOT apply to: revocation actions (standalone or counterclaim) -- these are flat fee only.
### Pre-2026 Value-Based Fee Table
| Value of the Action | Additional Value-Based Fee |
|---|---|
| <= EUR 500,000 | EUR 0 |
| <= EUR 750,000 | EUR 2,500 |
| <= EUR 1,000,000 | EUR 4,000 |
| <= EUR 1,500,000 | EUR 8,000 |
| <= EUR 2,000,000 | EUR 13,000 |
| <= EUR 3,000,000 | EUR 20,000 |
| <= EUR 4,000,000 | EUR 26,000 |
| <= EUR 5,000,000 | EUR 32,000 |
| <= EUR 6,000,000 | EUR 39,000 |
| <= EUR 7,000,000 | EUR 46,000 |
| <= EUR 8,000,000 | EUR 52,000 |
| <= EUR 9,000,000 | EUR 58,000 |
| <= EUR 10,000,000 | EUR 65,000 |
| <= EUR 15,000,000 | EUR 75,000 |
| <= EUR 20,000,000 | EUR 100,000 |
| <= EUR 25,000,000 | EUR 125,000 |
| <= EUR 30,000,000 | EUR 150,000 |
| <= EUR 50,000,000 | EUR 250,000 |
| > EUR 50,000,000 | EUR 325,000 |
Source: Maiwald MAIinsight April 2025 (verified against commentedupc.com and official UPC fee table AC/05/08072022).
### 2026 Value-Based Fee Table (estimated)
The 2026 amendment increases value-based fees by ~32% at first instance and ~45% on appeal. Applying the 32% increase:
| Value of the Action | Old Fee | New Fee (est. ~32%) |
|---|---|---|
| <= EUR 500,000 | EUR 0 | EUR 0 |
| <= EUR 750,000 | EUR 2,500 | ~EUR 3,300 |
| <= EUR 1,000,000 | EUR 4,000 | ~EUR 5,300 |
| <= EUR 1,500,000 | EUR 8,000 | ~EUR 10,600 |
| <= EUR 2,000,000 | EUR 13,000 | ~EUR 17,200 |
| <= EUR 3,000,000 | EUR 20,000 | ~EUR 26,400 |
| <= EUR 5,000,000 | EUR 32,000 | ~EUR 42,200 |
| <= EUR 10,000,000 | EUR 65,000 | ~EUR 85,800 |
| <= EUR 30,000,000 | EUR 150,000 | ~EUR 198,000 |
| <= EUR 50,000,000 | EUR 250,000 | ~EUR 330,000 |
| > EUR 50,000,000 | EUR 325,000 | ~EUR 429,000 |
**Note**: The official consolidated 2026 fee table PDF was not extractable (403 on UPC website). The Maiwald blog confirms: for a dispute valued at EUR 5M, total court fees (fixed + value-based) went from EUR 43,000 to EUR 44,600, suggesting the 2026 value-based fee for <=5M is EUR 30,000 (i.e., 14,600 + 30,000 = 44,600). This is close to the ~32% estimate. When the exact 2026 table becomes available, these estimates should be replaced.
**Verified 2026 data point** (Secerna): For a typical infringement action valued at EUR 2,000,000, total court fees increase from EUR 24,000 to EUR 31,800. This means: new value-based fee for <=2M = 31,800 - 14,600 = EUR 17,200 (vs. old: 13,000 + 11,000 = 24,000).
---
## 3. Appeal Fees (Court of Appeal)
### Pre-2026
| Appeal Type | Fixed Fee | Value-Based Fee |
|---|---|---|
| Appeal on infringement action | EUR 11,000 | Same table as CFI |
| Appeal on counterclaim for infringement | EUR 11,000 | Same table as CFI |
| Appeal on non-infringement declaration | EUR 11,000 | Same table as CFI |
| Appeal on license compensation | EUR 11,000 | Same table as CFI |
| Appeal on damages determination | EUR 3,000 | Same table as CFI |
| Appeal on revocation action | EUR 20,000 | None |
| Appeal on counterclaim for revocation | Same as first instance | None |
| Appeal on provisional measures | EUR 11,000 | None |
| Appeal on other interlocutory orders | EUR 3,000 | None |
| Application for rehearing | EUR 2,500 | None |
| Appeal on cost decision | EUR 3,000 | None |
| Leave to appeal costs | EUR 1,500 | None |
| Discretionary review request | EUR 350 | None |
### 2026 Appeal Changes
- Fixed fees: ~33% increase (same as CFI)
- Value-based fees: ~45% increase (10% more than CFI increase)
- Revocation appeal: EUR 20,000 -> EUR 29,200 (+46%)
- Rehearing application: EUR 2,500 -> EUR 14,600 (+484%)
---
## 4. Recoverable Costs (Attorney Fee Ceilings)
Per Rule 152(2) RoP and the Administrative Committee's Scale of Ceilings. These are caps on what the winning party can recover from the losing party for legal representation costs. Apply **per instance**.
| Value of the Proceedings | Ceiling for Recoverable Costs |
|---|---|
| <= EUR 250,000 | EUR 38,000 |
| <= EUR 500,000 | EUR 56,000 |
| <= EUR 1,000,000 | EUR 112,000 |
| <= EUR 2,000,000 | EUR 200,000 |
| <= EUR 4,000,000 | EUR 400,000 |
| <= EUR 8,000,000 | EUR 600,000 |
| <= EUR 16,000,000 | EUR 800,000 |
| <= EUR 30,000,000 | EUR 1,200,000 |
| <= EUR 50,000,000 | EUR 1,500,000 |
| > EUR 50,000,000 | EUR 2,000,000 |
### Ceiling Adjustments
The court may **raise** the ceiling upon party request:
- Up to **50% increase** for cases valued up to EUR 1 million
- Up to **25% increase** for cases valued EUR 1-50 million
- Up to an **absolute cap of EUR 5 million** for cases valued above EUR 50 million
The court may **lower** the ceiling if it would threaten the economic existence of a party (SMEs, non-profits, universities, individuals).
### What is recoverable
- Lawyer fees (Rechtsanwalt)
- Patent attorney fees (Patentanwalt)
- Expert fees
- Witness costs
- Interpreter and translator fees
- Note: Expert/translator/witness fees are NOT subject to the ceiling -- they must be reasonable but are recoverable on top of the ceiling
---
## 5. SME / Micro-Enterprise Reductions
### Pre-2026
- Small and micro enterprises: **40% reduction** on all court fees (pay 60%)
- Conditions per Rule 370(8) RoP
### 2026
- Increased to **50% reduction** (pay 50%)
### Legal Aid
- Available in principle under Rule 375 et seq. RoP
---
## 6. Comparison: UPC vs. German National Courts
### German Court Fee Calculation (GKG)
German court fees are calculated using **Anlage 2 zu § 34 GKG**:
- Fee table covers Streitwert up to EUR 500,000 (base fee at 500k: EUR 4,138)
- Above EUR 500,000: fee increases by **EUR 210 per each additional EUR 50,000**
- This gives a "simple fee" (einfache Gebuehr)
- Actual court fees = simple fee x multiplier from Kostenverzeichnis
**Multipliers** for patent cases:
- LG infringement, 1st instance: **3.0x** simple fee
- OLG appeal (Berufung): **4.0x** simple fee
- BPatG nullity, 1st instance: **4.5x** simple fee (separate proceedings!)
- BGH nullity appeal: **6.0x** simple fee
### GKG Simple Fee Calculation for Key Streitwerte
Formula for Streitwert > 500,000: `4,138 + ceil((Streitwert - 500,000) / 50,000) * 210`
| Streitwert | Simple Fee | LG 1st (3.0x) | OLG Appeal (4.0x) |
|---|---|---|---|
| EUR 500,000 | EUR 4,138 | EUR 12,414 | EUR 16,552 |
| EUR 1,000,000 | EUR 6,238 | EUR 18,714 | EUR 24,952 |
| EUR 2,000,000 | EUR 10,438 | EUR 31,314 | EUR 41,752 |
| EUR 3,000,000 | EUR 14,638 | EUR 43,914 | EUR 58,552 |
| EUR 5,000,000 | EUR 23,038 | EUR 69,114 | EUR 92,152 |
| EUR 10,000,000 | EUR 44,038 | EUR 132,114 | EUR 176,152 |
| EUR 30,000,000 | EUR 128,038 | EUR 384,114 | EUR 512,152 |
| EUR 50,000,000 | EUR 212,038 | EUR 636,114 | EUR 848,152 |
Note: GKG was updated effective 01.06.2025 -- the increment changed from EUR 198 to EUR 210 per 50k.
### German Attorney Fees (RVG)
RVG fees use the same Streitwert table (§ 13 RVG with Anlage 2 GKG) but with their own multipliers:
- Verfahrensgebuehr (procedural fee): 1.3x
- Terminsgebuehr (hearing fee): 1.2x
- Einigungsgebuehr (settlement fee): 1.0x (if applicable)
- Patent attorney (Patentanwalt) adds same fees again
Recoverable costs in Germany = court fees + 1 Rechtsanwalt (RVG) + 1 Patentanwalt (RVG).
### Side-by-Side Comparison
#### Example: Infringement action, Streitwert EUR 1,000,000
| Cost Component | UPC (pre-2026) | UPC (2026) | Germany LG |
|---|---|---|---|
| Court fees | EUR 15,000 | ~EUR 19,900 | EUR 18,714 |
| Max recoverable attorney costs | EUR 112,000 | EUR 112,000 | ~EUR 30,000* |
| **Total cost risk (loser)** | **~EUR 127,000** | **~EUR 131,900** | **~EUR 48,714** |
#### Example: Infringement action, Streitwert EUR 3,000,000
| Cost Component | UPC (pre-2026) | UPC (2026) | Germany LG |
|---|---|---|---|
| Court fees | EUR 31,000 | ~EUR 41,000 | EUR 43,914 |
| Max recoverable attorney costs | EUR 400,000 | EUR 400,000 | ~EUR 100,388** |
| **Total cost risk (loser)** | **~EUR 431,000** | **~EUR 441,000** | **~EUR 144,302** |
*German RVG: 1x RA (1.3 VG + 1.2 TG) + 1x PA (same) + Auslagenpauschale + USt on Streitwert EUR 1M
**Maiwald comparison figure for EUR 3M (1x PA + 1x RA, including court fees, based on RVG)
#### Example: Infringement action, Streitwert EUR 10,000,000
| Cost Component | UPC (pre-2026) | UPC (2026) | Germany LG |
|---|---|---|---|
| Court fees | EUR 76,000 | ~EUR 100,400 | EUR 132,114 |
| Max recoverable attorney costs | EUR 600,000 | EUR 600,000 | ~EUR 222,000 |
| **Total cost risk (loser)** | **~EUR 676,000** | **~EUR 700,400** | **~EUR 354,114** |
### Key Insight
- **Court fees**: German courts are **more expensive** than UPC for court fees alone at moderate Streitwerte (EUR 1-5M). At very high Streitwerte (EUR 10M+), German courts become more expensive still.
- **Recoverable attorney costs**: UPC is **dramatically more expensive** -- ceilings are 3-5x higher than German RVG-based costs.
- **Total cost risk**: UPC total exposure is typically **2-3x German courts** for the same Streitwert, primarily driven by the high attorney cost ceilings.
- **Territorial scope**: UPC covers multiple countries in one action, so the higher cost may be justified by the broader geographic effect compared to a single German LG action.
---
## 7. Implementation Notes for Calculator
### Data structures needed
```typescript
// Value-based fee brackets (UPC)
interface FeeBracket {
maxValue: number; // upper bound of bracket (Infinity for last)
fee: number; // EUR amount
}
// Pre-2026 brackets
const upcValueFees2025: FeeBracket[] = [
{ maxValue: 500_000, fee: 0 },
{ maxValue: 750_000, fee: 2_500 },
{ maxValue: 1_000_000, fee: 4_000 },
{ maxValue: 1_500_000, fee: 8_000 },
{ maxValue: 2_000_000, fee: 13_000 },
{ maxValue: 3_000_000, fee: 20_000 },
{ maxValue: 4_000_000, fee: 26_000 },
{ maxValue: 5_000_000, fee: 32_000 },
{ maxValue: 6_000_000, fee: 39_000 },
{ maxValue: 7_000_000, fee: 46_000 },
{ maxValue: 8_000_000, fee: 52_000 },
{ maxValue: 9_000_000, fee: 58_000 },
{ maxValue: 10_000_000, fee: 65_000 },
{ maxValue: 15_000_000, fee: 75_000 },
{ maxValue: 20_000_000, fee: 100_000 },
{ maxValue: 25_000_000, fee: 125_000 },
{ maxValue: 30_000_000, fee: 150_000 },
{ maxValue: 50_000_000, fee: 250_000 },
{ maxValue: Infinity, fee: 325_000 },
];
// Recoverable costs ceilings
const upcRecoverableCosts: FeeBracket[] = [
{ maxValue: 250_000, fee: 38_000 },
{ maxValue: 500_000, fee: 56_000 },
{ maxValue: 1_000_000, fee: 112_000 },
{ maxValue: 2_000_000, fee: 200_000 },
{ maxValue: 4_000_000, fee: 400_000 },
{ maxValue: 8_000_000, fee: 600_000 },
{ maxValue: 16_000_000, fee: 800_000 },
{ maxValue: 30_000_000, fee: 1_200_000 },
{ maxValue: 50_000_000, fee: 1_500_000 },
{ maxValue: Infinity, fee: 2_000_000 },
];
// German GKG simple fee calculation
function gkgSimpleFee(streitwert: number): number {
if (streitwert <= 500_000) {
// Use lookup table from Anlage 2 GKG
return gkgLookupTable(streitwert);
}
// Above 500k: base + 210 EUR per 50k increment
const base = 4_138; // simple fee at 500k (as of 2025-06-01)
const excess = streitwert - 500_000;
const increments = Math.ceil(excess / 50_000);
return base + increments * 210;
}
// German court fee = simple fee * multiplier
// LG 1st instance infringement: 3.0x
// OLG appeal: 4.0x
// BPatG nullity 1st: 4.5x
// BGH nullity appeal: 6.0x
```
### Fixed fees by action type (for calculator dropdown)
```typescript
type ActionType =
| 'infringement'
| 'counterclaim_infringement'
| 'non_infringement'
| 'license_compensation'
| 'determine_damages'
| 'revocation_standalone'
| 'counterclaim_revocation'
| 'provisional_measures'
| 'preserve_evidence'
| 'inspection_order'
| 'freeze_assets'
| 'protective_letter'
| 'protective_letter_extension';
interface ActionFees {
fixedFee2025: number;
fixedFee2026: number;
hasValueBasedFee: boolean;
hasValueBasedFee2026: boolean; // provisional measures gained value-based in 2026
}
```
---
## Sources
- Maiwald MAIinsight Issue No. 2, April 2025: "Court fees and recoverable costs at the UPC" (PDF, authoritative practitioner analysis)
- UPC Official Table of Court Fees: AC/05/08072022 (original schedule)
- UPC Administrative Committee amendment decision, 4 Nov 2025 (2026 changes)
- commentedupc.com/table-of-court-fees/ (complete pre-2026 table)
- Scale of Ceilings for Recoverable Costs: D-AC/10/24042023
- GKG Anlage 2 zu § 34 (German court fee table, as of 01.06.2025)
- Secerna: "Major Financial Overhaul: Significant UPC Fee Increase" (2026 data points)
- Casalonga: "Unified Patent Court: Significant Increase in Court Costs in 2026"
- Bird & Bird: "Unified Patent Court Fees increase from 1 January 2026"
- Vossius: "Costs and Cost Risk in UPC Proceedings"
- Haug Partners: "A U.S. View on the UPC -- Part 5: Of Costs and Fees"

View File

@@ -1,61 +1,29 @@
"use client";
import { DeadlineCalculator } from "@/components/deadlines/DeadlineCalculator";
import { DeadlineWizard } from "@/components/deadlines/DeadlineWizard";
import { FristenRechner } from "@/components/deadlines/FristenRechner";
import { ArrowLeft } from "lucide-react";
import Link from "next/link";
import { useState } from "react";
export default function FristenrechnerPage() {
const [mode, setMode] = useState<"wizard" | "quick">("wizard");
return (
<div className="animate-fade-in space-y-4">
<div className="flex items-start justify-between">
<div>
<Link
href="/fristen"
className="mb-2 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
>
<ArrowLeft className="h-3.5 w-3.5" />
Zurueck zu Fristen
</Link>
<h1 className="text-lg font-semibold text-neutral-900">
Fristenbestimmung
</h1>
<p className="mt-0.5 text-sm text-neutral-500">
{mode === "wizard"
? "Vollstaendige Verfahrens-Timeline mit automatischer Fristenberechnung"
: "Schnellberechnung einzelner Fristen nach Verfahrensart"}
</p>
</div>
{/* Mode toggle */}
<div className="flex rounded-md border border-neutral-200 bg-neutral-50 p-0.5">
<button
onClick={() => setMode("wizard")}
className={`rounded px-3 py-1 text-xs font-medium transition-colors ${
mode === "wizard"
? "bg-white text-neutral-900 shadow-sm"
: "text-neutral-500 hover:text-neutral-700"
}`}
>
Verfahren
</button>
<button
onClick={() => setMode("quick")}
className={`rounded px-3 py-1 text-xs font-medium transition-colors ${
mode === "quick"
? "bg-white text-neutral-900 shadow-sm"
: "text-neutral-500 hover:text-neutral-700"
}`}
>
Schnell
</button>
</div>
<div>
<Link
href="/fristen"
className="mb-2 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
>
<ArrowLeft className="h-3.5 w-3.5" />
Zurueck zu Fristen
</Link>
<h1 className="text-lg font-semibold text-neutral-900">
Fristenrechner
</h1>
<p className="mt-0.5 text-sm text-neutral-500">
Verfahrensart waehlen, Fristen einsehen und Termine berechnen
</p>
</div>
{mode === "wizard" ? <DeadlineWizard /> : <DeadlineCalculator />}
<FristenRechner />
</div>
);
}

View File

@@ -0,0 +1,24 @@
"use client";
import { CostCalculator } from "@/components/costs/CostCalculator";
import { Calculator } from "lucide-react";
export default function KostenrechnerPage() {
return (
<div className="animate-fade-in space-y-4">
<div>
<div className="flex items-center gap-2">
<Calculator className="h-5 w-5 text-neutral-400" />
<h1 className="text-lg font-semibold text-neutral-900">
Patentprozesskostenrechner
</h1>
</div>
<p className="mt-0.5 text-sm text-neutral-500">
Berechnung der Verfahrenskosten für deutsche Patentverfahren und UPC
</p>
</div>
<CostCalculator />
</div>
);
}

View File

@@ -1,16 +1,14 @@
"use client";
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { api } from "@/lib/api";
import type { ProceedingType } from "@/lib/types";
const TYPE_OPTIONS = [
{ value: "", label: "-- Typ wählen --" },
{ value: "INF", label: "Verletzungsklage (INF)" },
{ value: "REV", label: "Widerruf (REV)" },
{ value: "CCR", label: "Einstweilige Verfügung (CCR)" },
{ value: "APP", label: "Berufung (APP)" },
{ value: "PI", label: "Vorläufiger Rechtsschutz (PI)" },
{ value: "ZPO_CIVIL", label: "ZPO Zivilverfahren" },
];
const JURISDICTION_LABELS: Record<string, string> = {
UPC: "UPC-Verfahren",
DE: "Deutsche Patentverfahren",
};
export interface CaseFormData {
case_number: string;
@@ -34,6 +32,10 @@ export function CaseForm({
isSubmitting,
submitLabel = "Akte anlegen",
}: CaseFormProps) {
const { data: proceedingTypes } = useQuery({
queryKey: ["proceeding-types"],
queryFn: () => api.get<ProceedingType[]>("/proceeding-types"),
});
const [form, setForm] = useState<CaseFormData>({
case_number: initialData?.case_number ?? "",
title: initialData?.title ?? "",
@@ -139,11 +141,24 @@ export function CaseForm({
onChange={(e) => update("case_type", e.target.value)}
className={inputClass}
>
{TYPE_OPTIONS.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
<option value="">-- Typ wählen --</option>
{(() => {
const grouped = new Map<string, ProceedingType[]>();
for (const pt of proceedingTypes ?? []) {
const key = pt.jurisdiction ?? "Sonstige";
if (!grouped.has(key)) grouped.set(key, []);
grouped.get(key)!.push(pt);
}
return Array.from(grouped.entries()).map(([jurisdiction, types]) => (
<optgroup key={jurisdiction} label={JURISDICTION_LABELS[jurisdiction] ?? jurisdiction}>
{types.map((pt) => (
<option key={pt.id} value={pt.code}>
{pt.name} ({pt.code})
</option>
))}
</optgroup>
));
})()}
</select>
</div>
<div>

View File

@@ -0,0 +1,323 @@
"use client";
import { useState, useMemo } from "react";
import type {
DEInstance,
UPCInstance,
InstanceConfig,
UPCConfig,
VatRate,
Jurisdiction,
CalculatorResult,
} from "@/lib/costs/types";
import { computeDEInstance, computeUPCInstance } from "@/lib/costs/calculator";
import {
DE_INFRINGEMENT_INSTANCES,
DE_NULLITY_INSTANCES,
} from "@/lib/costs/fee-tables";
import { InstanceCard } from "./InstanceCard";
import { UPCCard } from "./UPCCard";
import { CostSummary } from "./CostSummary";
import { CostComparison } from "./CostComparison";
const DEFAULT_DE_CONFIG: InstanceConfig = {
enabled: false,
feeVersion: "Aktuell",
numAttorneys: 1,
numPatentAttorneys: 1,
oralHearing: true,
numClients: 1,
};
const DEFAULT_UPC_CONFIG: UPCConfig = {
enabled: false,
feeVersion: "2026",
isSME: false,
includeRevocation: false,
};
function makeDefaultDEInstances(): Record<DEInstance, InstanceConfig> {
return {
LG: { ...DEFAULT_DE_CONFIG, enabled: true },
OLG: { ...DEFAULT_DE_CONFIG },
BGH_NZB: { ...DEFAULT_DE_CONFIG },
BGH_REV: { ...DEFAULT_DE_CONFIG },
BPatG: { ...DEFAULT_DE_CONFIG },
BGH_NULLITY: { ...DEFAULT_DE_CONFIG },
};
}
function makeDefaultUPCInstances(): Record<UPCInstance, UPCConfig> {
return {
UPC_FIRST: { ...DEFAULT_UPC_CONFIG, enabled: true },
UPC_APPEAL: { ...DEFAULT_UPC_CONFIG },
};
}
const STREITWERT_PRESETS = [
100_000, 250_000, 500_000, 1_000_000, 3_000_000, 5_000_000, 10_000_000, 30_000_000,
];
export function CostCalculator() {
const [streitwert, setStreitwert] = useState(1_000_000);
const [streitwertInput, setStreitwertInput] = useState("1.000.000");
const [vatRate, setVatRate] = useState<VatRate>(0.19);
const [jurisdiction, setJurisdiction] = useState<Jurisdiction>("DE");
const [deInstances, setDEInstances] = useState(makeDefaultDEInstances);
const [upcInstances, setUPCInstances] = useState(makeDefaultUPCInstances);
// Parse formatted number input
function handleStreitwertInput(raw: string) {
setStreitwertInput(raw);
const cleaned = raw.replace(/\./g, "").replace(/,/g, ".");
const num = parseFloat(cleaned);
if (!isNaN(num) && num >= 500 && num <= 30_000_000) {
setStreitwert(num);
}
}
function handleStreitwertBlur() {
setStreitwertInput(
new Intl.NumberFormat("de-DE", { maximumFractionDigits: 0 }).format(streitwert),
);
}
function handleSliderChange(value: number) {
setStreitwert(value);
setStreitwertInput(
new Intl.NumberFormat("de-DE", { maximumFractionDigits: 0 }).format(value),
);
}
// All DE metadata (infringement + nullity)
const allDEMeta = useMemo(
() => [...DE_INFRINGEMENT_INSTANCES, ...DE_NULLITY_INSTANCES],
[],
);
// Compute results reactively
const results: CalculatorResult = useMemo(() => {
const deResults = allDEMeta.map((meta) => {
const key = meta.key as DEInstance;
return computeDEInstance(streitwert, deInstances[key], meta, vatRate);
});
const upcFirst = computeUPCInstance(
streitwert,
upcInstances.UPC_FIRST,
"UPC_FIRST",
upcInstances.UPC_FIRST.includeRevocation,
);
const upcAppeal = computeUPCInstance(
streitwert,
upcInstances.UPC_APPEAL,
"UPC_APPEAL",
upcInstances.UPC_APPEAL.includeRevocation,
);
const upcResults = [upcFirst, upcAppeal];
const deTotal = deResults.reduce((sum, r) => sum + r.instanceTotal, 0);
const upcTotal = upcResults.reduce((sum, r) => sum + r.instanceTotal, 0);
return {
deResults,
upcResults,
deTotal: Math.round(deTotal * 100) / 100,
upcTotal: Math.round(upcTotal * 100) / 100,
grandTotal: Math.round((deTotal + upcTotal) * 100) / 100,
};
}, [streitwert, vatRate, deInstances, upcInstances, allDEMeta]);
const showDE = jurisdiction === "DE" || jurisdiction === "UPC";
const showUPC = jurisdiction === "UPC";
const showComparison =
showDE &&
showUPC &&
results.deResults.some((r) => r.enabled) &&
results.upcResults.some((r) => r.enabled);
return (
<div className="grid gap-6 xl:grid-cols-[1fr_1fr]">
{/* Left: Inputs */}
<div className="space-y-6">
{/* Global inputs card */}
<div className="rounded-lg border border-neutral-200 bg-white p-4">
<h2 className="mb-4 text-sm font-semibold text-neutral-900">
Grundeinstellungen
</h2>
{/* Streitwert */}
<div className="mb-4">
<label className="mb-1.5 block text-xs font-medium text-neutral-500">
Streitwert (EUR)
</label>
<div className="flex items-center gap-3">
<input
type="text"
inputMode="numeric"
value={streitwertInput}
onChange={(e) => handleStreitwertInput(e.target.value)}
onBlur={handleStreitwertBlur}
className="w-40 rounded-md border border-neutral-200 bg-white px-3 py-2 text-right text-sm font-medium text-neutral-900 tabular-nums focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
/>
<span className="text-xs text-neutral-400">EUR</span>
</div>
<input
type="range"
min={500}
max={30_000_000}
step={10000}
value={streitwert}
onChange={(e) => handleSliderChange(parseInt(e.target.value))}
className="mt-2 w-full accent-neutral-700"
/>
<div className="mt-1 flex justify-between text-[10px] text-neutral-400">
<span>500</span>
<span>30 Mio.</span>
</div>
{/* Presets */}
<div className="mt-2 flex flex-wrap gap-1.5">
{STREITWERT_PRESETS.map((v) => (
<button
key={v}
onClick={() => handleSliderChange(v)}
className={`rounded-full px-2.5 py-0.5 text-xs transition-colors ${
streitwert === v
? "bg-neutral-900 text-white"
: "bg-neutral-100 text-neutral-600 hover:bg-neutral-200"
}`}
>
{v >= 1_000_000
? `${(v / 1_000_000).toFixed(0)} Mio.`
: new Intl.NumberFormat("de-DE").format(v)}
</button>
))}
</div>
</div>
{/* VAT + Jurisdiction row */}
<div className="grid grid-cols-2 gap-4">
<div>
<label className="mb-1.5 block text-xs font-medium text-neutral-500">
Umsatzsteuer
</label>
<select
value={vatRate}
onChange={(e) => setVatRate(parseFloat(e.target.value) as VatRate)}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
>
<option value={0.19}>19%</option>
<option value={0.16}>16%</option>
<option value={0}>0% (netto)</option>
</select>
</div>
<div>
<label className="mb-1.5 block text-xs font-medium text-neutral-500">
Gerichtsbarkeit
</label>
<div className="flex rounded-md border border-neutral-200">
<button
onClick={() => setJurisdiction("DE")}
className={`flex-1 rounded-l-md px-3 py-2 text-sm font-medium transition-colors ${
jurisdiction === "DE"
? "bg-neutral-900 text-white"
: "bg-white text-neutral-600 hover:bg-neutral-50"
}`}
>
DE
</button>
<button
onClick={() => setJurisdiction("UPC")}
className={`flex-1 rounded-r-md px-3 py-2 text-sm font-medium transition-colors ${
jurisdiction === "UPC"
? "bg-blue-600 text-white"
: "bg-white text-neutral-600 hover:bg-neutral-50"
}`}
>
DE + UPC
</button>
</div>
</div>
</div>
</div>
{/* DE instances */}
{showDE && (
<div className="space-y-3">
<h3 className="text-xs font-semibold uppercase tracking-wide text-neutral-500">
Verletzungsverfahren
</h3>
{DE_INFRINGEMENT_INSTANCES.map((meta) => (
<InstanceCard
key={meta.key}
meta={meta}
config={deInstances[meta.key as DEInstance]}
onChange={(c) =>
setDEInstances((prev) => ({ ...prev, [meta.key as DEInstance]: c }))
}
/>
))}
<h3 className="mt-4 text-xs font-semibold uppercase tracking-wide text-neutral-500">
Nichtigkeitsverfahren
</h3>
{DE_NULLITY_INSTANCES.map((meta) => (
<InstanceCard
key={meta.key}
meta={meta}
config={deInstances[meta.key as DEInstance]}
onChange={(c) =>
setDEInstances((prev) => ({ ...prev, [meta.key as DEInstance]: c }))
}
/>
))}
</div>
)}
{/* UPC instances */}
{showUPC && (
<div className="space-y-3">
<h3 className="text-xs font-semibold uppercase tracking-wide text-blue-600">
Einheitliches Patentgericht (UPC)
</h3>
<UPCCard
label="UPC (1. Instanz)"
config={upcInstances.UPC_FIRST}
onChange={(c) =>
setUPCInstances((prev) => ({ ...prev, UPC_FIRST: c }))
}
showRevocation
/>
<UPCCard
label="UPC (Berufung)"
config={upcInstances.UPC_APPEAL}
onChange={(c) =>
setUPCInstances((prev) => ({ ...prev, UPC_APPEAL: c }))
}
/>
</div>
)}
</div>
{/* Right: Results */}
<div className="space-y-4 xl:sticky xl:top-6 xl:self-start">
<CostSummary
deResults={showDE ? results.deResults : []}
upcResults={showUPC ? results.upcResults : []}
deTotal={showDE ? results.deTotal : 0}
upcTotal={showUPC ? results.upcTotal : 0}
/>
{showComparison && (
<CostComparison deTotal={results.deTotal} upcTotal={results.upcTotal} />
)}
{/* Print note */}
<p className="text-center text-[10px] text-neutral-300 print:hidden">
Alle Angaben ohne Gewähr. Berechnung basiert auf GKG/RVG/PatKostG bzw. UPC-Gebührenordnung.
</p>
</div>
</div>
);
}

View File

@@ -0,0 +1,83 @@
"use client";
import { formatEUR } from "@/lib/costs/calculator";
interface Props {
deTotal: number;
upcTotal: number;
deLabel?: string;
upcLabel?: string;
}
export function CostComparison({
deTotal,
upcTotal,
deLabel = "Deutsche Gerichte",
upcLabel = "UPC",
}: Props) {
if (deTotal === 0 && upcTotal === 0) return null;
const maxValue = Math.max(deTotal, upcTotal);
const dePercent = maxValue > 0 ? (deTotal / maxValue) * 100 : 0;
const upcPercent = maxValue > 0 ? (upcTotal / maxValue) * 100 : 0;
const diff = upcTotal - deTotal;
const diffPercent = deTotal > 0 ? ((diff / deTotal) * 100).toFixed(0) : "—";
return (
<div className="rounded-lg border border-neutral-200 bg-white p-4">
<h3 className="mb-4 text-sm font-medium text-neutral-900">
Kostenvergleich DE vs. UPC
</h3>
<div className="space-y-4">
{/* DE bar */}
<div>
<div className="mb-1 flex items-baseline justify-between">
<span className="text-xs font-medium text-neutral-600">{deLabel}</span>
<span className="text-sm font-semibold text-neutral-900 tabular-nums">
{formatEUR(deTotal)}
</span>
</div>
<div className="h-8 w-full overflow-hidden rounded-md bg-neutral-100">
<div
className="h-full rounded-md bg-neutral-700 transition-all duration-500"
style={{ width: `${Math.max(dePercent, 2)}%` }}
/>
</div>
</div>
{/* UPC bar */}
<div>
<div className="mb-1 flex items-baseline justify-between">
<span className="text-xs font-medium text-blue-600">{upcLabel}</span>
<span className="text-sm font-semibold text-neutral-900 tabular-nums">
{formatEUR(upcTotal)}
</span>
</div>
<div className="h-8 w-full overflow-hidden rounded-md bg-blue-50">
<div
className="h-full rounded-md bg-blue-600 transition-all duration-500"
style={{ width: `${Math.max(upcPercent, 2)}%` }}
/>
</div>
</div>
{/* Difference */}
{deTotal > 0 && upcTotal > 0 && (
<div className="flex items-center justify-between rounded-md bg-neutral-50 px-3 py-2 text-xs">
<span className="text-neutral-500">Differenz</span>
<span
className={`font-medium tabular-nums ${
diff > 0 ? "text-red-600" : diff < 0 ? "text-green-600" : "text-neutral-600"
}`}
>
{diff > 0 ? "+" : ""}
{formatEUR(diff)} ({diff > 0 ? "+" : ""}
{diffPercent}%)
</span>
</div>
)}
</div>
</div>
);
}

View File

@@ -0,0 +1,229 @@
"use client";
import type { InstanceResult, UPCInstanceResult } from "@/lib/costs/types";
import { formatEUR } from "@/lib/costs/calculator";
interface Props {
deResults: InstanceResult[];
upcResults: UPCInstanceResult[];
deTotal: number;
upcTotal: number;
}
function DEInstanceBreakdown({ result }: { result: InstanceResult }) {
if (!result.enabled) return null;
return (
<div className="rounded-lg border border-neutral-200 bg-white p-4">
<h4 className="mb-3 text-sm font-medium text-neutral-900">{result.label}</h4>
<div className="space-y-2 text-sm">
{/* Court fees */}
<div className="flex justify-between">
<span className="text-neutral-600">Gerichtskosten</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.gerichtskosten)}
</span>
</div>
{/* Attorney fees */}
{result.perAttorney && (
<div>
<div className="flex justify-between">
<span className="text-neutral-600">
Rechtsanwaltskosten
{result.attorneyTotal !== result.perAttorney.totalBrutto && (
<span className="text-neutral-400">
{" "}
({Math.round(result.attorneyTotal / result.perAttorney.totalBrutto)}x)
</span>
)}
</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.attorneyTotal)}
</span>
</div>
{/* Detail breakdown */}
<div className="ml-4 mt-1 space-y-0.5 text-xs text-neutral-400">
<div className="flex justify-between">
<span>Verfahrensgebühr</span>
<span className="tabular-nums">{formatEUR(result.perAttorney.verfahrensgebuehr)}</span>
</div>
{result.perAttorney.erhoehungsgebuehr > 0 && (
<div className="flex justify-between">
<span>Erhöhungsgebühr</span>
<span className="tabular-nums">{formatEUR(result.perAttorney.erhoehungsgebuehr)}</span>
</div>
)}
{result.perAttorney.terminsgebuehr > 0 && (
<div className="flex justify-between">
<span>Terminsgebühr</span>
<span className="tabular-nums">{formatEUR(result.perAttorney.terminsgebuehr)}</span>
</div>
)}
<div className="flex justify-between">
<span>Auslagenpauschale</span>
<span className="tabular-nums">{formatEUR(result.perAttorney.auslagenpauschale)}</span>
</div>
{result.perAttorney.vat > 0 && (
<div className="flex justify-between">
<span>USt.</span>
<span className="tabular-nums">{formatEUR(result.perAttorney.vat)}</span>
</div>
)}
</div>
</div>
)}
{/* Patent attorney fees */}
{result.perPatentAttorney && (
<div>
<div className="flex justify-between">
<span className="text-neutral-600">
Patentanwaltskosten
{result.patentAttorneyTotal !== result.perPatentAttorney.totalBrutto && (
<span className="text-neutral-400">
{" "}
({Math.round(result.patentAttorneyTotal / result.perPatentAttorney.totalBrutto)}x)
</span>
)}
</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.patentAttorneyTotal)}
</span>
</div>
</div>
)}
{/* Instance total */}
<div className="flex justify-between border-t border-neutral-100 pt-2">
<span className="font-medium text-neutral-900">Zwischensumme</span>
<span className="font-semibold text-neutral-900 tabular-nums">
{formatEUR(result.instanceTotal)}
</span>
</div>
</div>
</div>
);
}
function UPCInstanceBreakdown({ result }: { result: UPCInstanceResult }) {
if (!result.enabled) return null;
return (
<div className="rounded-lg border border-blue-200 bg-blue-50/30 p-4">
<h4 className="mb-3 text-sm font-medium text-neutral-900">{result.label}</h4>
<div className="space-y-2 text-sm">
<div className="flex justify-between">
<span className="text-neutral-600">Festgebühr</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.fixedFee)}
</span>
</div>
{result.valueBasedFee > 0 && (
<div className="flex justify-between">
<span className="text-neutral-600">Streitwertabhängige Gebühr</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.valueBasedFee)}
</span>
</div>
)}
<div className="flex justify-between">
<span className="text-neutral-600">Gerichtskosten gesamt</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.courtFeesTotal)}
</span>
</div>
{result.courtFeesSME !== result.courtFeesTotal && (
<div className="flex justify-between text-blue-700">
<span>Gerichtskosten (KMU)</span>
<span className="font-medium tabular-nums">{formatEUR(result.courtFeesSME)}</span>
</div>
)}
<div className="flex justify-between">
<span className="text-neutral-600">Erstattungsfähige Kosten (Deckel)</span>
<span className="font-medium text-neutral-900 tabular-nums">
{formatEUR(result.recoverableCostsCeiling)}
</span>
</div>
<div className="flex justify-between border-t border-blue-100 pt-2">
<span className="font-medium text-neutral-900">Gesamtkostenrisiko</span>
<span className="font-semibold text-neutral-900 tabular-nums">
{formatEUR(result.instanceTotal)}
</span>
</div>
</div>
</div>
);
}
export function CostSummary({ deResults, upcResults, deTotal, upcTotal }: Props) {
const hasDE = deResults.some((r) => r.enabled);
const hasUPC = upcResults.some((r) => r.enabled);
if (!hasDE && !hasUPC) {
return (
<div className="flex items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-neutral-50 p-8">
<p className="text-sm text-neutral-400">
Mindestens eine Instanz aktivieren, um Kosten zu berechnen.
</p>
</div>
);
}
return (
<div className="space-y-4">
{/* DE results */}
{hasDE && (
<div className="space-y-3">
<h3 className="text-sm font-medium text-neutral-500 uppercase tracking-wide">
Deutsche Gerichte
</h3>
{deResults.map((r) => (
<DEInstanceBreakdown key={r.instance} result={r} />
))}
{deResults.filter((r) => r.enabled).length > 1 && (
<div className="flex justify-between rounded-lg bg-neutral-900 px-4 py-3 text-white">
<span className="text-sm font-medium">Gesamtkosten DE</span>
<span className="text-sm font-semibold tabular-nums">{formatEUR(deTotal)}</span>
</div>
)}
</div>
)}
{/* UPC results */}
{hasUPC && (
<div className="space-y-3">
<h3 className="text-sm font-medium text-blue-600 uppercase tracking-wide">
Einheitliches Patentgericht (UPC)
</h3>
{upcResults.map((r) => (
<UPCInstanceBreakdown key={r.instance} result={r} />
))}
{upcResults.filter((r) => r.enabled).length > 1 && (
<div className="flex justify-between rounded-lg bg-blue-900 px-4 py-3 text-white">
<span className="text-sm font-medium">Gesamtkosten UPC</span>
<span className="text-sm font-semibold tabular-nums">{formatEUR(upcTotal)}</span>
</div>
)}
</div>
)}
{/* Grand total when both */}
{hasDE && hasUPC && (
<div className="mt-2 flex justify-between rounded-lg border-2 border-neutral-900 px-4 py-3">
<span className="text-sm font-semibold text-neutral-900">Gesamtkosten</span>
<span className="text-sm font-bold text-neutral-900 tabular-nums">
{formatEUR(deTotal + upcTotal)}
</span>
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,168 @@
"use client";
import { ChevronDown, ChevronRight } from "lucide-react";
import { useState } from "react";
import type { InstanceConfig, FeeScheduleVersion, InstanceMeta } from "@/lib/costs/types";
import { FEE_SCHEDULES } from "@/lib/costs/fee-tables";
interface Props {
meta: InstanceMeta;
config: InstanceConfig;
onChange: (config: InstanceConfig) => void;
}
const VERSION_OPTIONS: { value: FeeScheduleVersion; label: string }[] = Object.entries(
FEE_SCHEDULES,
).map(([key, entry]) => ({
value: key as FeeScheduleVersion,
label: entry.label,
}));
export function InstanceCard({ meta, config, onChange }: Props) {
const [expanded, setExpanded] = useState(config.enabled);
function update(patch: Partial<InstanceConfig>) {
onChange({ ...config, ...patch });
}
return (
<div
className={`rounded-lg border transition-colors ${
config.enabled
? "border-neutral-200 bg-white"
: "border-neutral-100 bg-neutral-50"
}`}
>
{/* Header */}
<div className="flex items-center gap-3 px-4 py-3">
<label className="flex items-center gap-2">
<input
type="checkbox"
checked={config.enabled}
onChange={(e) => {
update({ enabled: e.target.checked });
if (e.target.checked) setExpanded(true);
}}
className="h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500"
/>
<span
className={`text-sm font-medium ${
config.enabled ? "text-neutral-900" : "text-neutral-400"
}`}
>
{meta.label}
</span>
</label>
{config.enabled && (
<button
onClick={() => setExpanded(!expanded)}
className="ml-auto rounded p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600"
>
{expanded ? (
<ChevronDown className="h-4 w-4" />
) : (
<ChevronRight className="h-4 w-4" />
)}
</button>
)}
</div>
{/* Settings */}
{config.enabled && expanded && (
<div className="border-t border-neutral-100 px-4 pb-4 pt-3">
<div className="grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3">
{/* Fee version */}
<div>
<label className="mb-1 block text-xs text-neutral-500">
Gebührentabelle
</label>
<select
value={config.feeVersion}
onChange={(e) =>
update({ feeVersion: e.target.value as FeeScheduleVersion })
}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
>
{VERSION_OPTIONS.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
</div>
{/* Number of attorneys */}
<div>
<label className="mb-1 block text-xs text-neutral-500">
Rechtsanwälte
</label>
<input
type="number"
min={0}
max={10}
value={config.numAttorneys}
onChange={(e) =>
update({ numAttorneys: Math.max(0, parseInt(e.target.value) || 0) })
}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
/>
</div>
{/* Number of patent attorneys */}
{meta.hasPatentAttorneys && (
<div>
<label className="mb-1 block text-xs text-neutral-500">
Patentanwälte
</label>
<input
type="number"
min={0}
max={10}
value={config.numPatentAttorneys}
onChange={(e) =>
update({
numPatentAttorneys: Math.max(0, parseInt(e.target.value) || 0),
})
}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
/>
</div>
)}
{/* Oral hearing */}
<div className="flex items-end">
<label className="flex items-center gap-2 pb-1.5">
<input
type="checkbox"
checked={config.oralHearing}
onChange={(e) => update({ oralHearing: e.target.checked })}
className="h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500"
/>
<span className="text-sm text-neutral-700">
Mündliche Verhandlung
</span>
</label>
</div>
{/* Number of clients */}
<div>
<label className="mb-1 block text-xs text-neutral-500">
Mandanten
</label>
<input
type="number"
min={1}
max={20}
value={config.numClients}
onChange={(e) =>
update({ numClients: Math.max(1, parseInt(e.target.value) || 1) })
}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
/>
</div>
</div>
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,115 @@
"use client";
import { ChevronDown, ChevronRight } from "lucide-react";
import { useState } from "react";
import type { UPCConfig } from "@/lib/costs/types";
interface Props {
label: string;
config: UPCConfig;
onChange: (config: UPCConfig) => void;
showRevocation?: boolean;
}
export function UPCCard({ label, config, onChange, showRevocation }: Props) {
const [expanded, setExpanded] = useState(config.enabled);
function update(patch: Partial<UPCConfig>) {
onChange({ ...config, ...patch });
}
return (
<div
className={`rounded-lg border transition-colors ${
config.enabled
? "border-blue-200 bg-blue-50/30"
: "border-neutral-100 bg-neutral-50"
}`}
>
<div className="flex items-center gap-3 px-4 py-3">
<label className="flex items-center gap-2">
<input
type="checkbox"
checked={config.enabled}
onChange={(e) => {
update({ enabled: e.target.checked });
if (e.target.checked) setExpanded(true);
}}
className="h-4 w-4 rounded border-neutral-300 text-blue-600 focus:ring-blue-500"
/>
<span
className={`text-sm font-medium ${
config.enabled ? "text-neutral-900" : "text-neutral-400"
}`}
>
{label}
</span>
</label>
{config.enabled && (
<button
onClick={() => setExpanded(!expanded)}
className="ml-auto rounded p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600"
>
{expanded ? (
<ChevronDown className="h-4 w-4" />
) : (
<ChevronRight className="h-4 w-4" />
)}
</button>
)}
</div>
{config.enabled && expanded && (
<div className="border-t border-blue-100 px-4 pb-4 pt-3">
<div className="grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3">
<div>
<label className="mb-1 block text-xs text-neutral-500">
Gebührenordnung
</label>
<select
value={config.feeVersion}
onChange={(e) =>
update({ feeVersion: e.target.value as "pre2026" | "2026" })
}
className="w-full rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm text-neutral-900 focus:border-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-400"
>
<option value="2026">UPC (ab 2026)</option>
<option value="pre2026">UPC (vor 2026)</option>
</select>
</div>
<div className="flex items-end">
<label className="flex items-center gap-2 pb-1.5">
<input
type="checkbox"
checked={config.isSME}
onChange={(e) => update({ isSME: e.target.checked })}
className="h-4 w-4 rounded border-neutral-300 text-blue-600 focus:ring-blue-500"
/>
<span className="text-sm text-neutral-700">KMU-Ermäßigung</span>
</label>
</div>
{showRevocation && (
<div className="flex items-end">
<label className="flex items-center gap-2 pb-1.5">
<input
type="checkbox"
checked={config.includeRevocation}
onChange={(e) =>
update({ includeRevocation: e.target.checked })
}
className="h-4 w-4 rounded border-neutral-300 text-blue-600 focus:ring-blue-500"
/>
<span className="text-sm text-neutral-700">
Nichtigkeitswiderklage
</span>
</label>
</div>
)}
</div>
</div>
)}
</div>
);
}

View File

@@ -35,7 +35,9 @@ const inputClass =
export function DeadlineCalculator() {
const [proceedingType, setProceedingType] = useState("");
const [triggerDate, setTriggerDate] = useState("");
const [triggerDate, setTriggerDate] = useState(
new Date().toISOString().split("T")[0],
);
const { data: proceedingTypes, isLoading: typesLoading } = useQuery({
queryKey: ["proceeding-types"],
@@ -49,13 +51,28 @@ export function DeadlineCalculator() {
}) => api.post<CalculateResponse>("/deadlines/calculate", params),
});
// Auto-calculate when proceeding type changes (using current trigger date)
function doCalculate(type: string, date: string) {
if (!type || !date) return;
calculateMutation.mutate({
proceeding_type: type,
trigger_event_date: date,
});
}
function handleProceedingChange(newType: string) {
setProceedingType(newType);
doCalculate(newType, triggerDate);
}
function handleDateChange(newDate: string) {
setTriggerDate(newDate);
if (proceedingType) doCalculate(proceedingType, newDate);
}
function handleCalculate(e: React.FormEvent) {
e.preventDefault();
if (!proceedingType || !triggerDate) return;
calculateMutation.mutate({
proceeding_type: proceedingType,
trigger_event_date: triggerDate,
});
doCalculate(proceedingType, triggerDate);
}
const results = calculateMutation.data;
@@ -78,16 +95,48 @@ export function DeadlineCalculator() {
</label>
<select
value={proceedingType}
onChange={(e) => setProceedingType(e.target.value)}
onChange={(e) => handleProceedingChange(e.target.value)}
disabled={typesLoading}
className={inputClass}
>
<option value="">Bitte wählen...</option>
{proceedingTypes?.map((pt) => (
<option key={pt.id} value={pt.code}>
{pt.name} ({pt.code})
</option>
))}
{(() => {
const types = proceedingTypes ?? [];
const categoryLabels: Record<string, string> = {
hauptverfahren: "Hauptverfahren",
im_verfahren: "Verfahren im Verfahren",
rechtsbehelf: "Rechtsbehelfe",
};
const jurisdictionLabels: Record<string, string> = {
UPC: "UPC",
DE: "Deutsche Patentverfahren",
};
// Group by jurisdiction + category
const groups: { key: string; label: string; items: typeof types }[] = [];
const seen = new Set<string>();
for (const pt of types) {
const j = pt.jurisdiction ?? "Sonstige";
const c = pt.category ?? "hauptverfahren";
const key = `${j}::${c}`;
if (!seen.has(key)) {
seen.add(key);
const jLabel = jurisdictionLabels[j] ?? j;
const cLabel = categoryLabels[c] ?? c;
const label = j === "DE" ? jLabel : `${jLabel}${cLabel}`;
groups.push({ key, label, items: [] });
}
groups.find((g) => g.key === key)!.items.push(pt);
}
return groups.map((g) => (
<optgroup key={g.key} label={g.label}>
{g.items.map((pt) => (
<option key={pt.id} value={pt.code}>
{pt.name}
</option>
))}
</optgroup>
));
})()}
</select>
</div>
<div>
@@ -97,7 +146,7 @@ export function DeadlineCalculator() {
<input
type="date"
value={triggerDate}
onChange={(e) => setTriggerDate(e.target.value)}
onChange={(e) => handleDateChange(e.target.value)}
className={inputClass}
/>
</div>

View File

@@ -276,32 +276,53 @@ export function DeadlineWizard() {
)}
</div>
<div className="mt-4 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6">
<div className="mt-4 space-y-4">
{typesLoading ? (
<div className="col-span-full flex justify-center py-4">
<div className="flex justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
</div>
) : (
proceedingTypes?.map((pt) => (
<button
key={pt.id}
onClick={() => handleTypeSelect(pt.code)}
className={`rounded-lg border px-3 py-2.5 text-left transition-all ${
selectedType === pt.code
? "border-neutral-900 bg-neutral-900 text-white shadow-sm"
: "border-neutral-200 bg-white text-neutral-700 hover:border-neutral-400 hover:bg-neutral-50"
}`}
>
<div className="flex items-center gap-1.5">
<div
className="h-2 w-2 rounded-full"
style={{ backgroundColor: pt.default_color }}
/>
<span className="text-xs font-semibold">{pt.code}</span>
(() => {
const grouped = new Map<string, ProceedingType[]>();
for (const pt of proceedingTypes ?? []) {
const key = pt.jurisdiction ?? "Sonstige";
if (!grouped.has(key)) grouped.set(key, []);
grouped.get(key)!.push(pt);
}
const labels: Record<string, string> = {
UPC: "UPC-Verfahren",
DE: "Deutsche Patentverfahren",
};
return Array.from(grouped.entries()).map(([jurisdiction, types]) => (
<div key={jurisdiction}>
<div className="mb-2 text-xs font-medium text-neutral-500">
{labels[jurisdiction] ?? jurisdiction}
</div>
<div className="grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6">
{types.map((pt) => (
<button
key={pt.id}
onClick={() => handleTypeSelect(pt.code)}
className={`rounded-lg border px-3 py-2.5 text-left transition-all ${
selectedType === pt.code
? "border-neutral-900 bg-neutral-900 text-white shadow-sm"
: "border-neutral-200 bg-white text-neutral-700 hover:border-neutral-400 hover:bg-neutral-50"
}`}
>
<div className="flex items-center gap-1.5">
<div
className="h-2 w-2 rounded-full"
style={{ backgroundColor: pt.default_color }}
/>
<span className="text-xs font-semibold">{pt.code}</span>
</div>
<div className="mt-1 text-xs leading-tight opacity-80">{pt.name}</div>
</button>
))}
</div>
</div>
<div className="mt-1 text-xs leading-tight opacity-80">{pt.name}</div>
</button>
))
));
})()
)}
</div>
</div>
@@ -444,7 +465,7 @@ export function DeadlineWizard() {
<Scale className="h-6 w-6 text-neutral-400" />
</div>
<p className="mt-3 text-sm font-medium text-neutral-700">
UPC-Fristenbestimmung
Fristenbestimmung
</p>
<p className="mt-1 max-w-sm text-xs text-neutral-500">
Waehlen Sie die Verfahrensart und geben Sie das Datum des ausloesenden Ereignisses ein.

View File

@@ -0,0 +1,602 @@
"use client";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { api } from "@/lib/api";
import type {
ProceedingType,
RuleTreeNode,
CalculateResponse,
Case,
} from "@/lib/types";
import { format, parseISO } from "date-fns";
import { de } from "date-fns/locale";
import {
Scale,
Users,
Gavel,
FileText,
Clock,
CalendarDays,
AlertTriangle,
ChevronRight,
RotateCcw,
Loader2,
Check,
FolderOpen,
} from "lucide-react";
import { useState, useMemo } from "react";
import { toast } from "sonner";
// --- Helpers ---
function formatDuration(value: number, unit: string): string {
if (value === 0) return "";
const labels: Record<string, string> = {
days: value === 1 ? "Tag" : "Tage",
weeks: value === 1 ? "Woche" : "Wochen",
months: value === 1 ? "Monat" : "Monate",
};
return `${value} ${labels[unit] || unit}`;
}
function getPartyIcon(party?: string) {
switch (party) {
case "claimant":
return <Scale className="h-3.5 w-3.5" />;
case "defendant":
return <Users className="h-3.5 w-3.5" />;
case "court":
return <Gavel className="h-3.5 w-3.5" />;
default:
return <FileText className="h-3.5 w-3.5" />;
}
}
function getPartyLabel(party?: string): string {
switch (party) {
case "claimant":
return "Klaeger";
case "defendant":
return "Beklagter";
case "court":
return "Gericht";
case "both":
return "Beide Parteien";
default:
return "";
}
}
interface FlatRule {
id: string;
name: string;
duration_value: number;
duration_unit: string;
rule_code?: string;
primary_party?: string;
event_type?: string;
is_mandatory: boolean;
deadline_notes?: string;
description?: string;
depth: number;
}
function flattenRuleTree(nodes: RuleTreeNode[], depth = 0): FlatRule[] {
const result: FlatRule[] = [];
for (const node of nodes) {
result.push({
id: node.id,
name: node.name,
duration_value: node.duration_value,
duration_unit: node.duration_unit,
rule_code: node.rule_code,
primary_party: node.primary_party,
event_type: node.event_type,
is_mandatory: node.is_mandatory,
deadline_notes: node.deadline_notes,
description: node.description,
depth,
});
if (node.children && node.children.length > 0) {
result.push(...flattenRuleTree(node.children, depth + 1));
}
}
return result;
}
// --- Group labels ---
const categoryLabels: Record<string, string> = {
hauptverfahren: "Hauptverfahren",
im_verfahren: "Verfahren im Verfahren",
rechtsbehelf: "Rechtsbehelfe",
};
const jurisdictionLabels: Record<string, string> = {
UPC: "UPC",
DE: "Deutsche Patentverfahren",
};
interface TypeGroup {
key: string;
label: string;
items: ProceedingType[];
}
function groupProceedingTypes(types: ProceedingType[]): TypeGroup[] {
const groups: TypeGroup[] = [];
const seen = new Set<string>();
for (const pt of types) {
const j = pt.jurisdiction ?? "Sonstige";
const c = pt.category ?? "hauptverfahren";
const key = `${j}::${c}`;
if (!seen.has(key)) {
seen.add(key);
const jLabel = jurisdictionLabels[j] ?? j;
const cLabel = categoryLabels[c] ?? c;
const label = j === "DE" ? jLabel : `${jLabel}${cLabel}`;
groups.push({ key, label, items: [] });
}
groups.find((g) => g.key === key)!.items.push(pt);
}
return groups;
}
// --- Main Component ---
export function FristenRechner() {
const [selectedType, setSelectedType] = useState<string | null>(null);
const [expandedRuleId, setExpandedRuleId] = useState<string | null>(null);
const [triggerDate, setTriggerDate] = useState(
new Date().toISOString().split("T")[0],
);
const [calcResults, setCalcResults] = useState<
Record<string, { due_date: string; original_due_date: string; was_adjusted: boolean }>
>({});
const [savingRuleId, setSavingRuleId] = useState<string | null>(null);
const [selectedCaseId, setSelectedCaseId] = useState<string>("");
const queryClient = useQueryClient();
// Fetch proceeding types
const { data: proceedingTypes, isLoading: typesLoading } = useQuery({
queryKey: ["proceeding-types"],
queryFn: () => api.get<ProceedingType[]>("/proceeding-types"),
});
// Fetch rule tree when type is selected
const { data: ruleTree, isLoading: rulesLoading } = useQuery({
queryKey: ["deadline-rules", selectedType],
queryFn: () => api.get<RuleTreeNode[]>(`/deadline-rules/${selectedType}`),
enabled: !!selectedType,
});
// Fetch cases for "save to case"
const { data: cases } = useQuery({
queryKey: ["cases"],
queryFn: () => api.get<Case[]>("/cases"),
enabled: savingRuleId !== null,
});
// Calculate single deadline
const calcMutation = useMutation({
mutationFn: (params: {
proceeding_type: string;
trigger_event_date: string;
selected_rule_ids: string[];
}) => api.post<CalculateResponse>("/deadlines/calculate", params),
onSuccess: (data, variables) => {
if (data.deadlines && data.deadlines.length > 0) {
const d = data.deadlines[0];
setCalcResults((prev) => ({
...prev,
[variables.selected_rule_ids[0]]: {
due_date: d.due_date,
original_due_date: d.original_due_date,
was_adjusted: d.was_adjusted,
},
}));
}
},
});
// Save deadline to case
const saveMutation = useMutation({
mutationFn: (params: {
caseId: string;
deadline: { title: string; due_date: string; original_due_date?: string; rule_code?: string };
}) =>
api.post(`/cases/${params.caseId}/deadlines`, {
title: params.deadline.title,
due_date: params.deadline.due_date,
original_due_date: params.deadline.original_due_date,
rule_code: params.deadline.rule_code,
source: "calculator",
}),
onSuccess: () => {
toast.success("Frist auf Akte gespeichert");
queryClient.invalidateQueries({ queryKey: ["deadlines"] });
setSavingRuleId(null);
setSelectedCaseId("");
},
onError: () => {
toast.error("Fehler beim Speichern");
},
});
// Flat list of rules
const flatRules = useMemo(() => {
if (!ruleTree) return [];
return flattenRuleTree(ruleTree);
}, [ruleTree]);
// Groups
const groups = useMemo(() => {
if (!proceedingTypes) return [];
return groupProceedingTypes(proceedingTypes);
}, [proceedingTypes]);
const selectedPT = proceedingTypes?.find((pt) => pt.code === selectedType);
function handleTypeSelect(code: string) {
setSelectedType(code);
setExpandedRuleId(null);
setCalcResults({});
setSavingRuleId(null);
}
function handleReset() {
setSelectedType(null);
setExpandedRuleId(null);
setCalcResults({});
setSavingRuleId(null);
setSelectedCaseId("");
}
function handleRuleClick(ruleId: string) {
if (expandedRuleId === ruleId) {
setExpandedRuleId(null);
return;
}
setExpandedRuleId(ruleId);
setSavingRuleId(null);
// Auto-calculate with current date
if (selectedType && triggerDate) {
calcMutation.mutate({
proceeding_type: selectedType,
trigger_event_date: triggerDate,
selected_rule_ids: [ruleId],
});
}
}
function handleDateChange(ruleId: string, date: string) {
setTriggerDate(date);
if (selectedType && date) {
calcMutation.mutate({
proceeding_type: selectedType,
trigger_event_date: date,
selected_rule_ids: [ruleId],
});
}
}
return (
<div className="space-y-6">
{/* Step 1: Proceeding Type Cards */}
<div>
<div className="mb-4 flex items-center justify-between">
<h2 className="text-sm font-medium text-neutral-900">
Verfahrensart waehlen
</h2>
{selectedType && (
<button
onClick={handleReset}
className="flex items-center gap-1 text-xs text-neutral-500 hover:text-neutral-700"
>
<RotateCcw className="h-3 w-3" />
Zuruecksetzen
</button>
)}
</div>
{typesLoading ? (
<div className="flex justify-center py-8">
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
</div>
) : (
<div className="space-y-5">
{groups.map((group) => (
<div key={group.key}>
<div className="mb-2 text-xs font-medium uppercase tracking-wide text-neutral-400">
{group.label}
</div>
<div className="flex flex-wrap gap-2">
{group.items.map((pt) => {
const isSelected = selectedType === pt.code;
return (
<button
key={pt.id}
onClick={() => handleTypeSelect(pt.code)}
className={`rounded-lg border px-3 py-2 text-sm transition-all ${
isSelected
? "border-neutral-900 bg-neutral-900 text-white shadow-sm"
: "border-neutral-200 bg-white text-neutral-700 hover:border-neutral-300 hover:shadow-sm"
}`}
>
{pt.name}
</button>
);
})}
</div>
</div>
))}
</div>
)}
</div>
{/* Step 2: Deadline Rules for Selected Type */}
{selectedType && (
<div className="animate-fade-in">
<div className="mb-3 flex items-center justify-between">
<div>
<h2 className="text-sm font-medium text-neutral-900">
Fristen: {selectedPT?.name}
</h2>
{flatRules.length > 0 && (
<p className="mt-0.5 text-xs text-neutral-500">
{flatRules.length} Fristen &mdash; Frist anklicken zum Berechnen
</p>
)}
</div>
</div>
{rulesLoading ? (
<div className="flex justify-center py-8">
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
</div>
) : flatRules.length === 0 ? (
<div className="rounded-lg border border-dashed border-neutral-300 bg-white px-6 py-8 text-center text-sm text-neutral-500">
Keine Fristenregeln fuer diesen Verfahrenstyp hinterlegt.
</div>
) : (
<div className="rounded-lg border border-neutral-200 bg-white divide-y divide-neutral-100">
{flatRules.map((rule, i) => {
const isExpanded = expandedRuleId === rule.id;
const result = calcResults[rule.id];
const duration = formatDuration(rule.duration_value, rule.duration_unit);
return (
<div key={rule.id}>
{/* Rule Row */}
<button
onClick={() => handleRuleClick(rule.id)}
className={`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-neutral-50 ${
isExpanded ? "bg-neutral-50" : ""
}`}
style={{ paddingLeft: `${16 + rule.depth * 20}px` }}
>
{/* Timeline dot + connector */}
<div className="flex flex-col items-center">
<div
className={`h-2.5 w-2.5 shrink-0 rounded-full border-2 ${
isExpanded
? "border-neutral-900 bg-neutral-900"
: "border-neutral-300 bg-white"
}`}
/>
{i < flatRules.length - 1 && (
<div className="mt-0.5 h-3 w-px bg-neutral-200" />
)}
</div>
{/* Content */}
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="text-sm font-medium text-neutral-900">
{rule.name}
</span>
{!rule.is_mandatory && (
<span className="rounded bg-neutral-100 px-1 py-0.5 text-[10px] text-neutral-400">
optional
</span>
)}
</div>
<div className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-neutral-500">
{duration && (
<span className="flex items-center gap-0.5">
<Clock className="h-3 w-3" />
{duration}
</span>
)}
{rule.rule_code && (
<>
<span className="text-neutral-300">&middot;</span>
<span className="rounded bg-neutral-100 px-1 py-0.5 font-mono text-[10px]">
{rule.rule_code}
</span>
</>
)}
{rule.primary_party && (
<>
<span className="text-neutral-300">&middot;</span>
<span className="flex items-center gap-0.5">
{getPartyIcon(rule.primary_party)}
{getPartyLabel(rule.primary_party)}
</span>
</>
)}
</div>
</div>
{/* Chevron */}
<ChevronRight
className={`h-4 w-4 shrink-0 text-neutral-400 transition-transform ${
isExpanded ? "rotate-90" : ""
}`}
/>
</button>
{/* Step 3: Expanded Calculation Panel */}
{isExpanded && (
<div className="border-t border-neutral-100 bg-neutral-50 px-4 py-4 animate-fade-in"
style={{ paddingLeft: `${36 + rule.depth * 20}px` }}
>
<div className="flex flex-col gap-4 sm:flex-row sm:items-end">
{/* Date picker */}
<div>
<label className="mb-1 block text-xs font-medium text-neutral-500">
Ausloesedatum
</label>
<input
type="date"
value={triggerDate}
onChange={(e) =>
handleDateChange(rule.id, e.target.value)
}
className="rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-900 outline-none transition-colors focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
/>
</div>
{/* Result */}
{calcMutation.isPending &&
calcMutation.variables?.selected_rule_ids[0] === rule.id ? (
<div className="flex items-center gap-2 text-sm text-neutral-500">
<Loader2 className="h-4 w-4 animate-spin" />
Berechne...
</div>
) : result ? (
<div className="flex items-center gap-4">
<div>
<div className="text-xs font-medium text-neutral-500">
Fristende
</div>
<div className="flex items-center gap-2">
<CalendarDays className="h-4 w-4 text-neutral-700" />
<span className="text-lg font-semibold tabular-nums text-neutral-900">
{format(
parseISO(result.due_date),
"dd. MMMM yyyy",
{ locale: de },
)}
</span>
</div>
{result.was_adjusted && (
<div className="mt-0.5 flex items-center gap-1 text-xs text-amber-600">
<AlertTriangle className="h-3 w-3" />
Angepasst (Original:{" "}
{format(
parseISO(result.original_due_date),
"dd.MM.yyyy",
)}
)
</div>
)}
</div>
{/* Save to case button */}
<button
onClick={(e) => {
e.stopPropagation();
setSavingRuleId(
savingRuleId === rule.id ? null : rule.id,
);
}}
className="flex items-center gap-1 rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-xs font-medium text-neutral-700 transition-colors hover:bg-neutral-50"
>
<FolderOpen className="h-3.5 w-3.5" />
Auf Akte
</button>
</div>
) : null}
</div>
{/* Save to case panel */}
{savingRuleId === rule.id && result && (
<div className="mt-3 flex items-center gap-2 animate-fade-in">
<select
value={selectedCaseId}
onChange={(e) =>
setSelectedCaseId(e.target.value)
}
className="flex-1 rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-xs text-neutral-900 outline-none focus:border-neutral-400"
>
<option value="">Akte waehlen...</option>
{cases
?.filter((c) => c.status !== "closed")
.map((c) => (
<option key={c.id} value={c.id}>
{c.case_number} {c.title}
</option>
))}
</select>
<button
disabled={
!selectedCaseId || saveMutation.isPending
}
onClick={() => {
saveMutation.mutate({
caseId: selectedCaseId,
deadline: {
title: rule.name,
due_date: result.due_date,
original_due_date: result.was_adjusted
? result.original_due_date
: undefined,
rule_code: rule.rule_code,
},
});
}}
className="flex items-center gap-1 rounded-md bg-neutral-900 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-neutral-800 disabled:opacity-50"
>
{saveMutation.isPending ? (
<Loader2 className="h-3 w-3 animate-spin" />
) : (
<Check className="h-3 w-3" />
)}
Speichern
</button>
</div>
)}
{/* Notes */}
{rule.deadline_notes && (
<p className="mt-2 text-xs italic text-neutral-400">
{rule.deadline_notes}
</p>
)}
</div>
)}
</div>
);
})}
</div>
)}
</div>
)}
{/* Empty state */}
{!selectedType && !typesLoading && (
<div className="flex flex-col items-center rounded-lg border border-dashed border-neutral-300 bg-white px-6 py-12 text-center">
<div className="rounded-xl bg-neutral-100 p-3">
<Scale className="h-6 w-6 text-neutral-400" />
</div>
<p className="mt-3 text-sm font-medium text-neutral-700">
Fristenrechner
</p>
<p className="mt-1 max-w-sm text-xs text-neutral-500">
Waehlen Sie oben eine Verfahrensart, um alle zugehoerigen Fristen
anzuzeigen und einzelne Termine zu berechnen.
</p>
</div>
)}
{/* Calculation error */}
{calcMutation.isError && (
<div className="flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
<AlertTriangle className="h-4 w-4 shrink-0" />
Fehler bei der Berechnung. Bitte Eingaben pruefen.
</div>
)}
</div>
);
}

View File

@@ -9,6 +9,7 @@ import {
Calendar,
Brain,
BarChart3,
Calculator,
Settings,
Menu,
X,
@@ -29,6 +30,7 @@ const allNavigation: NavItem[] = [
{ name: "Fristen", href: "/fristen", icon: Clock },
{ name: "Termine", href: "/termine", icon: Calendar },
{ name: "Berichte", href: "/berichte", icon: BarChart3 },
{ name: "Kostenrechner", href: "/kosten/rechner", icon: Calculator },
{ name: "AI Analyse", href: "/ai/extract", icon: Brain, permission: "ai_extraction" },
{ name: "Einstellungen", href: "/einstellungen", icon: Settings, permission: "manage_settings" },
];

View File

@@ -164,7 +164,7 @@ export function TeamSettings() {
</div>
<div>
<p className="text-sm font-medium text-neutral-900">
{member.user_id.slice(0, 8)}...
{member.email || member.user_id.slice(0, 8) + "..."}
</p>
<p className="text-xs text-neutral-500">{roleInfo.label}</p>
</div>

View File

@@ -0,0 +1,276 @@
import type {
FeeScheduleVersion,
FeeBracket,
InstanceConfig,
InstanceMeta,
InstanceResult,
AttorneyBreakdown,
VatRate,
UPCConfig,
UPCInstance,
UPCInstanceResult,
UPCFeeBracket,
UPCRecoverableCost,
} from "./types";
import { isAlias } from "./types";
import { FEE_SCHEDULES, CONSTANTS, UPC_FEES } from "./fee-tables";
/** Resolve alias to actual fee schedule brackets */
function resolveBrackets(version: FeeScheduleVersion): FeeBracket[] {
const entry = FEE_SCHEDULES[version];
if (isAlias(entry)) {
return resolveBrackets(entry.aliasOf);
}
return entry.brackets;
}
/**
* Compute the base fee (1.0x) using the step-based accumulator algorithm.
* @param isRVG - true for RVG (attorney), false for GKG (court)
*/
export function computeBaseFee(
streitwert: number,
isRVG: boolean,
version: FeeScheduleVersion,
): number {
const brackets = resolveBrackets(version);
let remaining = streitwert;
let fee = 0;
let lowerBound = 0;
for (const bracket of brackets) {
const [upperBound, stepSize, gkgInc, rvgInc] = bracket;
const increment = isRVG ? rvgInc : gkgInc;
const bracketSize = upperBound === Infinity ? remaining : upperBound - lowerBound;
const portionInBracket = Math.min(remaining, bracketSize);
if (portionInBracket <= 0) break;
// First bracket: the base fee comes from the first step
if (lowerBound === 0) {
// The minimum fee is the increment for the first bracket
fee += increment;
const stepsAfterFirst = Math.max(0, Math.ceil((portionInBracket - stepSize) / stepSize));
fee += stepsAfterFirst * increment;
} else {
const steps = Math.ceil(portionInBracket / stepSize);
fee += steps * increment;
}
remaining -= portionInBracket;
lowerBound = upperBound;
if (remaining <= 0) break;
}
return fee;
}
/** Compute attorney fees for a single attorney */
function computeAttorneyFees(
streitwert: number,
version: FeeScheduleVersion,
vgFactor: number,
tgFactor: number,
oralHearing: boolean,
numClients: number,
vatRate: VatRate,
): AttorneyBreakdown {
const baseRVG = computeBaseFee(streitwert, true, version);
const verfahrensgebuehr = vgFactor * baseRVG;
const erhoehungsgebuehr =
numClients > 1
? Math.min((numClients - 1) * CONSTANTS.erhoehungsfaktor, CONSTANTS.erhoehungsfaktorMax) *
baseRVG
: 0;
const terminsgebuehr = oralHearing ? tgFactor * baseRVG : 0;
const auslagenpauschale = CONSTANTS.auslagenpauschale;
const subtotalNetto =
verfahrensgebuehr + erhoehungsgebuehr + terminsgebuehr + auslagenpauschale;
const vat = subtotalNetto * vatRate;
const totalBrutto = subtotalNetto + vat;
return {
verfahrensgebuehr: Math.round(verfahrensgebuehr * 100) / 100,
erhoehungsgebuehr: Math.round(erhoehungsgebuehr * 100) / 100,
terminsgebuehr: Math.round(terminsgebuehr * 100) / 100,
auslagenpauschale,
subtotalNetto: Math.round(subtotalNetto * 100) / 100,
vat: Math.round(vat * 100) / 100,
totalBrutto: Math.round(totalBrutto * 100) / 100,
};
}
/** Compute all costs for a single DE instance */
export function computeDEInstance(
streitwert: number,
config: InstanceConfig,
meta: InstanceMeta,
vatRate: VatRate,
): InstanceResult {
if (!config.enabled) {
return {
instance: meta.key,
label: meta.label,
enabled: false,
gerichtskosten: 0,
perAttorney: null,
attorneyTotal: 0,
perPatentAttorney: null,
patentAttorneyTotal: 0,
instanceTotal: 0,
};
}
// Court fees: base fee × factor
// PatKostG (BPatG nullity) uses the same step-based lookup from the GKG column
const baseFee = computeBaseFee(streitwert, false, config.feeVersion);
const gerichtskosten =
meta.feeBasis === "fixed"
? meta.fixedCourtFee ?? 0
: Math.round(meta.courtFeeFactor * baseFee * 100) / 100;
// Attorney (RA) fees
const perAttorney =
config.numAttorneys > 0
? computeAttorneyFees(
streitwert,
config.feeVersion,
meta.raVGFactor,
meta.raTGFactor,
config.oralHearing,
config.numClients,
vatRate,
)
: null;
const attorneyTotal = perAttorney
? Math.round(perAttorney.totalBrutto * config.numAttorneys * 100) / 100
: 0;
// Patent attorney (PA) fees
const perPatentAttorney =
meta.hasPatentAttorneys && config.numPatentAttorneys > 0
? computeAttorneyFees(
streitwert,
config.feeVersion,
meta.paVGFactor,
meta.paTGFactor,
config.oralHearing,
config.numClients,
vatRate,
)
: null;
const patentAttorneyTotal = perPatentAttorney
? Math.round(perPatentAttorney.totalBrutto * config.numPatentAttorneys * 100) / 100
: 0;
const instanceTotal =
Math.round((gerichtskosten + attorneyTotal + patentAttorneyTotal) * 100) / 100;
return {
instance: meta.key,
label: meta.label,
enabled: true,
gerichtskosten,
perAttorney,
attorneyTotal,
perPatentAttorney,
patentAttorneyTotal,
instanceTotal,
};
}
/** Look up a value-based fee from UPC bracket table */
function lookupUPCValueFee(streitwert: number, brackets: readonly UPCFeeBracket[]): number {
for (const bracket of brackets) {
if (bracket.maxValue === null || streitwert <= bracket.maxValue) {
return bracket.fee;
}
}
return brackets[brackets.length - 1].fee;
}
/** Look up recoverable costs ceiling */
function lookupRecoverableCosts(
streitwert: number,
table: readonly UPCRecoverableCost[],
): number {
for (const entry of table) {
if (entry.maxValue === null || streitwert <= entry.maxValue) {
return entry.ceiling;
}
}
return table[table.length - 1].ceiling;
}
/** Compute UPC instance costs */
export function computeUPCInstance(
streitwert: number,
config: UPCConfig,
instance: UPCInstance,
includeRevocation: boolean,
): UPCInstanceResult {
const label =
instance === "UPC_FIRST" ? "UPC (1. Instanz)" : "UPC (Berufung)";
if (!config.enabled) {
return {
instance,
label,
enabled: false,
fixedFee: 0,
valueBasedFee: 0,
courtFeesTotal: 0,
courtFeesSME: 0,
recoverableCostsCeiling: 0,
instanceTotal: 0,
};
}
const feeData = UPC_FEES[config.feeVersion];
// Fixed fee for infringement
let fixedFee = feeData.fixedFees.infringement;
// Add revocation fee if counterclaim included
if (includeRevocation) {
fixedFee += feeData.fixedFees.revocation;
}
// Value-based fee (only for infringement-type actions with Streitwert > 500k)
const valueBasedFee = lookupUPCValueFee(streitwert, feeData.valueBased);
const courtFeesTotal = fixedFee + valueBasedFee;
const courtFeesSME = Math.round(courtFeesTotal * (1 - feeData.smReduction));
const recoverableCostsCeiling = lookupRecoverableCosts(
streitwert,
feeData.recoverableCosts,
);
// Total cost risk = court fees + recoverable costs ceiling
const instanceTotal = (config.isSME ? courtFeesSME : courtFeesTotal) + recoverableCostsCeiling;
return {
instance,
label,
enabled: true,
fixedFee,
valueBasedFee,
courtFeesTotal,
courtFeesSME,
recoverableCostsCeiling,
instanceTotal,
};
}
/** Format a number as EUR with thousand separators */
export function formatEUR(value: number): string {
return new Intl.NumberFormat("de-DE", {
style: "currency",
currency: "EUR",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(value);
}

View File

@@ -0,0 +1,239 @@
import type {
FeeScheduleVersion,
FeeScheduleEntry,
InstanceMeta,
UPCFeeBracket,
UPCRecoverableCost,
} from "./types";
// Fee schedules: [upperBound, stepSize, gkgIncrement, rvgIncrement]
export const FEE_SCHEDULES: Record<FeeScheduleVersion, FeeScheduleEntry> = {
"2005": {
label: "GKG/RVG 2006-09-01",
validFrom: "2006-09-01",
brackets: [
[300, 300, 25, 25],
[1500, 300, 10, 20],
[5000, 500, 8, 28],
[10000, 1000, 15, 37],
[25000, 3000, 23, 40],
[50000, 5000, 29, 72],
[200000, 15000, 100, 77],
[500000, 30000, 150, 118],
[Infinity, 50000, 150, 150],
],
},
"2013": {
label: "GKG/RVG 2013-08-01",
validFrom: "2013-08-01",
brackets: [
[500, 300, 35, 45],
[2000, 500, 18, 35],
[10000, 1000, 19, 51],
[25000, 3000, 26, 46],
[50000, 5000, 35, 75],
[200000, 15000, 120, 85],
[500000, 30000, 179, 120],
[Infinity, 50000, 180, 150],
],
},
"2021": {
label: "GKG/RVG 2021-01-01",
validFrom: "2021-01-01",
brackets: [
[500, 300, 38, 49],
[2000, 500, 20, 39],
[10000, 1000, 21, 56],
[25000, 3000, 29, 52],
[50000, 5000, 38, 81],
[200000, 15000, 132, 94],
[500000, 30000, 198, 132],
[Infinity, 50000, 198, 165],
],
},
"2025": {
label: "GKG/RVG 2025-06-01",
validFrom: "2025-06-01",
brackets: [
[500, 300, 40, 51.5],
[2000, 500, 21, 41.5],
[10000, 1000, 22.5, 59.5],
[25000, 3000, 30.5, 55],
[50000, 5000, 40.5, 86],
[200000, 15000, 140, 99.5],
[500000, 30000, 210, 140],
[Infinity, 50000, 210, 175],
],
},
Aktuell: {
label: "Aktuell (= 2025-06-01)",
validFrom: "2025-06-01",
aliasOf: "2025",
},
};
export const CONSTANTS = {
erhoehungsfaktor: 0.3,
erhoehungsfaktorMax: 2.0,
auslagenpauschale: 20,
} as const;
// DE instance metadata with fee multipliers
export const DE_INFRINGEMENT_INSTANCES: InstanceMeta[] = [
{
key: "LG",
label: "LG (Verletzung 1. Instanz)",
courtFeeFactor: 3.0,
feeBasis: "GKG",
raVGFactor: 1.3,
raTGFactor: 1.2,
paVGFactor: 1.3,
paTGFactor: 1.2,
hasPatentAttorneys: true,
},
{
key: "OLG",
label: "OLG (Berufung)",
courtFeeFactor: 4.0,
feeBasis: "GKG",
raVGFactor: 1.6,
raTGFactor: 1.2,
paVGFactor: 1.6,
paTGFactor: 1.2,
hasPatentAttorneys: true,
},
{
key: "BGH_NZB",
label: "BGH (Nichtzulassungsbeschwerde)",
courtFeeFactor: 2.0,
feeBasis: "GKG",
raVGFactor: 2.3,
raTGFactor: 1.2,
paVGFactor: 1.6,
paTGFactor: 1.2,
hasPatentAttorneys: true,
},
{
key: "BGH_REV",
label: "BGH (Revision)",
courtFeeFactor: 5.0,
feeBasis: "GKG",
raVGFactor: 2.3,
raTGFactor: 1.5,
paVGFactor: 1.6,
paTGFactor: 1.5,
hasPatentAttorneys: true,
},
];
export const DE_NULLITY_INSTANCES: InstanceMeta[] = [
{
key: "BPatG",
label: "BPatG (Nichtigkeitsverfahren)",
courtFeeFactor: 4.5,
feeBasis: "PatKostG",
raVGFactor: 1.3,
raTGFactor: 1.2,
paVGFactor: 1.3,
paTGFactor: 1.2,
hasPatentAttorneys: true,
},
{
key: "BGH_NULLITY",
label: "BGH (Nichtigkeitsberufung)",
courtFeeFactor: 6.0,
feeBasis: "GKG",
raVGFactor: 1.6,
raTGFactor: 1.5,
paVGFactor: 1.6,
paTGFactor: 1.5,
hasPatentAttorneys: true,
},
];
// UPC fee data
export const UPC_FEES = {
pre2026: {
label: "UPC (vor 2026)",
fixedFees: {
infringement: 11000,
revocation: 20000,
},
valueBased: [
{ maxValue: 500000, fee: 0 },
{ maxValue: 750000, fee: 2500 },
{ maxValue: 1000000, fee: 4000 },
{ maxValue: 1500000, fee: 8000 },
{ maxValue: 2000000, fee: 13000 },
{ maxValue: 3000000, fee: 20000 },
{ maxValue: 4000000, fee: 26000 },
{ maxValue: 5000000, fee: 32000 },
{ maxValue: 6000000, fee: 39000 },
{ maxValue: 7000000, fee: 46000 },
{ maxValue: 8000000, fee: 52000 },
{ maxValue: 9000000, fee: 58000 },
{ maxValue: 10000000, fee: 65000 },
{ maxValue: 15000000, fee: 75000 },
{ maxValue: 20000000, fee: 100000 },
{ maxValue: 25000000, fee: 125000 },
{ maxValue: 30000000, fee: 150000 },
{ maxValue: 50000000, fee: 250000 },
{ maxValue: null, fee: 325000 },
] as UPCFeeBracket[],
recoverableCosts: [
{ maxValue: 250000, ceiling: 38000 },
{ maxValue: 500000, ceiling: 56000 },
{ maxValue: 1000000, ceiling: 112000 },
{ maxValue: 2000000, ceiling: 200000 },
{ maxValue: 4000000, ceiling: 400000 },
{ maxValue: 8000000, ceiling: 600000 },
{ maxValue: 16000000, ceiling: 800000 },
{ maxValue: 30000000, ceiling: 1200000 },
{ maxValue: 50000000, ceiling: 1500000 },
{ maxValue: null, ceiling: 2000000 },
] as UPCRecoverableCost[],
smReduction: 0.4,
},
"2026": {
label: "UPC (ab 2026)",
fixedFees: {
infringement: 14600,
revocation: 26500,
},
// Estimated ~32% increase on pre-2026 values
valueBased: [
{ maxValue: 500000, fee: 0 },
{ maxValue: 750000, fee: 3300 },
{ maxValue: 1000000, fee: 5300 },
{ maxValue: 1500000, fee: 10600 },
{ maxValue: 2000000, fee: 17200 },
{ maxValue: 3000000, fee: 26400 },
{ maxValue: 4000000, fee: 34300 },
{ maxValue: 5000000, fee: 42200 },
{ maxValue: 6000000, fee: 51500 },
{ maxValue: 7000000, fee: 60700 },
{ maxValue: 8000000, fee: 68600 },
{ maxValue: 9000000, fee: 76600 },
{ maxValue: 10000000, fee: 85800 },
{ maxValue: 15000000, fee: 99000 },
{ maxValue: 20000000, fee: 132000 },
{ maxValue: 25000000, fee: 165000 },
{ maxValue: 30000000, fee: 198000 },
{ maxValue: 50000000, fee: 330000 },
{ maxValue: null, fee: 429000 },
] as UPCFeeBracket[],
recoverableCosts: [
{ maxValue: 250000, ceiling: 38000 },
{ maxValue: 500000, ceiling: 56000 },
{ maxValue: 1000000, ceiling: 112000 },
{ maxValue: 2000000, ceiling: 200000 },
{ maxValue: 4000000, ceiling: 400000 },
{ maxValue: 8000000, ceiling: 600000 },
{ maxValue: 16000000, ceiling: 800000 },
{ maxValue: 30000000, ceiling: 1200000 },
{ maxValue: 50000000, ceiling: 1500000 },
{ maxValue: null, ceiling: 2000000 },
] as UPCRecoverableCost[],
smReduction: 0.5,
},
} as const;

View File

@@ -0,0 +1,132 @@
// Fee calculation types for the Patentprozesskostenrechner
export type FeeScheduleVersion = "2005" | "2013" | "2021" | "2025" | "Aktuell";
export type Jurisdiction = "DE" | "UPC";
export type VatRate = 0 | 0.16 | 0.19;
/** [upperBound, stepSize, gkgIncrement, rvgIncrement] */
export type FeeBracket = [number, number, number, number];
export interface FeeSchedule {
label: string;
validFrom: string;
brackets: FeeBracket[];
}
export interface FeeScheduleAlias {
label: string;
validFrom: string;
aliasOf: FeeScheduleVersion;
}
export type FeeScheduleEntry = FeeSchedule | FeeScheduleAlias;
export function isAlias(entry: FeeScheduleEntry): entry is FeeScheduleAlias {
return "aliasOf" in entry;
}
// DE instance types
export type DEInfringementInstance = "LG" | "OLG" | "BGH_NZB" | "BGH_REV";
export type DENullityInstance = "BPatG" | "BGH_NULLITY";
export type DEInstance = DEInfringementInstance | DENullityInstance;
// UPC instance types
export type UPCInstance = "UPC_FIRST" | "UPC_APPEAL";
export type Instance = DEInstance | UPCInstance;
export interface InstanceConfig {
enabled: boolean;
feeVersion: FeeScheduleVersion;
numAttorneys: number;
numPatentAttorneys: number;
oralHearing: boolean;
numClients: number;
}
export interface UPCConfig {
enabled: boolean;
feeVersion: "pre2026" | "2026";
isSME: boolean;
includeRevocation: boolean;
}
export interface CalculatorInputs {
streitwert: number;
vatRate: VatRate;
jurisdiction: Jurisdiction;
// DE instances
deInstances: Record<DEInstance, InstanceConfig>;
// UPC instances
upcInstances: Record<UPCInstance, UPCConfig>;
}
// Output types
export interface AttorneyBreakdown {
verfahrensgebuehr: number;
erhoehungsgebuehr: number;
terminsgebuehr: number;
auslagenpauschale: number;
subtotalNetto: number;
vat: number;
totalBrutto: number;
}
export interface InstanceResult {
instance: Instance;
label: string;
enabled: boolean;
gerichtskosten: number;
perAttorney: AttorneyBreakdown | null;
attorneyTotal: number;
perPatentAttorney: AttorneyBreakdown | null;
patentAttorneyTotal: number;
instanceTotal: number;
}
export interface UPCInstanceResult {
instance: UPCInstance;
label: string;
enabled: boolean;
fixedFee: number;
valueBasedFee: number;
courtFeesTotal: number;
courtFeesSME: number;
recoverableCostsCeiling: number;
instanceTotal: number;
}
export interface CalculatorResult {
deResults: InstanceResult[];
upcResults: UPCInstanceResult[];
deTotal: number;
upcTotal: number;
grandTotal: number;
}
// Instance metadata for display and calculation
export interface InstanceMeta {
key: Instance;
label: string;
courtFeeFactor: number;
feeBasis: "GKG" | "PatKostG" | "fixed";
fixedCourtFee?: number;
raVGFactor: number;
raTGFactor: number;
paVGFactor: number;
paTGFactor: number;
hasPatentAttorneys: boolean;
}
export interface UPCFeeBracket {
maxValue: number | null;
fee: number;
}
export interface UPCRecoverableCost {
maxValue: number | null;
ceiling: number;
}

View File

@@ -15,6 +15,7 @@ export interface UserTenant {
user_id: string;
tenant_id: string;
role: string;
email: string;
created_at: string;
}
@@ -196,6 +197,7 @@ export interface ProceedingType {
name: string;
description?: string;
jurisdiction?: string;
category?: string;
default_color: string;
sort_order: number;
is_active: boolean;
@@ -293,6 +295,44 @@ export interface ApiError {
status: number;
}
// Fee calculation types (Patentprozesskostenrechner)
export interface FeeCalculateRequest {
streitwert: number;
vat_rate: number;
fee_version: string;
instances: FeeInstanceInput[];
}
export interface FeeInstanceInput {
instance_type: string;
enabled: boolean;
num_attorneys: number;
num_patent_attorneys: number;
oral_hearing: boolean;
num_clients: number;
}
export interface FeeCalculateResponse {
instances: FeeInstanceOutput[];
total: number;
}
export interface FeeInstanceOutput {
instance_type: string;
label: string;
court_fees: number;
attorney_fees: number;
patent_attorney_fees: number;
instance_total: number;
}
export interface FeeScheduleInfo {
version: string;
label: string;
valid_from: string;
}
export interface PaginatedResponse<T> {
data: T[];
total: number;