From e93c9c13c991e09af73a9055bf7eedfe0d8a5d17 Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Sat, 29 Aug 2026 19:50:34 +0300 Subject: [PATCH] Fix product performance grouped JSON build --- svc/queries/production_product_costing.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/svc/queries/production_product_costing.go b/svc/queries/production_product_costing.go index 0ea4ab3..7cd341d 100644 --- a/svc/queries/production_product_costing.go +++ b/svc/queries/production_product_costing.go @@ -911,6 +911,10 @@ func GetProductionHasCostProducts( nFirmaID int, ) (*sql.Rows, error) { search = strings.TrimSpace(search) + firmFilterSQL := "" + if nFirmaID > 0 { + firmFilterSQL = " AND ISNULL(OM.nFirmaID, 0) = @p4\n" + } sqlText := ` WITH SonOnMaliyet AS ( @@ -999,7 +1003,7 @@ OUTER APPLY ( ) ) CM WHERE OM.rn = 1 - AND (@p4 <= 0 OR ISNULL(OM.nFirmaID, 0) = @p4) +` + firmFilterSQL + ` AND ( @p1 = '' OR RTRIM(CONVERT(VARCHAR(32), ISNULL(OM.nOnMLNo, 0))) LIKE '%' + @p1 + '%' @@ -1014,7 +1018,10 @@ OFFSET @p2 ROWS FETCH NEXT @p3 ROWS ONLY ` - return uretimDB.QueryContext(ctx, sqlText, search, offset, limit, nFirmaID) + if nFirmaID > 0 { + return uretimDB.QueryContext(ctx, sqlText, search, offset, limit, nFirmaID) + } + return uretimDB.QueryContext(ctx, sqlText, search, offset, limit) } func GetProductionHasCostHistoryByProductCode(