Table of Contents

Class Merchant

Namespace
arolariu.Backend.Domain.Invoices.DDD.Entities.Merchants
Assembly
arolariu.Backend.Domain.Invoices.dll

Represents a merchant (vendor / store) referenced by one or more invoices within the invoicing bounded context.

[ExcludeFromCodeCoverage]
public sealed class Merchant : NamedEntity<Guid>, IAuditable
Inheritance
Merchant
Implements
Inherited Members

Remarks

Encapsulates classification (Category), location/contact data (Address), hierarchical grouping (ParentCompanyId) and reverse references from invoices (ReferencedInvoices) for analytic aggregation.

Identity: Assigned at creation time (random GUID). Future optimization may migrate to Version 7 GUID for chronological sorting.

Relationships: Not an aggregate root for invoices (invoices own the relationship by storing MerchantReference). This type acts as a referenced entity; deleting a merchant should not cascade to invoices without explicit orchestration logic.

Thread-safety: Not thread-safe — treat instances as single-thread scoped.

Soft Delete: Not currently implementing soft-delete flags at this level; deletion semantics handled at persistence/broker layer if added.

Properties

AdditionalMetadata

Extensible key/value metadata (lightweight tagging / enrichment layer).

[JsonPropertyOrder(7)]
public IDictionary<string, string> AdditionalMetadata { get; init; }

Property Value

IDictionary<string, string>

Remarks

Key namespaces SHOULD use a dotted convention (e.g. ai.confidence, user.note, integration.source).

Values are stored as strings for portability; upstream systems must handle serialization of complex types.

Write Semantics: Last writer wins per key; no historical versioning.

Address

Structured contact / address information.

[JsonPropertyOrder(4)]
public ContactInformation Address { get; set; }

Property Value

ContactInformation

Remarks

Represents a value object snapshot. Entire object is typically replaced on update; no deep merge semantics currently.

Category

Domain classification used for analytics, grouping and enrichment heuristics.

[JsonPropertyOrder(3)]
public MerchantCategory Category { get; set; }

Property Value

MerchantCategory

Remarks

Defaults to OTHER when unclassified. Downstream enrichment processes SHOULD minimize long-term usage of OTHER.

ParentCompanyId

Optional linkage to a parent company (hierarchical reporting / consolidation).

[JsonPropertyOrder(5)]
public Guid ParentCompanyId { get; set; }

Property Value

Guid

Remarks

Guid.Empty indicates no parent company assigned.

ReferencedInvoices

Reverse references to invoices that currently point to this merchant.

[JsonPropertyOrder(6)]
public ICollection<Guid> ReferencedInvoices { get; init; }

Property Value

ICollection<Guid>

Remarks

Maintained for read-optimization / analytics. Contents are not automatically pruned on invoice deletion; reconciliation job may be required.

Order reflects insertion order; duplicates are not automatically filtered (caller MUST prevent duplicate insertion).

id

Immutable merchant identity.

[JsonPropertyName("id")]
[JsonPropertyOrder(0)]
public override Guid id { get; init; }

Property Value

Guid

Remarks

Generated via NewGuid(); no ordering guarantees. Consider Version 7 GUID if chronological sorting becomes a requirement.

Methods

Default()

Create a default instance of Merchant.

internal static Merchant Default()

Returns

Merchant