diff --git a/svc/models/orderproductionitem.go b/svc/models/orderproductionitem.go index a98abfe..c3ee4ad 100644 --- a/svc/models/orderproductionitem.go +++ b/svc/models/orderproductionitem.go @@ -17,6 +17,9 @@ type OrderProductionItem struct { OldDim2 string `json:"OldDim2"` OldDesc string `json:"OldDesc"` OldQty float64 `json:"OldQty"` + OldDocCurrencyCode string `json:"OldDocCurrencyCode"` + OldNetAmount float64 `json:"OldNetAmount"` + OldNetAmountUSD float64 `json:"OldNetAmountUSD"` NewItemCode string `json:"NewItemCode"` NewColor string `json:"NewColor"` diff --git a/svc/queries/orderproduction_items.go b/svc/queries/orderproduction_items.go index 0f538da..615268e 100644 --- a/svc/queries/orderproduction_items.go +++ b/svc/queries/orderproduction_items.go @@ -36,6 +36,26 @@ SELECT ISNULL(l.LineDescription,'') AS OldDesc, CAST(ISNULL(l.Qty1, 0) AS FLOAT) AS OldQty, + ISNULL(h.DocCurrencyCode,'TRY') AS OldDocCurrencyCode, + CAST(ISNULL(c.NetAmount, 0) AS FLOAT) AS OldNetAmount, + CAST( + CASE + WHEN ISNULL(h.DocCurrencyCode,'TRY') = 'USD' + THEN ISNULL(c.NetAmount,0) + + WHEN ISNULL(h.DocCurrencyCode,'TRY') = 'TRY' + AND usd.Rate > 0 + THEN ISNULL(c.NetAmount,0) / usd.Rate + + WHEN ISNULL(h.DocCurrencyCode,'TRY') IN ('EUR','GBP') + AND cur.Rate > 0 + AND usd.Rate > 0 + THEN (ISNULL(c.NetAmount,0) * cur.Rate) / usd.Rate + + ELSE 0 + END + AS FLOAT) AS OldNetAmountUSD, + CAST('' AS NVARCHAR(60)) AS NewItemCode, CAST('' AS NVARCHAR(30)) AS NewColor, CAST('' AS NVARCHAR(30)) AS NewDim2, @@ -46,6 +66,33 @@ SELECT CAST(0 AS bit) AS IsVariantMissing FROM dbo.trOrderLine l +JOIN dbo.trOrderHeader h + ON h.OrderHeaderID = l.OrderHeaderID +LEFT JOIN dbo.trOrderLineCurrency c WITH (NOLOCK) + ON c.OrderLineID = l.OrderLineID + AND c.CurrencyCode = ISNULL(h.DocCurrencyCode,'TRY') + +OUTER APPLY ( + SELECT TOP 1 Rate + FROM dbo.AllExchangeRates + WHERE CurrencyCode = 'USD' + AND RelationCurrencyCode = 'TRY' + AND ExchangeTypeCode = 6 + AND Rate > 0 + AND Date <= CAST(GETDATE() AS date) + ORDER BY Date DESC +) usd + +OUTER APPLY ( + SELECT TOP 1 Rate + FROM dbo.AllExchangeRates + WHERE CurrencyCode = ISNULL(h.DocCurrencyCode,'TRY') + AND RelationCurrencyCode = 'TRY' + AND ExchangeTypeCode = 6 + AND Rate > 0 + AND Date <= CAST(GETDATE() AS date) + ORDER BY Date DESC +) cur WHERE l.OrderHeaderID = @p1 AND ISNULL(l.ItemCode,'') LIKE 'U%' ORDER BY l.SortOrder, l.OrderLineID diff --git a/svc/routes/orderproductionitems.go b/svc/routes/orderproductionitems.go index 6e4b1dd..ad441b8 100644 --- a/svc/routes/orderproductionitems.go +++ b/svc/routes/orderproductionitems.go @@ -62,6 +62,9 @@ func OrderProductionItemsRoute(mssql *sql.DB) http.Handler { &o.OldDim2, &o.OldDesc, &o.OldQty, + &o.OldDocCurrencyCode, + &o.OldNetAmount, + &o.OldNetAmountUSD, &o.NewItemCode, &o.NewColor, &o.NewDim2, diff --git a/ui/src/pages/OrderProductionUpdate.vue b/ui/src/pages/OrderProductionUpdate.vue index 10a7d6a..094f71a 100644 --- a/ui/src/pages/OrderProductionUpdate.vue +++ b/ui/src/pages/OrderProductionUpdate.vue @@ -456,6 +456,30 @@ const columns = [ { name: 'OldDesc', label: 'Eski Aciklama', field: 'OldDesc', align: 'left', sortable: false, style: 'min-width:130px;', headerStyle: 'min-width:130px;', headerClasses: 'col-old col-desc', classes: 'col-old col-desc' }, { name: 'OldSizes', label: 'Bedenler', field: 'OldSizesLabel', align: 'left', sortable: false, style: 'min-width:90px;', headerStyle: 'min-width:90px;', headerClasses: 'col-old col-wrap', classes: 'col-old col-wrap' }, { name: 'OldTotalQty', label: 'Siparis Adedi', field: 'OldTotalQtyLabel', align: 'right', sortable: false, style: 'min-width:90px;', headerStyle: 'min-width:90px;', headerClasses: 'col-old', classes: 'col-old' }, + { + name: 'OldTotalAmount', + label: 'Tutar', + field: 'OldTotalAmount', + align: 'right', + sortable: true, + style: 'min-width:110px;white-space:nowrap', + headerStyle: 'min-width:110px;white-space:nowrap', + headerClasses: 'col-old', + classes: 'col-old', + format: (val, row) => `${Number(val || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${row?.OldDocCurrencyCode || ''}`.trim() + }, + { + name: 'OldTotalAmountUSD', + label: 'Tutar (USD)', + field: 'OldTotalAmountUSD', + align: 'right', + sortable: true, + style: 'min-width:110px;white-space:nowrap', + headerStyle: 'min-width:110px;white-space:nowrap', + headerClasses: 'col-old', + classes: 'col-old', + format: val => `${Number(val || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} USD` + }, { name: 'OldDueDate', label: 'Eski Termin', field: 'OldDueDate', align: 'left', sortable: true, style: 'min-width:100px;', headerStyle: 'min-width:100px;', headerClasses: 'col-old', classes: 'col-old' }, { name: 'NewItemCode', label: 'Yeni Urun Kodu', field: 'NewItemCode', align: 'left', sortable: false, style: 'min-width:130px;', headerStyle: 'min-width:130px;', headerClasses: 'col-new col-new-first', classes: 'col-new col-new-first' }, { name: 'NewColor', label: 'Yeni Urun Rengi', field: 'NewColor', align: 'left', sortable: false, style: 'min-width:100px;', headerStyle: 'min-width:100px;', headerClasses: 'col-new', classes: 'col-new' }, @@ -1735,6 +1759,9 @@ function groupItems (items, prevRows = []) { OldSizesLabel: '', OldTotalQty: 0, OldTotalQtyLabel: '0', + OldDocCurrencyCode: String(it?.OldDocCurrencyCode || '').trim() || 'TRY', + OldTotalAmount: 0, + OldTotalAmountUSD: 0, NewItemCode: prev.NewItemCode || '', NewColor: prev.NewColor || '', NewDim2: prev.NewDim2 || '', @@ -1770,6 +1797,8 @@ function groupItems (items, prevRows = []) { g.__sizeMap[size] = (g.__sizeMap[size] || 0) + 1 } g.__oldQtyTotal = Number(g.__oldQtyTotal || 0) + Number(it?.OldQty || 0) + g.__oldAmountTotal = Number(g.__oldAmountTotal || 0) + Number(it?.OldNetAmount || 0) + g.__oldAmountUsdTotal = Number(g.__oldAmountUsdTotal || 0) + Number(it?.OldNetAmountUSD || 0) if (it?.IsVariantMissing) g.IsVariantMissing = true } @@ -1780,6 +1809,8 @@ function groupItems (items, prevRows = []) { g.OldSizesLabel = sizes.label g.OldTotalQty = Number(g.__oldQtyTotal || 0) g.OldTotalQtyLabel = formatQtyLabel(g.OldTotalQty) + g.OldTotalAmount = Number(g.__oldAmountTotal || 0) + g.OldTotalAmountUSD = Number(g.__oldAmountUsdTotal || 0) const info = store.classifyItemCode(g.NewItemCode) g.NewItemCode = info.normalized g.NewItemMode = info.mode @@ -1789,6 +1820,8 @@ function groupItems (items, prevRows = []) { } delete g.__sizeMap delete g.__oldQtyTotal + delete g.__oldAmountTotal + delete g.__oldAmountUsdTotal out.push(g) } diff --git a/ui/src/pages/ProductionProductCostingMTBolumMapping.vue b/ui/src/pages/ProductionProductCostingMTBolumMapping.vue index 49e3fb1..3ea538c 100644 --- a/ui/src/pages/ProductionProductCostingMTBolumMapping.vue +++ b/ui/src/pages/ProductionProductCostingMTBolumMapping.vue @@ -686,6 +686,8 @@ async function saveKeys (keys) { clearDirty() // after saving, clear save selection to avoid accidental re-save saveSelectedKeyMap.value = {} + // after saving, also clear the search input so the sheet reloads unfiltered + filters.value.search = '' await refreshAll() } catch (e) { const detail = await extractApiErrorDetail(e)