using Books.Api.Domain.JournalEntryDrafts;
using EventFlow.Commands;
namespace Books.Api.Commands.JournalEntryDrafts;
///
/// Command to create a new journal entry draft.
/// VoucherNumber is required by Bogføringsloven § 7, Stk. 4.
///
public class CreateJournalEntryDraftCommand(
JournalEntryDraftId aggregateId,
string companyId,
string name,
string createdBy,
string voucherNumber,
string? extractionData = null)
: Command(aggregateId)
{
public string CompanyId { get; } = companyId;
public string Name { get; } = name;
public string CreatedBy { get; } = createdBy;
///
/// Bilagsnummer - unique document number per company.
///
public string VoucherNumber { get; } = voucherNumber;
///
/// Full AI extraction data as JSON string.
/// Contains vendor CVR, amounts, VAT, due date, payment reference, line items, etc.
///
public string? ExtractionData { get; } = extractionData;
}
///
/// Command to update a journal entry draft (auto-save).
/// Includes VAT codes per line and attachment references.
///
public class UpdateJournalEntryDraftCommand(
JournalEntryDraftId aggregateId,
string? name,
DateOnly? documentDate,
string? description,
string? fiscalYearId,
List lines,
List? attachmentIds = null)
: Command(aggregateId)
{
public string? Name { get; } = name;
///
/// Bilagsdato - the date of the transaction/document (e.g., invoice date)
///
public DateOnly? DocumentDate { get; } = documentDate;
public string? Description { get; } = description;
public string? FiscalYearId { get; } = fiscalYearId;
public List Lines { get; } = lines;
///
/// References to attached documents (bilag) - required by Bogføringsloven § 6.
///
public List AttachmentIds { get; } = attachmentIds ?? [];
}
public class MarkJournalEntryDraftPostedCommand(
JournalEntryDraftId aggregateId,
string transactionId,
string postedBy)
: Command(aggregateId)
{
public string TransactionId { get; } = transactionId;
public string PostedBy { get; } = postedBy;
}
public class DiscardJournalEntryDraftCommand(
JournalEntryDraftId aggregateId,
string discardedBy)
: Command(aggregateId)
{
public string DiscardedBy { get; } = discardedBy;
}