using EventFlow.Aggregates;
namespace Books.Api.Domain.Attachments.Events;
///
/// Event raised when an attachment (bilag) is uploaded.
/// Required by Bogføringsloven § 6 for document retention.
///
public class AttachmentUploadedEvent(
string companyId,
string fileName,
string originalFileName,
string contentType,
long fileSize,
string storagePath,
string uploadedBy,
string? draftId = null,
string? transactionId = null) : AggregateEvent
{
public string CompanyId { get; } = companyId;
///
/// Stored filename (sanitized/unique).
///
public string FileName { get; } = fileName;
///
/// Original filename as uploaded by user.
///
public string OriginalFileName { get; } = originalFileName;
///
/// MIME type (e.g., application/pdf, image/png).
///
public string ContentType { get; } = contentType;
///
/// File size in bytes.
///
public long FileSize { get; } = fileSize;
///
/// Path to the stored file (local path or blob URL).
///
public string StoragePath { get; } = storagePath;
public string UploadedBy { get; } = uploadedBy;
///
/// Optional reference to journal entry draft.
///
public string? DraftId { get; } = draftId;
///
/// Optional reference to posted transaction.
///
public string? TransactionId { get; } = transactionId;
}
///
/// Event raised when an attachment is linked to a transaction after posting.
///
public class AttachmentLinkedToTransactionEvent(
string transactionId) : AggregateEvent
{
public string TransactionId { get; } = transactionId;
}
///
/// Event raised when an attachment is deleted.
/// Note: Per Bogføringsloven § 6, attachments should be retained for 5 years.
/// This event is for administrative cleanup only.
///
public class AttachmentDeletedEvent(
string deletedBy,
string reason) : AggregateEvent
{
public string DeletedBy { get; } = deletedBy;
public string Reason { get; } = reason;
}