Price List Service
Overview
Price Lists represent pricing contexts that define product prices in specific currencies.
Each Price List defines:
- unique name (
Name) - currency code (
Currency) - default flag for the currency (
IsDefault)
Price Lists are the foundation of the pricing system and are used to organize product prices by currency and business context (e.g., retail, wholesale, promotional). Each price list can contain prices for multiple products, and products can have different prices across different price lists.
All price list operations are tenant-aware and fully audited.
Endpoints
GET
/api/v1/PriceList/GetAllPriceLists
Returns all price lists.
Behavior:
- Returns a list of
PriceListModel - Returns
404if no price lists exist
Response:
List<PriceListModel>
Authorization:
- Requires Bearer Token
GET
/api/v1/PriceList/GetPriceListById/{id}
Returns a single price list by its ID.
Route parameters:
id(int, required)
Behavior:
- Looks up price list by
Id - Returns price list details if found
Errors:
- Returns
404if price list does not exist
Response:
PriceListModel
Authorization:
- Requires Bearer Token
GET
/api/v1/PriceList/GetDefault?currency={currency}
Returns default price list(s), optionally filtered by currency.
Query parameters:
currency(string?, optional) - filter by currency code (e.g., "GBP", "USD")
Behavior:
- Returns all default price lists if
currencyis not provided - Returns default price list for specified currency if
currencyis provided - A price list is considered default when
IsDefault == true
Errors:
- Returns
404if no default price list exists (or none match the currency filter)
Response:
List<PriceListModel>
Authorization:
- Requires Bearer Token
POST
/api/v1/PriceList/AddNewPriceList
Creates a new price list.
Request body (PriceListModel):
Name(string, required, must not be empty)Currency(string, required, must not be empty)IsDefault(bool?, optional, defaults tofalseif not provided)
Behavior:
- Validation is enforced in the service layer (
IsReadyToAdd()) - Prevents duplicates by enforcing uniqueness of
Nameper currency - If
IsDefaultistrue, automatically unmarks previous default for the same currency - Successful creation writes an audit log entry
Errors:
- Returns
400if:- request body is invalid (
IsReadyToAdd()is false) - price list with the same
Namealready exists - database insert - or other internal error occurs
- request body is invalid (
Response:
200 OKwith message:"New price list added"400 Bad Requestwith message:"Add new price list failed"
Authorization:
- Requires Bearer Token
PUT
/api/v1/PriceList/UpdatePriceListById/{id}
Updates an existing price list.
Route parameters:
id(int, required)
Request body (PriceListModel):
Name(string, optional)Currency(string, optional)IsDefault(bool?, optional)
Behavior:
- The controller sets
Idfrom the route - Validation is enforced (
IsReadyToUpdate()requiresId > 0,Namenot empty,Currencynot empty) - Prevents duplicate names: validates that
Nameis unique for the givenCurrency(excluding current record) - If
IsDefaultis set totrue, automatically unmarks previous default for the same currency - Updates only fields provided in body:
Nameupdated if not null or whitespaceCurrencyupdated if not null or whitespaceIsDefaultupdated if not null
- Successful update writes an audit log entry
Errors:
- Returns
400if:- request body is invalid (
IsReadyToUpdate()is false) - price list does not exist
Namealready exists for the givenCurrency(excluding current record)
- request body is invalid (
Response:
200 OKwith message:"Update price list successful"400 Bad Requestwith message:"Update price list failed"
Authorization:
- Requires Bearer Token
DELETE
/api/v1/PriceList/DeletePriceListById/{id}
Deletes a price list by its ID.
Route parameters:
id(int, required)
Behavior:
- Performs a hard delete
- Successful deletion writes an audit log entry
Errors:
- Returns
400with message"Price list not found"if the price list does not exist
Response:
200 OKwith message:"Price list deleted successfully"400 Bad Requestwith message:"Price list not found"
Authorization:
- Requires Bearer Token
Notes
- Validation is enforced in the service layer, not via model attributes
Namemust be unique per currency (enforced during creation and update)- Only one price list can be marked as default per currency
- When setting a new default, the previous default for that currency is automatically unmarked
IsDefaultdefaults tofalseif not provided during creation- Deleting a price list does not cascade to related product prices (consider adding validation to prevent deletion if product prices exist)
- Internal errors are logged and not exposed to API consumers