Files
duempelkas/.github/prompts/02-domain-model.prompt.md
troogs e589cc170a Add GitHub Copilot prompt files
- Step-by-step prompts for solution skeleton, domain model,
  DbContext mappings, application services, UI shell/pages,
  PDF export, and tests/validation
2026-03-31 17:12:35 +02:00

1.8 KiB

description, agent
description agent
Implement the EF Core entity classes and enums for Account, AccountYear, Entry, TransferLink, and EntryType agent

Step 2: Domain Model

Implement the domain entities under src/Duempelkas.Domain.

Entities

Account (Entities/Account.cs)

  • int Id (PK)
  • string Name (required, max 200)
  • DateTime CreatedUtc
  • ICollection<AccountYear> AccountYears (navigation)

AccountYear (Entities/AccountYear.cs)

  • int Id (PK)
  • int AccountId (FK → Account)
  • int Year (e.g. 2026)
  • decimal OpeningBalance — explicit carryover from the previous year, user-entered
  • DateTime CreatedUtc
  • Account Account (navigation)
  • ICollection<Entry> Entries (navigation)

Constraint: unique on (AccountId, Year).

Entry (Entities/Entry.cs)

  • int Id (PK)
  • int AccountYearId (FK → AccountYear)
  • EntryType Type — Income or Expense
  • DateTime Date
  • string Title (required, max 500)
  • decimal Amount — always positive; sign determined by Type
  • int? TransferLinkId (FK → TransferLink, nullable)
  • DateTime CreatedUtc
  • AccountYear AccountYear (navigation)
  • TransferLink? TransferLink (navigation)
  • int Id (PK)
  • int SourceEntryId (FK → Entry, unique)
  • int TargetEntryId (FK → Entry, unique)
  • string? Note
  • DateTime CreatedUtc
  • Entry SourceEntry (navigation)
  • Entry TargetEntry (navigation)

Invariants enforced at service level:

  • SourceEntry.Type must be Expense
  • TargetEntry.Type must be Income
  • Both share the same Amount and Date

EntryType (Enums/EntryType.cs)

public enum EntryType { Income = 0, Expense = 1 }

Conventions

  • Use decimal for all monetary amounts.
  • Store amounts as positive; behaviour (add/subtract) comes from EntryType.
  • File-scoped namespaces, nullable enabled.