using Books.Api.Domain.JournalEntryDrafts;
namespace Books.Api.EventFlow.ReadModels;
///
/// DTO for reading journal entry draft data from the database.
///
public class JournalEntryDraftReadModelDto
{
public string Id { get; set; } = string.Empty;
public string CompanyId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
///
/// Bilagsnummer - unique document number required by Bogføringsloven § 7, Stk. 4
///
public string VoucherNumber { get; set; } = string.Empty;
///
/// Bilagsdato - the date of the transaction/document (e.g., invoice date)
///
public DateTime? DocumentDate { get; set; }
public string? Description { get; set; }
public string? FiscalYearId { get; set; }
public string Lines { get; set; } = "[]";
///
/// JSON array of attachment IDs (bilag references)
///
public string AttachmentIds { get; set; } = "[]";
public string Status { get; set; } = "active";
public string? TransactionId { get; set; }
///
/// The exact timestamp when the draft was posted to the ledger.
///
public DateTimeOffset? PostedAt { get; set; }
public string CreatedBy { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
///
/// Full AI extraction data stored as JSON string.
/// Contains vendor CVR, amounts, VAT, due date, payment reference, line items, etc.
///
public string? ExtractionData { get; set; }
///
/// Deserialize lines from JSON to list of DraftLine objects.
///
public List GetLines()
{
if (string.IsNullOrEmpty(Lines))
return [];
return System.Text.Json.JsonSerializer.Deserialize>(Lines) ?? [];
}
///
/// Deserialize attachment IDs from JSON.
///
public List GetAttachmentIds()
{
if (string.IsNullOrEmpty(AttachmentIds))
return [];
return System.Text.Json.JsonSerializer.Deserialize>(AttachmentIds) ?? [];
}
}