feat(budget): add "Fuel" and "Parking" expense categories

- Adds two new fixed budget categories: fuel ("Fuel") and parkings
  ("Parking"), alongside the existing set (Accommodation, Food & drink,
  Groceries, Transport, Flights, Activities, Sightseeing, Shopping,
  Fees & tickets, Health, Tips, Other).
- Icon/color metadata added for both (Fuel and ParkingCircle from
  lucide-react), plus legacy free-text aliases (gas/petrol->fuel,
  parking->parkings) for existing/imported expense rows.
- Label strings added for all 23 supported locales.
- Adds test coverage for the new categories and legacy alias mapping.
This commit is contained in:
MikeDabrowski
2026-08-08 22:43:19 +02:00
committed by Maurice
parent 875f87b885
commit 999236f944
27 changed files with 95 additions and 1 deletions
@@ -0,0 +1,34 @@
import { describe, it, expect } from 'vitest'
import { COST_CATEGORIES } from '@trek/shared'
import { COST_CAT_META, COST_CATEGORY_LIST, catMeta } from './costsCategories'
describe('COST_CAT_META', () => {
it('has metadata for every fixed category, including fuel and parkings', () => {
for (const key of COST_CATEGORIES) {
expect(COST_CAT_META[key]).toBeDefined()
expect(COST_CAT_META[key].key).toBe(key)
}
})
it('derives COST_CATEGORY_LIST in the same order as COST_CATEGORIES', () => {
expect(COST_CATEGORY_LIST.map(m => m.key)).toEqual([...COST_CATEGORIES])
})
})
describe('catMeta', () => {
it('resolves fuel and parkings directly', () => {
expect(catMeta('fuel').key).toBe('fuel')
expect(catMeta('parkings').key).toBe('parkings')
})
it('maps legacy/free-text aliases to the new categories', () => {
expect(catMeta('gas').key).toBe('fuel')
expect(catMeta('petrol').key).toBe('fuel')
expect(catMeta('parking').key).toBe('parkings')
})
it('falls back to other for unknown categories', () => {
expect(catMeta('made-up-category').key).toBe('other')
expect(catMeta(null).key).toBe('other')
})
})
@@ -1,4 +1,4 @@
import { Hotel, Utensils, ShoppingCart, Bus, Plane, Ticket, Camera, ShoppingBag, FileText, HeartPulse, Coins, MoreHorizontal } from 'lucide-react'
import { Hotel, Utensils, ShoppingCart, Bus, Plane, Ticket, Camera, ShoppingBag, FileText, HeartPulse, Coins, MoreHorizontal, Fuel, ParkingCircle } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import { COST_CATEGORIES, type CostCategory } from '@trek/shared'
@@ -27,6 +27,8 @@ export const COST_CAT_META: Record<CostCategory, CostCategoryMeta> = {
fees: { key: 'fees', labelKey: 'costs.cat.fees', Icon: FileText, color: '#475569' },
health: { key: 'health', labelKey: 'costs.cat.health', Icon: HeartPulse, color: '#dc2626' },
tips: { key: 'tips', labelKey: 'costs.cat.tips', Icon: Coins, color: '#d97706' },
fuel: { key: 'fuel', labelKey: 'costs.cat.fuel', Icon: Fuel, color: '#f59e0b' },
parkings: { key: 'parkings', labelKey: 'costs.cat.parkings', Icon: ParkingCircle, color: '#3b82f6' },
other: { key: 'other', labelKey: 'costs.cat.other', Icon: MoreHorizontal, color: '#6b7280' },
}
@@ -51,6 +53,8 @@ const LEGACY_CATEGORY_MAP: Record<string, CostCategory> = {
fee: 'fees', fees: 'fees',
health: 'health', medical: 'health',
tip: 'tips', tips: 'tips',
gas: 'fuel', fuel: 'fuel', petrol: 'fuel',
parking: 'parkings', parkings: 'parkings',
other: 'other', misc: 'other',
}