Entities Module
Overview
The Entities module is responsible for managing all business entities within the system.
An entity represents either a Customer or a Supplier, including their addresses and users.
This module defines how entities are created, validated, updated and deleted before they are used
by sales, pricing, ordering and access-control modules.
All operations are tenant-aware and fully audited.
Services
The Entities module consists of the following services:
- Customer - manage customers and their details
- Supplier - manage suppliers and their details
- Entity Address - manage billing and shipping addresses
- Entity User - manage users, roles, passwords and self-service profile
- Files - manage filemanage file attachments linked to entities
- File Types - manage file type definitions
Models
This module exposes and consumes the following models.
Entity Model
Represents a business entity (customer).
Fields:
Id (type: long)- internal identifierCode (type: string?)- unique customer codeName (type: string?)- customer display nameEmail (type: string?)- primary email addressPhone (type: string?)- contact phone numberHasAccessToAllProducts (type: bool?)- access to all products flagDefaultBillingAddressId (type: long)- default billing addressDefaultShippingAddressId (type: long)- default shipping addressIsActive (type: bool?)- active flag
Validation:
IsReadyToAdd()- requires
Code - requires
Name
- requires
IsReadyToUpdate()- requires
Id > 0 - requires
Code - requires
Name
- requires
Notes:
- Used for customers
- Email must be unique across all entities
- Entity type is determined internally (
IsSupplierflag) - All data is tenant-scoped
Supplier Model
Represents a supplier entity.
Extends Entity Model with supplier-specific fields.
Additional Fields:
RelatedEntityId (type: long?)- related customer or entity identifierRelatedEntityRelationship (type: string?)- relationship descriptionPaymentTermsDays (type: int?)- payment terms in daysIsPayOnAccount (type: bool?)- pay on account flagCreditLimit (type: decimal?)- credit limit amount
Validation:
- Inherits validation from
Entity Model
Notes:
SupplierModelinherits fromEntityModel- Supplier-specific fields are applied only when
IsSupplier = true - Stored in the same entity data store as customers
- Tenant-scoped and audited
Address Model
Represents an address assigned to an entity.
Fields:
Id (type: long)- internal identifierEntityID (type: long?)- associated entity identifierName (type: string?)- address name or labelLine1 (type: string?)- first address lineLine2 (type: string?)- second address lineCity (type: string?)- cityStateRegion (type: string?)- state or regionPostalCode (type: string?)- postal codeCountryCode (type: string?)- ISO country codePhone (type: string?)- contact phoneEmail (type: string?)- contact emailAddressType (type: int?)- address type (FK toEntityAddressType; default:0)
Validation:
IsReadyToAdd()- requires
EntityID > 0 - requires
Name - requires
Line1 - requires
City - requires
PostalCode - requires
CountryCode
- requires
IsReadyToUpdate()- requires
Id > 0 - requires
Name
- requires
Notes:
- An entity may have multiple addresses
- Address purpose is determined by
AddressType— see EntityAddressType Model - Address data is tenant-scoped
EntityAddressType Model
Defines the purpose of an address. Values are fixed system constants — the same for all tenants.
Fields:
Id (type: int)- identifier (also used as the FK value inAddress.AddressType)Title (type: string)- display name
Fixed values:
| Id | Title |
|---|---|
| 0 | Default |
| 1 | Shipping |
| 2 | Billing |
Notes:
- These values are seeded at database level and must not be changed
Address.AddressTypeis constrained by FK to this table- Replaces the previous
IsBilling/IsShippingboolean flags
Files Model
Represents a file attachment linked to an entity.
Fields:
Id (type: long)- internal identifierEntityId (type: long)- associated entity identifierFileName (type: string)- file nameDescription (type: string?)- file descriptionCreatedAt (type: DateTime)- creation timestampUpdatedAt (type: DateTime?)- last update timestampFileURL (type: string?)- URL or path to the fileFileType (type: long?)- file type identifier
Validation:
IsReadyToAdd()- requires
EntityId > 0 - requires
FileName
- requires
IsReadyToUpdate()- requires
Id > 0 - requires
EntityId > 0 - requires
FileName
- requires
Notes:
- Files are linked to entities via
EntityId - File storage location is managed externally
- All data is tenant-scoped
File Type Model
Represents a category or type of file.
Fields:
Id (type: long)- internal identifierTitle (type: string)- file type display titleIcon (type: string?)- optional icon identifierCreatedAt (type: DateTime)- creation timestamp
Validation:
IsReadyToAdd()- requires
Title
- requires
IsReadyToUpdate()- requires
Id > 0 - requires
Title
- requires
Notes:
- File types provide categorization for files
- Used for filtering and organizing attachments
- All data is tenant-scoped