Skip to content

Implement Versioned Document Types #1

@adjdred

Description

@adjdred

📌 Summary

Implement a versioned DocumentType system to support multi-tenant document templates (e.g. certificates, transcripts, HEARs). Each document type can have multiple versions that apply from a specified time onward. Documents must reference the correct version based on their IssuedTime.


🧱 Entity: DocumentType

A single table that supports both grouping and versioning via a ParentId.

Fields:

  • Id: Unique identifier
  • TenantId: Multi-tenancy support
  • ParentId: Reference to the root version (null if this is the first version)
  • Name: Friendly name of the template version (e.g. "Transcript v2")
  • TypeName: Category (e.g. Certificate, Transcript, Letter)
  • Version: Version string or number
  • ValidFromTime: The time this version becomes active
  • IsActive: Indicates if the version is enabled for use
  • CreationTime: Timestamp (via ABP ICreationAudited)

📄 Requirements

  • Create DocumentType entity using FullAuditedAggregateRoot<Guid> and IMultiTenant
  • Support self-referencing ParentId to model versions under a shared logical group
  • Ensure DocumentTypeField and other related data link to the correct version
  • Add ability to resolve the correct DocumentType for a document using IssuedTime
  • Enforce uniqueness of (TenantId, ParentId, Version) if applicable
  • Seed or create the first version with ParentId = null
  • Add methods in the domain/application layer to:
    • Create a new version
    • Retrieve current version for a group
    • Get all versions by root ID

📦 Example: Document Version Resolution Logic

var applicableVersion = dbContext.DocumentTypes
    .Where(dt => dt.ParentId == rootId || dt.Id == rootId)
    .Where(dt => dt.ValidFromTime <= document.IssuedTime)
    .OrderByDescending(dt => dt.ValidFromTime)
    .FirstOrDefault();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions