From 945868d83d0af1e9f3c6d1f6d3d7f3efda81390c Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Fri, 28 Aug 2026 19:36:03 +0300 Subject: [PATCH] Fix product performance grouped JSON build --- svc/models/production_product_costing.go | 3 +++ svc/queries/production_product_costing.go | 23 +++++++++++++++++++ svc/routes/production_product_costing.go | 3 +++ .../pages/ProductionProductCostingHasCost.vue | 5 +++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/svc/models/production_product_costing.go b/svc/models/production_product_costing.go index 6935adf..fe752df 100644 --- a/svc/models/production_product_costing.go +++ b/svc/models/production_product_costing.go @@ -33,6 +33,9 @@ type ProductionHasCostProductRow struct { LTutarTL float64 `json:"lTutarTL"` LTutarUSD float64 `json:"lTutarUSD"` LTutarEURO float64 `json:"lTutarEURO"` + IscilikTutari float64 `json:"IscilikTutari"` + IscilikPrBr string `json:"IscilikPrBr"` + IscilikUSDTutari float64 `json:"IscilikUSDTutari"` DteGuncellemeTarihi string `json:"dteGuncellemeTarihi"` SGuncellemeKullaniciAdi string `json:"sGuncellemeKullaniciAdi"` NUrtReceteID string `json:"nUrtReceteID"` diff --git a/svc/queries/production_product_costing.go b/svc/queries/production_product_costing.go index 9864f3b..7dd11b5 100644 --- a/svc/queries/production_product_costing.go +++ b/svc/queries/production_product_costing.go @@ -927,6 +927,9 @@ SELECT ISNULL(OM.lTutarTL, 0) AS lTutarTL, ISNULL(OM.lTutarUSD, 0) AS lTutarUSD, ISNULL(OM.lTutarEURO, 0) AS lTutarEURO, + ISNULL(CM.IscilikTutari, 0) AS IscilikTutari, + ISNULL(CM.IscilikPrBr, '') AS IscilikPrBr, + ISNULL(CM.IscilikUSDTutari, 0) AS IscilikUSDTutari, CONVERT(VARCHAR(10), OM.dteGuncellemeTarihi, 23) AS dteGuncellemeTarihi, ISNULL(OM.sGuncellemeKullaniciAdi, '') AS sGuncellemeKullaniciAdi, RTRIM(CONVERT(VARCHAR(32), ISNULL(OM.nUrtReceteID, 0))) AS nUrtReceteID, @@ -941,6 +944,26 @@ SELECT FROM SonOnMaliyet OM LEFT JOIN SonSiparis SS ON SS.UrunKodu = LTRIM(RTRIM(OM.UrunKodu)) +OUTER APPLY ( + SELECT + SUM(ISNULL(D.fiyat_girilen, 0) * ISNULL(D.lMiktar, 0)) AS IscilikTutari, + CASE + WHEN COUNT(DISTINCT UPPER(ISNULL(NULLIF(LTRIM(RTRIM(D.fiyat_doviz)), ''), 'USD'))) = 1 + THEN MAX(UPPER(ISNULL(NULLIF(LTRIM(RTRIM(D.fiyat_doviz)), ''), 'USD'))) + WHEN COUNT(*) > 0 THEN 'MIX' + ELSE '' + END AS IscilikPrBr, + SUM(ISNULL(D.lMiktar, 0) * ISNULL(D.lDovizFiyati, 0)) AS IscilikUSDTutari + FROM dbo.spUrtOnMLMasDet D + LEFT JOIN dbo.spUrtOnMLHammaddeTuru T + ON T.nHammaddeTuruNo = D.nHammaddeTuruNo + WHERE D.nOnMLNo = OM.nOnMLNo + AND ISNULL(D.fiyat_girilen, 0) > 0 + AND ( + UPPER(ISNULL(NULLIF(LTRIM(RTRIM(D.sAciklama3)), ''), LTRIM(RTRIM(ISNULL(T.sAciklama3, ''))))) LIKE '%CM1%' + OR UPPER(ISNULL(NULLIF(LTRIM(RTRIM(D.sAciklama3)), ''), LTRIM(RTRIM(ISNULL(T.sAciklama3, ''))))) LIKE '%CM2%' + ) +) CM WHERE OM.rn = 1 AND ( @p1 = '' diff --git a/svc/routes/production_product_costing.go b/svc/routes/production_product_costing.go index 4000c04..7e28e7f 100644 --- a/svc/routes/production_product_costing.go +++ b/svc/routes/production_product_costing.go @@ -221,6 +221,9 @@ func GetProductionHasCostProductsHandler(w http.ResponseWriter, r *http.Request) &item.LTutarTL, &item.LTutarUSD, &item.LTutarEURO, + &item.IscilikTutari, + &item.IscilikPrBr, + &item.IscilikUSDTutari, &item.DteGuncellemeTarihi, &item.SGuncellemeKullaniciAdi, &item.NUrtReceteID, diff --git a/ui/src/pages/ProductionProductCostingHasCost.vue b/ui/src/pages/ProductionProductCostingHasCost.vue index 9bc92a4..b0b5312 100644 --- a/ui/src/pages/ProductionProductCostingHasCost.vue +++ b/ui/src/pages/ProductionProductCostingHasCost.vue @@ -189,6 +189,9 @@ const columns = [ { name: 'lTutarTL', label: 'lTutarTL', field: 'lTutarTL', align: 'right', sortable: true, format: val => formatMoney(val), style: 'width:6%', headerStyle: 'width:6%' }, { name: 'lTutarUSD', label: 'lTutarUSD', field: 'lTutarUSD', align: 'right', sortable: true, format: val => formatMoney(val), style: 'width:6%', headerStyle: 'width:6%' }, { name: 'lTutarEURO', label: 'lTutarEURO', field: 'lTutarEURO', align: 'right', sortable: true, format: val => formatMoney(val), style: 'width:6%', headerStyle: 'width:6%' }, + { name: 'IscilikTutari', label: 'Iscilik Tutari', field: 'IscilikTutari', align: 'right', sortable: true, format: val => formatMoney(val), style: 'width:6%', headerStyle: 'width:6%' }, + { name: 'IscilikPrBr', label: 'Iscilik Pr.Br.', field: 'IscilikPrBr', align: 'center', sortable: true, style: 'width:5%', headerStyle: 'width:5%' }, + { name: 'IscilikUSDTutari', label: 'Iscilik USD Tutari', field: 'IscilikUSDTutari', align: 'right', sortable: true, format: val => formatMoney(val), style: 'width:6%', headerStyle: 'width:6%' }, { name: 'dteGuncellemeTarihi', label: 'dteGuncellemeTarihi', field: 'dteGuncellemeTarihi', align: 'center', sortable: true, format: val => formatDateTR(val), style: 'width:7%', headerStyle: 'width:7%' }, { name: 'sGuncellemeKullaniciAdi', label: 'sGuncellemeKullaniciAdi', field: 'sGuncellemeKullaniciAdi', align: 'left', sortable: true, style: 'width:7%', headerStyle: 'width:7%' }, { name: 'nUrtReceteID', label: 'nUrtReceteID', field: 'nUrtReceteID', align: 'left', sortable: true, style: 'width:6%', headerStyle: 'width:6%' }, @@ -393,7 +396,7 @@ function escapeExcelCsvCell (value) { return `"${text.replace(/"/g, '""')}"` } -const excelNumericColumns = new Set(['ceketDepoGiris', 'pantolonDepoGiris', 'yelekDepoGiris', 'lTutarTL', 'lTutarUSD', 'lTutarEURO']) +const excelNumericColumns = new Set(['ceketDepoGiris', 'pantolonDepoGiris', 'yelekDepoGiris', 'lTutarTL', 'lTutarUSD', 'lTutarEURO', 'IscilikTutari', 'IscilikUSDTutari']) function formatExcelCsvCell (col, rawValue, displayValue) { if (excelNumericColumns.has(col?.name)) {