From 290a95c54cef90c9cde3a72e676f9fa2862da61e Mon Sep 17 00:00:00 2001 From: nns <278048682+nurdotnet@users.noreply.github.com> Date: Sun, 26 Apr 2026 03:03:43 +0500 Subject: [PATCH] fix(supply-lines): show both article and barcode in line subtitle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit В таблице позиций приёмки под названием товара теперь выводится и артикул, и основной штрихкод сразу — раньше показывалось что-то одно (артикул или ничего, без штрихкода). Формат: «Арт: 17933 · ШК: 4870144022958». Если только одно из двух — префикс соответствующий, без точки-разделителя. Если ни того ни другого — subtitle не рендерится. Шрифт мелкий моно серый. API: - SupplyLineDto расширен полем ProductBarcode (основной по IsPrimary, иначе первый по порядку). - В проекции GetInternal штрихкод подтягивается через p.Barcodes.OrderByDescending(IsPrimary).Select(Code).First(). Frontend: - types.ts.SupplyLineDto, LineRow в SupplyEditPage и AddedProduct в SupplyLineQuickAdd получили поле productBarcode/barcode. - При добавлении строки через ProductPicker, sticky-input или quick-create — primary barcode достаётся из p.barcodes одинаковой логикой (sort by IsPrimary desc, [0]). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Controllers/Purchases/SuppliesController.cs | 6 +++++- .../src/components/SupplyLineQuickAdd.tsx | 6 ++++++ src/food-market.web/src/lib/types.ts | 3 ++- src/food-market.web/src/pages/SupplyEditPage.tsx | 13 ++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) 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}