Entity Price Override Service
Overview
Entity Price Overrides represent entity-specific pricing that supersedes standard price list pricing.
Each Entity Price Override defines:
- entity identifier (
EntityId) - typically a customer or supplier - product identifier (
ProductId) - override unit price (
UnitPrice) - discount percentage (
DiscountPercent) - validity period (
StartDate,EndDate)
Entity Price Overrides enable special pricing arrangements for specific customers or suppliers, such as contract pricing, volume discounts, or promotional agreements. Overrides take precedence over standard price list pricing when determining the final price for an entity.
All entity price override operations are tenant-aware and fully audited.
Endpoints
GET
/api/v1/EntityPriceOverride/GetAllEntitiesPriceOverride/{entityId}
Returns all price overrides for a specific entity.
Route parameters:
entityId(long, required)
Behavior:
- Filters by
EntityId - Returns all price overrides for the entity regardless of product or date validity
- Returns
404if no price overrides exist for the entity
Response:
List<EntityPriceOverrideModel>
Authorization:
- Requires Bearer Token
GET
/api/v1/EntityPriceOverride/GetEntityPriceOverride/{entityId}/{productId}
Returns the price override for a specific entity-product combination.
Route parameters:
entityId(long, required)productId(long, required)
Behavior:
- Looks up price override by
(EntityId, ProductId) - Returns override details if found
- Returns empty
EntityPriceOverrideModelif no override exists
Response:
EntityPriceOverrideModel
Authorization:
- Requires Bearer Token
POST
/api/v1/EntityPriceOverride/AddNewEntityPriceOverride
Creates a new entity price override.
Request body (EntityPriceOverrideModel):
EntityId(long, required, must be > 0)ProductId(long, required, must be > 0)UnitPrice(decimal?, optional, must be > 0 if provided)DiscountPercent(decimal?, optional, must be > 0 if provided)StartDate(DateOnly, required)EndDate(DateOnly, required)
Behavior:
- Validation is enforced in the service layer (
IsReadyToAdd()) IsReadyToAdd()requires:EntityId > 0ProductId > 0- At least one of
UnitPrice > 0ORDiscountPercent > 0
- Only one override can exist per
(EntityId, ProductId)pair (no duplicates) - Successful creation writes an audit log entry
Errors:
- Returns
400if:- request body is invalid (
IsReadyToAdd()is false) - override already exists for
(EntityId, ProductId) - database insert - or other internal error occurs
- request body is invalid (
Response:
200 OKwith message:"New Entity Price Override added"400 Bad Requestwith message:"Add new Entity Price Override failed"
Authorization:
- Requires Bearer Token
PUT
/api/v1/EntityPriceOverride/UpdateEntityPriceOverrideEntityIdAndProductId/{entityId}/{productId}
Updates an existing entity price override.
Route parameters:
entityId(long, required)productId(long, required)
Request body (EntityPriceOverrideModel):
UnitPrice(decimal?, optional)DiscountPercent(decimal?, optional)StartDate(DateOnly, optional)EndDate(DateOnly, optional)
Behavior:
- The controller sets
EntityIdandProductIdfrom the route - Validation is enforced (
IsReadyToUpdate()requiresEntityId > 0andProductId > 0) - Looks up override by
(EntityId, ProductId) - Updates only fields provided in body:
UnitPriceupdated if not nullDiscountPercentupdated if not nullStartDateupdated if not default valueEndDateupdated if not default value
- Successful update writes an audit log entry
Errors:
- Returns
400if:- request body is invalid (
IsReadyToUpdate()is false) - no override exists for
(EntityId, ProductId)
- request body is invalid (
Response:
200 OKwith message:"Update Product successful"(note: message should reference "Entity Price Override")400 Bad Requestwith message:"Update Product failed"(note: message should reference "Entity Price Override")
Authorization:
- Requires Bearer Token
DELETE
/api/v1/EntityPriceOverride/DeleteEntityPriceOverride/{entityId}/{productId}
Deletes an entity price override by (EntityId, ProductId).
Route parameters:
entityId(long, required)productId(long, required)
Behavior:
- Performs a hard delete
- Successful deletion writes an audit log entry
Errors:
- Returns
400with message"Entity Price Override not found"if the override does not exist
Response:
200 OKwith message:"Entity Price Override deleted successfully"400 Bad Requestwith message:"Entity Price Override not found"
Authorization:
- Requires Bearer Token
Notes
- Validation is enforced in the service layer, not via model attributes
(EntityId, ProductId)is treated as a unique pair (duplicates are blocked)- At least one of
UnitPriceorDiscountPercentmust be provided when creating an override - Entity price overrides take precedence over standard price list pricing
- Date ranges control when the override is active
- Internal errors are logged and not exposed to API consumers