diff --git a/svc/queries/production_product_costing.go b/svc/queries/production_product_costing.go
index 20ada8f..0ea4ab3 100644
--- a/svc/queries/production_product_costing.go
+++ b/svc/queries/production_product_costing.go
@@ -908,6 +908,7 @@ func GetProductionHasCostProducts(
search string,
offset int,
limit int,
+ nFirmaID int,
) (*sql.Rows, error) {
search = strings.TrimSpace(search)
@@ -998,6 +999,7 @@ OUTER APPLY (
)
) CM
WHERE OM.rn = 1
+ AND (@p4 <= 0 OR ISNULL(OM.nFirmaID, 0) = @p4)
AND (
@p1 = ''
OR RTRIM(CONVERT(VARCHAR(32), ISNULL(OM.nOnMLNo, 0))) LIKE '%' + @p1 + '%'
@@ -1012,7 +1014,7 @@ OFFSET @p2 ROWS
FETCH NEXT @p3 ROWS ONLY
`
- return uretimDB.QueryContext(ctx, sqlText, search, offset, limit)
+ return uretimDB.QueryContext(ctx, sqlText, search, offset, limit, nFirmaID)
}
func GetProductionHasCostHistoryByProductCode(
diff --git a/svc/routes/production_product_costing.go b/svc/routes/production_product_costing.go
index 55e596a..6594533 100644
--- a/svc/routes/production_product_costing.go
+++ b/svc/routes/production_product_costing.go
@@ -197,11 +197,12 @@ func GetProductionHasCostProductsHandler(w http.ResponseWriter, r *http.Request)
search := strings.TrimSpace(r.URL.Query().Get("search"))
offset := parsePositiveIntOrDefault(r.URL.Query().Get("offset"), 0)
limit := parsePositiveIntOrDefault(r.URL.Query().Get("limit"), 300)
+ nFirmaID, _ := strconv.Atoi(strings.TrimSpace(r.URL.Query().Get("n_firma_id")))
if limit > 1000 {
limit = 1000
}
- rows, err := queries.GetProductionHasCostProducts(r.Context(), uretimDB, search, offset, limit)
+ rows, err := queries.GetProductionHasCostProducts(r.Context(), uretimDB, search, offset, limit, nFirmaID)
if err != nil {
log.Printf("❌ [ProductionHasCost] query error: %v", err)
http.Error(w, "Veritabanı hatası", http.StatusInternalServerError)
diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
index 808d7c5..f719e86 100644
--- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue
+++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
@@ -142,9 +142,11 @@
outline
class="pcd-toolbar-btn"
:loading="firmCostHistoryLoading"
- :disable="!detailHeader || detailLoading || saveLoading || bulkPriceLoading"
+ :disable="!detailHeader || detailLoading || saveLoading || bulkPriceLoading || !currentFirmaID"
@click="openFirmCostHistoryDialog"
- />
+ >
+