product performance grouped kpi improvements
This commit is contained in:
@@ -56,7 +56,7 @@ func productPerformanceStockQuery() string {
|
||||
FROM (VALUES
|
||||
('1-0-14'),('1-0-10'),('1-0-8'),('1-2-5'),('1-2-4'),('1-0-12'),('100'),('1-0-28'),
|
||||
('1-0-24'),('1-2-6'),('1-1-14'),('1-0-2'),('1-0-52'),('1-1-2'),('1-0-21'),('1-1-3'),
|
||||
('1-0-33'),('101'),('1-014'),('1-0-49'),('1-0-36')
|
||||
('1-0-33'),('101'),('1-014'),('1-0-49'),('1-0-36'),('1-0-4'),('1-0-29')
|
||||
) W(WarehouseCode)
|
||||
),
|
||||
Raw AS (
|
||||
@@ -76,17 +76,7 @@ Raw AS (
|
||||
INNER JOIN ActiveWarehouses W
|
||||
ON W.WarehouseCode = LTRIM(RTRIM(S.WarehouseCode))
|
||||
WHERE S.ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(S.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(S.ItemCode))) = 13
|
||||
AND (@p3 = '' OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE @p3 + '%')
|
||||
AND S.DocumentDate < DATEADD(DAY, 1, @p2)
|
||||
GROUP BY
|
||||
@@ -259,14 +249,6 @@ CurrentSource AS (
|
||||
INNER JOIN ActiveWarehouses W ON W.WarehouseCode = LTRIM(RTRIM(S.WarehouseCode))
|
||||
WHERE S.ItemTypeCode = 1
|
||||
AND LEN(LTRIM(RTRIM(S.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
AND (@p3 = '' OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE @p3 + '%')
|
||||
AND S.DocumentDate < DATEADD(DAY, 1, @p2)
|
||||
GROUP BY S.WarehouseCode, S.ItemCode, S.ColorCode, S.ItemDim1Code, S.ItemDim2Code, S.ItemDim3Code
|
||||
@@ -293,16 +275,10 @@ CurrentAvailable AS (
|
||||
I.ColorCode,
|
||||
I.YakaKodu,
|
||||
StockQty = CAST(ROUND(SUM(
|
||||
CASE
|
||||
WHEN ISNULL(I.InventoryQty1, 0)
|
||||
- ISNULL(I.PickingQty1, 0)
|
||||
- ISNULL(I.ReserveQty1, 0)
|
||||
- ISNULL(I.DispOrderQty1, 0) < 0 THEN 0
|
||||
ELSE ISNULL(I.InventoryQty1, 0)
|
||||
- ISNULL(I.PickingQty1, 0)
|
||||
- ISNULL(I.ReserveQty1, 0)
|
||||
- ISNULL(I.DispOrderQty1, 0)
|
||||
END),
|
||||
ISNULL(I.InventoryQty1, 0)
|
||||
- ISNULL(I.PickingQty1, 0)
|
||||
- ISNULL(I.ReserveQty1, 0)
|
||||
- ISNULL(I.DispOrderQty1, 0)),
|
||||
2
|
||||
) AS decimal(18,4)),
|
||||
InQty = CAST(0 AS decimal(18,4)),
|
||||
@@ -321,14 +297,6 @@ CurrentAvailable AS (
|
||||
AND cdItem.IsBlocked = 0
|
||||
WHERE I.InventoryQty1 >= 0
|
||||
AND LEN(I.ProductCode) = 13
|
||||
AND (
|
||||
I.ProductCode LIKE 'S%'
|
||||
OR I.ProductCode LIKE 'O%'
|
||||
OR I.ProductCode LIKE 'N%'
|
||||
OR I.ProductCode LIKE 'X%'
|
||||
OR I.ProductCode LIKE 'I%'
|
||||
OR I.ProductCode LIKE 'A%'
|
||||
)
|
||||
GROUP BY I.ProductCode, I.ColorCode, I.YakaKodu
|
||||
)
|
||||
SELECT
|
||||
@@ -718,13 +686,7 @@ func productPerformanceRefreshStage(raw string) string {
|
||||
}
|
||||
|
||||
func productPerformanceProductPrefix(raw string) string {
|
||||
prefix := strings.ToUpper(strings.TrimSpace(raw))
|
||||
switch prefix {
|
||||
case "", "S", "O", "N", "X", "I", "A":
|
||||
return prefix
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
return strings.ToUpper(strings.TrimSpace(raw))
|
||||
}
|
||||
|
||||
func normalizeProductPerformanceProductCode(raw string) string {
|
||||
@@ -1648,14 +1610,6 @@ WITH OpenOrderLines AS (
|
||||
AND l.ItemTypeCode = 1
|
||||
AND ISNULL(l.Qty1, 0) > 0
|
||||
AND LEN(LTRIM(RTRIM(l.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
),
|
||||
Spread AS (
|
||||
SELECT
|
||||
@@ -1867,14 +1821,6 @@ WITH OpenOrderLines AS (
|
||||
AND l.ItemTypeCode = 1
|
||||
AND ISNULL(l.Qty1, 0) > 0
|
||||
AND LEN(LTRIM(RTRIM(l.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
SELECT TOP (@p1)
|
||||
ProductCode,
|
||||
@@ -2082,7 +2028,6 @@ WITH OpenOrderLines AS (
|
||||
AND l.ItemTypeCode = 1
|
||||
AND ISNULL(l.Qty1, 0) > 0
|
||||
AND LEN(LTRIM(RTRIM(l.ItemCode))) = 13
|
||||
AND (UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'S%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'O%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'N%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'X%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'I%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'A%')
|
||||
)
|
||||
SELECT TOP (@p1)
|
||||
ProductCode, ColorCode, YakaKodu, MAX(ItemDescription), MarketKey, CurrAccCode, CustomerName,
|
||||
@@ -2207,7 +2152,6 @@ WITH OpenOrderLines AS (
|
||||
AND l.ItemTypeCode = 1
|
||||
AND ISNULL(l.Qty1, 0) > 0
|
||||
AND LEN(LTRIM(RTRIM(l.ItemCode))) = 13
|
||||
AND (UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'S%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'O%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'N%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'X%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'I%' OR UPPER(LTRIM(RTRIM(l.ItemCode))) LIKE 'A%')
|
||||
)
|
||||
SELECT TOP (@p1)
|
||||
MarketKey, CurrAccCode, CustomerName, OrderNumber, CONVERT(varchar, OrderDate, 23), CONVERT(varchar, DueDate, 23),
|
||||
@@ -3925,7 +3869,7 @@ func ListProductPerformanceStockSizes(ctx context.Context, productCode, colorCod
|
||||
FROM (VALUES
|
||||
('1-0-14'),('1-0-10'),('1-0-8'),('1-2-5'),('1-2-4'),('1-0-12'),('100'),('1-0-28'),
|
||||
('1-0-24'),('1-2-6'),('1-1-14'),('1-0-2'),('1-0-52'),('1-1-2'),('1-0-21'),('1-1-3'),
|
||||
('1-0-33'),('101'),('1-014'),('1-0-49'),('1-0-36')
|
||||
('1-0-33'),('101'),('1-014'),('1-0-49'),('1-0-36'),('1-0-4'),('1-0-29')
|
||||
) W(WarehouseCode)
|
||||
),
|
||||
Stock AS (
|
||||
@@ -3988,20 +3932,15 @@ AvailableBySizeWarehouse AS (
|
||||
SELECT
|
||||
S.SizeCode,
|
||||
StockQty =
|
||||
CASE
|
||||
WHEN ISNULL(S.InventoryQty1, 0)
|
||||
- ISNULL(P.PickingQty1, 0)
|
||||
- ISNULL(R.ReserveQty1, 0)
|
||||
- ISNULL(D.DispOrderQty1, 0) < 0 THEN 0
|
||||
ELSE ISNULL(S.InventoryQty1, 0)
|
||||
- ISNULL(P.PickingQty1, 0)
|
||||
- ISNULL(R.ReserveQty1, 0)
|
||||
- ISNULL(D.DispOrderQty1, 0)
|
||||
END
|
||||
ISNULL(S.InventoryQty1, 0)
|
||||
- ISNULL(P.PickingQty1, 0)
|
||||
- ISNULL(R.ReserveQty1, 0)
|
||||
- ISNULL(D.DispOrderQty1, 0)
|
||||
FROM Stock S
|
||||
LEFT JOIN Pick P ON P.SizeCode = S.SizeCode AND P.WarehouseCode = S.WarehouseCode
|
||||
LEFT JOIN Reserve R ON R.SizeCode = S.SizeCode AND R.WarehouseCode = S.WarehouseCode
|
||||
LEFT JOIN Disp D ON D.SizeCode = S.SizeCode AND D.WarehouseCode = S.WarehouseCode
|
||||
WHERE S.InventoryQty1 >= 0
|
||||
)
|
||||
SELECT
|
||||
SizeCode,
|
||||
|
||||
@@ -18,76 +18,11 @@ func productPerformanceSalesSQL() string {
|
||||
AND cdItemDesc.ItemCode = I.ItemCode
|
||||
AND cdItemDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAnaGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = I.ItemTypeCode
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 1
|
||||
AND prItemAttribute.ItemTypeCode = I.ItemTypeCode
|
||||
AND prItemAttribute.ItemCode = I.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAltGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = I.ItemTypeCode
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 2
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 2
|
||||
AND prItemAttribute.ItemTypeCode = I.ItemTypeCode
|
||||
AND prItemAttribute.ItemCode = I.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
Kategori = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = I.ItemTypeCode
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 44
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 44
|
||||
AND prItemAttribute.ItemTypeCode = I.ItemTypeCode
|
||||
AND prItemAttribute.ItemCode = I.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = I.ItemTypeCode
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 42
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 42
|
||||
AND prItemAttribute.ItemTypeCode = I.ItemTypeCode
|
||||
AND prItemAttribute.ItemCode = I.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
AskiliYan = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = I.ItemTypeCode
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 45
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 45
|
||||
AND prItemAttribute.ItemTypeCode = I.ItemTypeCode
|
||||
AND prItemAttribute.ItemCode = I.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAnaGrubu = dbo.HG_Temizlik(ISNULL(PAF.ProductAtt01, SPACE(0))),
|
||||
UrunAltGrubu = dbo.HG_Temizlik(ISNULL(PAF.ProductAtt02, SPACE(0))),
|
||||
Kategori = dbo.HG_Temizlik(ISNULL(PAF.ProductAtt44, SPACE(0))),
|
||||
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL(PAF.ProductAtt42, SPACE(0))),
|
||||
AskiliYan = dbo.HG_Temizlik(ISNULL(PAF.ProductAtt45, SPACE(0))),
|
||||
ChannelCode = CASE
|
||||
WHEN I.ProcessCode IN ('R') THEN dbo.HG_Temizlik(ISNULL((
|
||||
SELECT OfficeDescription
|
||||
@@ -159,20 +94,12 @@ func productPerformanceSalesSQL() string {
|
||||
LEFT OUTER JOIN CustomerAttributesFilter CAF WITH(NOLOCK)
|
||||
ON CAF.CurrAccTypeCode = I.CurrAccTypeCode
|
||||
AND CAF.CurrAccCode = I.CurrAccCode
|
||||
LEFT OUTER JOIN ProductAttributesFilter PAF WITH(NOLOCK)
|
||||
ON PAF.ItemCode = I.ItemCode
|
||||
WHERE I.InvoiceDate >= @p1
|
||||
AND I.InvoiceDate < DATEADD(DAY, 1, @p2)
|
||||
AND I.ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(I.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(I.ItemCode))) = 13
|
||||
AND (@p3 = '' OR UPPER(LTRIM(RTRIM(I.ItemCode))) LIKE @p3 + '%')
|
||||
AND (
|
||||
(I.CompanyCode = 1 AND I.ATAtt01 IN (1,2) AND I.ProcessCode IN ('WS','R'))
|
||||
@@ -249,17 +176,7 @@ Raw AS (
|
||||
INNER JOIN ActiveWarehouses W
|
||||
ON W.WarehouseCode = LTRIM(RTRIM(S.WarehouseCode))
|
||||
WHERE S.ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(S.ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(S.ItemCode))) = 13
|
||||
AND (@p3 = '' OR UPPER(LTRIM(RTRIM(S.ItemCode))) LIKE @p3 + '%')
|
||||
AND S.DocumentDate < DATEADD(DAY, 1, @p2)
|
||||
GROUP BY
|
||||
@@ -385,49 +302,19 @@ func productPerformancePriceSQL() string {
|
||||
SELECT DISTINCT ItemCode
|
||||
FROM cdItem WITH(NOLOCK)
|
||||
WHERE ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (@p1 = '' OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE @p1 + '%')
|
||||
UNION
|
||||
SELECT DISTINCT ItemCode
|
||||
FROM trPriceListLine WITH(NOLOCK)
|
||||
WHERE ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (@p1 = '' OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE @p1 + '%')
|
||||
UNION
|
||||
SELECT DISTINCT ItemCode
|
||||
FROM prItemBasePrice WITH(NOLOCK)
|
||||
WHERE ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (
|
||||
UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'S%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'O%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'N%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'X%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'I%'
|
||||
OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (@p1 = '' OR UPPER(LTRIM(RTRIM(ItemCode))) LIKE @p1 + '%')
|
||||
),
|
||||
LatestPrice AS (
|
||||
@@ -483,81 +370,18 @@ SELECT
|
||||
AND cdItemDesc.ItemCode = pc.ItemCode
|
||||
AND cdItemDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
Kategori = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 44
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 44
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
AskiliYan = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 45
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 45
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 42
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 42
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAnaGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 1
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAltGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 2
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 2
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
Kategori = dbo.HG_Temizlik(ISNULL(paf.ProductAtt44, SPACE(0))),
|
||||
AskiliYan = dbo.HG_Temizlik(ISNULL(paf.ProductAtt45, SPACE(0))),
|
||||
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL(paf.ProductAtt42, SPACE(0))),
|
||||
UrunAnaGrubu = dbo.HG_Temizlik(ISNULL(paf.ProductAtt01, SPACE(0))),
|
||||
UrunAltGrubu = dbo.HG_Temizlik(ISNULL(paf.ProductAtt02, SPACE(0))),
|
||||
CostPriceUsd = ISNULL(c.CostPriceUsd, 0),
|
||||
BasePriceUsd = ISNULL(bp.BasePriceUsd, 0),
|
||||
BasePriceTry = ISNULL(bp.BasePriceTry, 0),
|
||||
c.LastPricingDate
|
||||
FROM ProductCodes pc
|
||||
LEFT JOIN ProductAttributesFilter paf WITH(NOLOCK)
|
||||
ON paf.ItemCode = pc.ItemCode
|
||||
LEFT JOIN BasePrice bp ON bp.ItemCode = pc.ItemCode
|
||||
LEFT JOIN Cost c ON c.ItemCode = pc.ItemCode AND c.rn = 1
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user