Add RetailPrice and AgencyMarginPercent to PriceListItem and related API updates
This commit is contained in:
@@ -19,5 +19,19 @@ namespace Distribution.Models
|
||||
/// Must be less than or equal to Price when set.
|
||||
/// </summary>
|
||||
public decimal? MinPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// MRP — the price the store is expected to charge the end consumer. Informational (not
|
||||
/// enforced on sales), but must be >= Price so the store always has a positive margin.
|
||||
/// Null = not tracked for this item/list.
|
||||
/// </summary>
|
||||
public decimal? RetailPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The regional agency's commission, as a percentage (0-100) of Price, for operating
|
||||
/// distribution in that region. Informational — used for agency settlement/payout
|
||||
/// reporting, not enforced on sales. Null = not tracked for this item/list.
|
||||
/// </summary>
|
||||
public decimal? AgencyMarginPercent { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type {
|
||||
PaginatedResponse,
|
||||
PriceListResponse,
|
||||
PriceResolution,
|
||||
SchemeResponse,
|
||||
SchemeRuleType,
|
||||
} from '@/types/api'
|
||||
|
||||
import type { PageParams } from './master'
|
||||
|
||||
// ─── Price Lists ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface PriceListItemBody {
|
||||
@@ -25,14 +23,9 @@ export interface PriceListBody {
|
||||
items: PriceListItemBody[]
|
||||
}
|
||||
|
||||
export interface PriceListListParams extends PageParams {
|
||||
regionId?: string
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export const priceLists = {
|
||||
list: (params?: PriceListListParams) =>
|
||||
api.get<PaginatedResponse<PriceListResponse>>('/price-lists', { params }).then(r => r.data),
|
||||
list: (params?: { regionId?: string }) =>
|
||||
api.get<PriceListResponse[]>('/price-lists', { params }).then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<PriceListResponse>(`/price-lists/${id}`).then(r => r.data),
|
||||
@@ -42,6 +35,18 @@ export const priceLists = {
|
||||
|
||||
update: (id: string, body: Partial<PriceListBody>) =>
|
||||
api.put<PriceListResponse>(`/price-lists/${id}`, body).then(r => r.data),
|
||||
|
||||
remove: (id: string) =>
|
||||
api.delete(`/price-lists/${id}`),
|
||||
|
||||
upsertItem: (priceListId: string, sku: string, body: { price: number; minPrice?: number | null; retailPrice?: number | null; agencyMarginPercent?: number | null }) =>
|
||||
api.put<PriceListResponse>(`/price-lists/${priceListId}/items/${encodeURIComponent(sku)}`, body).then(r => r.data),
|
||||
|
||||
removeItem: (priceListId: string, sku: string) =>
|
||||
api.delete<PriceListResponse>(`/price-lists/${priceListId}/items/${encodeURIComponent(sku)}`).then(r => r.data),
|
||||
|
||||
resolve: (params: { itemId: string; storeId: string; saleDate: string }) =>
|
||||
api.get<PriceResolution>('/price-lists/resolve', { params }).then(r => r.data),
|
||||
}
|
||||
|
||||
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
||||
@@ -69,14 +74,9 @@ export interface SchemeBody {
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export interface SchemeListParams extends PageParams {
|
||||
regionId?: string
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export const schemes = {
|
||||
list: (params?: SchemeListParams) =>
|
||||
api.get<PaginatedResponse<SchemeResponse>>('/schemes', { params }).then(r => r.data),
|
||||
list: (params?: { regionId?: string }) =>
|
||||
api.get<SchemeResponse[]>('/schemes', { params }).then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<SchemeResponse>(`/schemes/${id}`).then(r => r.data),
|
||||
@@ -86,4 +86,7 @@ export const schemes = {
|
||||
|
||||
update: (id: string, body: Partial<SchemeBody>) =>
|
||||
api.put<SchemeResponse>(`/schemes/${id}`, body).then(r => r.data),
|
||||
|
||||
remove: (id: string) =>
|
||||
api.delete(`/schemes/${id}`),
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type { PaginatedResponse, SupplierResponse } from '@/types/api'
|
||||
import type { PageParams } from './master'
|
||||
import type { SupplierResponse } from '@/types/api'
|
||||
|
||||
export interface SupplierBody {
|
||||
name: string
|
||||
@@ -9,8 +8,8 @@ export interface SupplierBody {
|
||||
}
|
||||
|
||||
export const suppliers = {
|
||||
list: (params?: PageParams) =>
|
||||
api.get<PaginatedResponse<SupplierResponse>>('/suppliers', { params }).then(r => r.data),
|
||||
list: () =>
|
||||
api.get<SupplierResponse[]>('/suppliers').then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<SupplierResponse>(`/suppliers/${id}`).then(r => r.data),
|
||||
@@ -20,4 +19,7 @@ export const suppliers = {
|
||||
|
||||
update: (id: string, body: Partial<SupplierBody>) =>
|
||||
api.put<SupplierResponse>(`/suppliers/${id}`, body).then(r => r.data),
|
||||
|
||||
remove: (id: string) =>
|
||||
api.delete(`/suppliers/${id}`),
|
||||
}
|
||||
|
||||
@@ -313,6 +313,8 @@ export interface PriceListItemResponse {
|
||||
itemName: string
|
||||
price: number
|
||||
minPrice: number | null
|
||||
retailPrice: number | null
|
||||
agencyMarginPercent: number | null
|
||||
}
|
||||
|
||||
export interface PriceListResponse {
|
||||
@@ -327,6 +329,13 @@ export interface PriceListResponse {
|
||||
items: PriceListItemResponse[]
|
||||
}
|
||||
|
||||
export interface PriceResolution {
|
||||
price: number
|
||||
minPrice: number | null
|
||||
retailPrice: number | null
|
||||
agencyMarginPercent: number | null
|
||||
}
|
||||
|
||||
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface BundleComponent {
|
||||
|
||||
Reference in New Issue
Block a user