diff --git a/src/food-market.api/Controllers/Purchases/SuppliesController.cs b/src/food-market.api/Controllers/Purchases/SuppliesController.cs index ffce2c2..9af1577 100644 --- a/src/food-market.api/Controllers/Purchases/SuppliesController.cs +++ b/src/food-market.api/Controllers/Purchases/SuppliesController.cs @@ -34,6 +34,7 @@ public record SupplyListRow( public record SupplyLineDto( Guid? Id, Guid ProductId, string? ProductName, string? ProductArticle, + string? ProductBarcode, string? UnitSymbol, decimal Quantity, decimal UnitPrice, decimal LineTotal, int SortOrder, bool RetailPriceManuallyOverridden, decimal? RetailPriceOverride, @@ -384,7 +385,10 @@ private async Task GenerateNumberAsync(DateTime date, CancellationToken where l.SupplyId == id orderby l.SortOrder select new SupplyLineDto( - l.Id, l.ProductId, p.Name, p.Article, u.Name, + l.Id, l.ProductId, p.Name, p.Article, + // Основной штрихкод (IsPrimary=true), иначе первый по порядку. + p.Barcodes.OrderByDescending(b => b.IsPrimary).Select(b => b.Code).FirstOrDefault(), + u.Name, l.Quantity, l.UnitPrice, l.LineTotal, l.SortOrder, l.RetailPriceManuallyOverridden, l.RetailPriceOverride, p.Prices diff --git a/src/food-market.web/src/components/SupplyLineQuickAdd.tsx b/src/food-market.web/src/components/SupplyLineQuickAdd.tsx index 187ef29..dabcbbb 100644 --- a/src/food-market.web/src/components/SupplyLineQuickAdd.tsx +++ b/src/food-market.web/src/components/SupplyLineQuickAdd.tsx @@ -18,6 +18,8 @@ export interface AddedProduct { id: string name: string article: string | null + /** Основной штрихкод (IsPrimary), либо первый по порядку. */ + barcode: string | null referencePrice: number | null unitName: string | null cost: number | null @@ -162,10 +164,12 @@ export function SupplyLineQuickAdd({ storeId, disabled, onPick }: Props) { refocus() try { const full = (await api.get(`/api/catalog/products/${id}`)).data + const primaryBarcode = (full.barcodes ?? []).slice().sort((a, b) => Number(b.isPrimary) - Number(a.isPrimary))[0]?.code ?? null const incremented = onPick({ id: full.id, name: full.name, article: full.article, + barcode: primaryBarcode, referencePrice: full.referencePrice, unitName: full.unitName, cost: full.cost, @@ -240,10 +244,12 @@ export function SupplyLineQuickAdd({ storeId, disabled, onPick }: Props) { } const onCreated = async (p: Product) => { + const primaryBarcode = (p.barcodes ?? []).slice().sort((a, b) => Number(b.isPrimary) - Number(a.isPrimary))[0]?.code ?? null onPick({ id: p.id, name: p.name, article: p.article, + barcode: primaryBarcode, referencePrice: p.referencePrice, unitName: p.unitName, cost: p.cost, diff --git a/src/food-market.web/src/lib/types.ts b/src/food-market.web/src/lib/types.ts index 1bd9645..a545feb 100644 --- a/src/food-market.web/src/lib/types.ts +++ b/src/food-market.web/src/lib/types.ts @@ -92,7 +92,8 @@ export interface SupplyListRow { export interface SupplyLineDto { id: string | null; productId: string; - productName: string | null; productArticle: string | null; unitName: string | null; + productName: string | null; productArticle: string | null; productBarcode: string | null; + unitName: string | null; quantity: number; unitPrice: number; lineTotal: number; sortOrder: number; retailPriceManuallyOverridden: boolean; retailPriceOverride: number | null; currentRetailPrice: number | null; diff --git a/src/food-market.web/src/pages/SupplyEditPage.tsx b/src/food-market.web/src/pages/SupplyEditPage.tsx index caba533..ad8ae2f 100644 --- a/src/food-market.web/src/pages/SupplyEditPage.tsx +++ b/src/food-market.web/src/pages/SupplyEditPage.tsx @@ -16,6 +16,7 @@ interface LineRow { productId: string productName: string productArticle: string | null + productBarcode: string | null unitName: string | null quantity: number unitPrice: number @@ -96,6 +97,7 @@ export function SupplyEditPage() { productId: l.productId, productName: l.productName ?? '', productArticle: l.productArticle, + productBarcode: l.productBarcode, unitName: l.unitName, quantity: l.quantity, unitPrice: l.unitPrice, @@ -196,12 +198,14 @@ export function SupplyEditPage() { const addLineFromProduct = (p: Product) => { const defaultRetail = p.prices?.[0]?.amount ?? null + const primaryBarcode = (p.barcodes ?? []).slice().sort((a, b) => Number(b.isPrimary) - Number(a.isPrimary))[0]?.code ?? null setForm({ ...form, lines: [...form.lines, { productId: p.id, productName: p.name, productArticle: p.article, + productBarcode: primaryBarcode, unitName: p.unitName, quantity: 1, unitPrice: p.referencePrice ?? p.cost ?? 0, @@ -231,6 +235,7 @@ export function SupplyEditPage() { productId: p.id, productName: p.name, productArticle: p.article, + productBarcode: p.barcode, unitName: p.unitName, quantity: 1, unitPrice: p.referencePrice ?? p.cost ?? 0, @@ -399,7 +404,13 @@ export function SupplyEditPage() {
{l.productName}
- {l.productArticle &&
{l.productArticle}
} + {(l.productArticle || l.productBarcode) && ( +
+ {l.productArticle && Арт: {l.productArticle}} + {l.productArticle && l.productBarcode && ·} + {l.productBarcode && ШК: {l.productBarcode}} +
+ )} {l.unitName}