diff --git a/Distribution/Models/PriceListItem.cs b/Distribution/Models/PriceListItem.cs index f9b7b24..bfb0c4b 100644 --- a/Distribution/Models/PriceListItem.cs +++ b/Distribution/Models/PriceListItem.cs @@ -19,5 +19,19 @@ namespace Distribution.Models /// Must be less than or equal to Price when set. /// public decimal? MinPrice { get; set; } + + /// + /// 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. + /// + public decimal? RetailPrice { get; set; } + + /// + /// 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. + /// + public decimal? AgencyMarginPercent { get; set; } } } diff --git a/distribution_fe/lib/api/pricing.ts b/distribution_fe/lib/api/pricing.ts index 438b6f9..ea75cb1 100644 --- a/distribution_fe/lib/api/pricing.ts +++ b/distribution_fe/lib/api/pricing.ts @@ -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>('/price-lists', { params }).then(r => r.data), + list: (params?: { regionId?: string }) => + api.get('/price-lists', { params }).then(r => r.data), get: (id: string) => api.get(`/price-lists/${id}`).then(r => r.data), @@ -42,6 +35,18 @@ export const priceLists = { update: (id: string, body: Partial) => api.put(`/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(`/price-lists/${priceListId}/items/${encodeURIComponent(sku)}`, body).then(r => r.data), + + removeItem: (priceListId: string, sku: string) => + api.delete(`/price-lists/${priceListId}/items/${encodeURIComponent(sku)}`).then(r => r.data), + + resolve: (params: { itemId: string; storeId: string; saleDate: string }) => + api.get('/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>('/schemes', { params }).then(r => r.data), + list: (params?: { regionId?: string }) => + api.get('/schemes', { params }).then(r => r.data), get: (id: string) => api.get(`/schemes/${id}`).then(r => r.data), @@ -86,4 +86,7 @@ export const schemes = { update: (id: string, body: Partial) => api.put(`/schemes/${id}`, body).then(r => r.data), + + remove: (id: string) => + api.delete(`/schemes/${id}`), } diff --git a/distribution_fe/lib/api/suppliers.ts b/distribution_fe/lib/api/suppliers.ts index 4ac4330..ecc1865 100644 --- a/distribution_fe/lib/api/suppliers.ts +++ b/distribution_fe/lib/api/suppliers.ts @@ -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>('/suppliers', { params }).then(r => r.data), + list: () => + api.get('/suppliers').then(r => r.data), get: (id: string) => api.get(`/suppliers/${id}`).then(r => r.data), @@ -20,4 +19,7 @@ export const suppliers = { update: (id: string, body: Partial) => api.put(`/suppliers/${id}`, body).then(r => r.data), + + remove: (id: string) => + api.delete(`/suppliers/${id}`), } diff --git a/distribution_fe/types/api.ts b/distribution_fe/types/api.ts index 6a93ac8..5f00b9e 100644 --- a/distribution_fe/types/api.ts +++ b/distribution_fe/types/api.ts @@ -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 {