books/backend/Books.Api/Domain/Attachments/Events/AttachmentEvents.cs
Nicolaj Hartmann 1f75c5d791 Add all backend domain, commands, repositories, and tests
This commit includes all previously untracked backend files:

Domain:
- Accounts, Attachments, BankConnections, Customers
- FiscalYears, Invoices, JournalEntryDrafts
- Orders, Products, UserAccess

Commands & Handlers:
- Full CQRS command structure for all domains

Repositories:
- PostgreSQL repositories for all read models
- Bank transaction and ledger repositories

GraphQL:
- Input types, scalars, and types for all entities
- Mutations and queries

Infrastructure:
- Banking integration (Enable Banking client)
- File storage, Invoicing, Reporting, SAF-T export
- Database migrations (003-029)

Tests:
- Integration tests for GraphQL endpoints
- Domain tests
- Invoicing and reporting tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:19:42 +01:00

80 lines
2.3 KiB
C#

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