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(