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.
|
/// Must be less than or equal to Price when set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? MinPrice { get; set; }
|
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 { api } from '@/lib/api'
|
||||||
import type {
|
import type {
|
||||||
PaginatedResponse,
|
|
||||||
PriceListResponse,
|
PriceListResponse,
|
||||||
|
PriceResolution,
|
||||||
SchemeResponse,
|
SchemeResponse,
|
||||||
SchemeRuleType,
|
SchemeRuleType,
|
||||||
} from '@/types/api'
|
} from '@/types/api'
|
||||||
|
|
||||||
import type { PageParams } from './master'
|
|
||||||
|
|
||||||
// ─── Price Lists ──────────────────────────────────────────────────────────────
|
// ─── Price Lists ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export interface PriceListItemBody {
|
export interface PriceListItemBody {
|
||||||
@@ -25,14 +23,9 @@ export interface PriceListBody {
|
|||||||
items: PriceListItemBody[]
|
items: PriceListItemBody[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PriceListListParams extends PageParams {
|
|
||||||
regionId?: string
|
|
||||||
isActive?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const priceLists = {
|
export const priceLists = {
|
||||||
list: (params?: PriceListListParams) =>
|
list: (params?: { regionId?: string }) =>
|
||||||
api.get<PaginatedResponse<PriceListResponse>>('/price-lists', { params }).then(r => r.data),
|
api.get<PriceListResponse[]>('/price-lists', { params }).then(r => r.data),
|
||||||
|
|
||||||
get: (id: string) =>
|
get: (id: string) =>
|
||||||
api.get<PriceListResponse>(`/price-lists/${id}`).then(r => r.data),
|
api.get<PriceListResponse>(`/price-lists/${id}`).then(r => r.data),
|
||||||
@@ -42,6 +35,18 @@ export const priceLists = {
|
|||||||
|
|
||||||
update: (id: string, body: Partial<PriceListBody>) =>
|
update: (id: string, body: Partial<PriceListBody>) =>
|
||||||
api.put<PriceListResponse>(`/price-lists/${id}`, body).then(r => r.data),
|
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 ──────────────────────────────────────────────────────────────────
|
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
||||||
@@ -69,14 +74,9 @@ export interface SchemeBody {
|
|||||||
isActive?: boolean
|
isActive?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SchemeListParams extends PageParams {
|
|
||||||
regionId?: string
|
|
||||||
isActive?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const schemes = {
|
export const schemes = {
|
||||||
list: (params?: SchemeListParams) =>
|
list: (params?: { regionId?: string }) =>
|
||||||
api.get<PaginatedResponse<SchemeResponse>>('/schemes', { params }).then(r => r.data),
|
api.get<SchemeResponse[]>('/schemes', { params }).then(r => r.data),
|
||||||
|
|
||||||
get: (id: string) =>
|
get: (id: string) =>
|
||||||
api.get<SchemeResponse>(`/schemes/${id}`).then(r => r.data),
|
api.get<SchemeResponse>(`/schemes/${id}`).then(r => r.data),
|
||||||
@@ -86,4 +86,7 @@ export const schemes = {
|
|||||||
|
|
||||||
update: (id: string, body: Partial<SchemeBody>) =>
|
update: (id: string, body: Partial<SchemeBody>) =>
|
||||||
api.put<SchemeResponse>(`/schemes/${id}`, body).then(r => r.data),
|
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 { api } from '@/lib/api'
|
||||||
import type { PaginatedResponse, SupplierResponse } from '@/types/api'
|
import type { SupplierResponse } from '@/types/api'
|
||||||
import type { PageParams } from './master'
|
|
||||||
|
|
||||||
export interface SupplierBody {
|
export interface SupplierBody {
|
||||||
name: string
|
name: string
|
||||||
@@ -9,8 +8,8 @@ export interface SupplierBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const suppliers = {
|
export const suppliers = {
|
||||||
list: (params?: PageParams) =>
|
list: () =>
|
||||||
api.get<PaginatedResponse<SupplierResponse>>('/suppliers', { params }).then(r => r.data),
|
api.get<SupplierResponse[]>('/suppliers').then(r => r.data),
|
||||||
|
|
||||||
get: (id: string) =>
|
get: (id: string) =>
|
||||||
api.get<SupplierResponse>(`/suppliers/${id}`).then(r => r.data),
|
api.get<SupplierResponse>(`/suppliers/${id}`).then(r => r.data),
|
||||||
@@ -20,4 +19,7 @@ export const suppliers = {
|
|||||||
|
|
||||||
update: (id: string, body: Partial<SupplierBody>) =>
|
update: (id: string, body: Partial<SupplierBody>) =>
|
||||||
api.put<SupplierResponse>(`/suppliers/${id}`, body).then(r => r.data),
|
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
|
itemName: string
|
||||||
price: number
|
price: number
|
||||||
minPrice: number | null
|
minPrice: number | null
|
||||||
|
retailPrice: number | null
|
||||||
|
agencyMarginPercent: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PriceListResponse {
|
export interface PriceListResponse {
|
||||||
@@ -327,6 +329,13 @@ export interface PriceListResponse {
|
|||||||
items: PriceListItemResponse[]
|
items: PriceListItemResponse[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PriceResolution {
|
||||||
|
price: number
|
||||||
|
minPrice: number | null
|
||||||
|
retailPrice: number | null
|
||||||
|
agencyMarginPercent: number | null
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export interface BundleComponent {
|
export interface BundleComponent {
|
||||||
|
|||||||
Reference in New Issue
Block a user