product performance grouped kpi improvements
This commit is contained in:
@@ -1380,11 +1380,11 @@ WITH OpenOrderLines AS (
|
|||||||
SELECT AttributeDescription
|
SELECT AttributeDescription
|
||||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||||
WHERE cdItemAttributeDesc.ItemTypeCode = l.ItemTypeCode
|
WHERE cdItemAttributeDesc.ItemTypeCode = l.ItemTypeCode
|
||||||
AND cdItemAttributeDesc.AttributeTypeCode = 42
|
AND cdItemAttributeDesc.AttributeTypeCode = 44
|
||||||
AND cdItemAttributeDesc.AttributeCode = (
|
AND cdItemAttributeDesc.AttributeCode = (
|
||||||
SELECT TOP 1 AttributeCode
|
SELECT TOP 1 AttributeCode
|
||||||
FROM prItemAttribute WITH(NOLOCK)
|
FROM prItemAttribute WITH(NOLOCK)
|
||||||
WHERE AttributeTypeCode = 42
|
WHERE AttributeTypeCode = 44
|
||||||
AND prItemAttribute.ItemTypeCode = l.ItemTypeCode
|
AND prItemAttribute.ItemTypeCode = l.ItemTypeCode
|
||||||
AND prItemAttribute.ItemCode = l.ItemCode
|
AND prItemAttribute.ItemCode = l.ItemCode
|
||||||
)
|
)
|
||||||
@@ -1404,15 +1404,16 @@ WITH OpenOrderLines AS (
|
|||||||
)
|
)
|
||||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||||
), SPACE(0))),
|
), SPACE(0))),
|
||||||
YasGrubu = dbo.HG_Temizlik(ISNULL((
|
YasGrubu = '',
|
||||||
|
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL((
|
||||||
SELECT AttributeDescription
|
SELECT AttributeDescription
|
||||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||||
WHERE cdItemAttributeDesc.ItemTypeCode = l.ItemTypeCode
|
WHERE cdItemAttributeDesc.ItemTypeCode = l.ItemTypeCode
|
||||||
AND cdItemAttributeDesc.AttributeTypeCode = 44
|
AND cdItemAttributeDesc.AttributeTypeCode = 42
|
||||||
AND cdItemAttributeDesc.AttributeCode = (
|
AND cdItemAttributeDesc.AttributeCode = (
|
||||||
SELECT TOP 1 AttributeCode
|
SELECT TOP 1 AttributeCode
|
||||||
FROM prItemAttribute WITH(NOLOCK)
|
FROM prItemAttribute WITH(NOLOCK)
|
||||||
WHERE AttributeTypeCode = 44
|
WHERE AttributeTypeCode = 42
|
||||||
AND prItemAttribute.ItemTypeCode = l.ItemTypeCode
|
AND prItemAttribute.ItemTypeCode = l.ItemTypeCode
|
||||||
AND prItemAttribute.ItemCode = l.ItemCode
|
AND prItemAttribute.ItemCode = l.ItemCode
|
||||||
)
|
)
|
||||||
@@ -1531,6 +1532,7 @@ SELECT TOP (@p1)
|
|||||||
Seri = MAX(o.Seri),
|
Seri = MAX(o.Seri),
|
||||||
YasGrubu = MAX(o.YasGrubu),
|
YasGrubu = MAX(o.YasGrubu),
|
||||||
AskiliYan = MAX(o.AskiliYan),
|
AskiliYan = MAX(o.AskiliYan),
|
||||||
|
UrunIlkGrubu = MAX(o.UrunIlkGrubu),
|
||||||
UrunAnaGrubu = MAX(o.UrunAnaGrubu),
|
UrunAnaGrubu = MAX(o.UrunAnaGrubu),
|
||||||
UrunAltGrubu = MAX(o.UrunAltGrubu),
|
UrunAltGrubu = MAX(o.UrunAltGrubu),
|
||||||
o.MarketKey,
|
o.MarketKey,
|
||||||
@@ -1567,12 +1569,11 @@ ORDER BY SUM(o.AmountUSD) DESC, SUM(o.Qty) DESC, o.ProductCode, o.ColorCode, o.Y
|
|||||||
var r models.ProductPerformanceOrderAnalysisRow
|
var r models.ProductPerformanceOrderAnalysisRow
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&r.ProductCode, &r.ColorCode, &r.YakaKodu, &r.ItemDescription, &r.Kategori, &r.Seri, &r.YasGrubu, &r.AskiliYan,
|
&r.ProductCode, &r.ColorCode, &r.YakaKodu, &r.ItemDescription, &r.Kategori, &r.Seri, &r.YasGrubu, &r.AskiliYan,
|
||||||
&r.UrunAnaGrubu, &r.UrunAltGrubu, &r.MarketKey, &r.OrderQty, &r.OrderUSD, &r.AvgOrderPriceUSD,
|
&r.UrunIlkGrubu, &r.UrunAnaGrubu, &r.UrunAltGrubu, &r.MarketKey, &r.OrderQty, &r.OrderUSD, &r.AvgOrderPriceUSD,
|
||||||
&r.MarketCount, &r.CustomerCount, &r.OrderCount, &r.LineCount, &r.FirstOrderDate, &r.LastOrderDate, &r.EarliestDueDate, &r.OverdueQty,
|
&r.MarketCount, &r.CustomerCount, &r.OrderCount, &r.LineCount, &r.FirstOrderDate, &r.LastOrderDate, &r.EarliestDueDate, &r.OverdueQty,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r.UrunIlkGrubu = r.YasGrubu
|
|
||||||
out = append(out, r)
|
out = append(out, r)
|
||||||
if !seenProducts[r.ProductCode] {
|
if !seenProducts[r.ProductCode] {
|
||||||
seenProducts[r.ProductCode] = true
|
seenProducts[r.ProductCode] = true
|
||||||
@@ -1607,11 +1608,21 @@ ORDER BY SUM(o.AmountUSD) DESC, SUM(o.Qty) DESC, o.ProductCode, o.ColorCode, o.Y
|
|||||||
if strings.TrimSpace(row.ItemDescription) == "" {
|
if strings.TrimSpace(row.ItemDescription) == "" {
|
||||||
row.ItemDescription = attr.itemDescription
|
row.ItemDescription = attr.itemDescription
|
||||||
}
|
}
|
||||||
|
if strings.TrimSpace(row.Kategori) == "" {
|
||||||
row.Kategori = attr.kategori
|
row.Kategori = attr.kategori
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(row.AskiliYan) == "" {
|
||||||
row.AskiliYan = attr.askiliYan
|
row.AskiliYan = attr.askiliYan
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(row.UrunIlkGrubu) == "" {
|
||||||
row.UrunIlkGrubu = attr.urunIlkGrubu
|
row.UrunIlkGrubu = attr.urunIlkGrubu
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(row.UrunAnaGrubu) == "" {
|
||||||
row.UrunAnaGrubu = attr.urunAnaGrubu
|
row.UrunAnaGrubu = attr.urunAnaGrubu
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(row.UrunAltGrubu) == "" {
|
||||||
row.UrunAltGrubu = attr.urunAltGrubu
|
row.UrunAltGrubu = attr.urunAltGrubu
|
||||||
|
}
|
||||||
row.CostPriceUSD = price.cost
|
row.CostPriceUSD = price.cost
|
||||||
row.BasePriceUSD = price.base
|
row.BasePriceUSD = price.base
|
||||||
row.StockQty = stockByKey[productPerformanceVariantKey(row.ProductCode, row.ColorCode, row.YakaKodu)]
|
row.StockQty = stockByKey[productPerformanceVariantKey(row.ProductCode, row.ColorCode, row.YakaKodu)]
|
||||||
@@ -3499,6 +3510,8 @@ func defaultProductPerformanceGroupLevels(mode string) []string {
|
|||||||
|
|
||||||
func mapGroupValue(row map[string]any, field string) string {
|
func mapGroupValue(row map[string]any, field string) string {
|
||||||
switch field {
|
switch field {
|
||||||
|
case "urun_ilk_grubu":
|
||||||
|
return cleanProductPerformanceFirstGroup(stringFromMap(row, "urun_ilk_grubu"))
|
||||||
case "market_key":
|
case "market_key":
|
||||||
return displayProductPerformanceMarketName(stringFromMap(row, "market_key"))
|
return displayProductPerformanceMarketName(stringFromMap(row, "market_key"))
|
||||||
default:
|
default:
|
||||||
@@ -3583,6 +3596,9 @@ func dominantProductPerformanceValue(rows []map[string]any, field string) string
|
|||||||
counts := map[string]int{}
|
counts := map[string]int{}
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
value := stringFromMap(row, field)
|
value := stringFromMap(row, field)
|
||||||
|
if field == "urun_ilk_grubu" {
|
||||||
|
value = cleanProductPerformanceFirstGroup(value)
|
||||||
|
}
|
||||||
if value != "" {
|
if value != "" {
|
||||||
counts[value]++
|
counts[value]++
|
||||||
}
|
}
|
||||||
@@ -3657,6 +3673,18 @@ func stringFromMap(row map[string]any, field string) string {
|
|||||||
return strings.TrimSpace(fmt.Sprint(value))
|
return strings.TrimSpace(fmt.Sprint(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanProductPerformanceFirstGroup(value string) string {
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
normalized := strings.ToUpper(value)
|
||||||
|
normalized = strings.NewReplacer("İ", "I", "Ş", "S", "Ğ", "G", "Ü", "U", "Ö", "O", "Ç", "C").Replace(normalized)
|
||||||
|
switch normalized {
|
||||||
|
case "YETISKIN", "YETISKIN/GARSON", "GARSON":
|
||||||
|
return ""
|
||||||
|
default:
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func floatFromMap(row map[string]any, field string) float64 {
|
func floatFromMap(row map[string]any, field string) float64 {
|
||||||
return floatFromAny(row[field])
|
return floatFromAny(row[field])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3225,13 +3225,26 @@ function productCategoryValue (row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function productFirstGroupValue (row) {
|
function productFirstGroupValue (row) {
|
||||||
return row?.urun_ilk_grubu || ''
|
return cleanProductFirstGroupValue(row?.urun_ilk_grubu)
|
||||||
}
|
}
|
||||||
|
|
||||||
function productMainGroupValue (row) {
|
function productMainGroupValue (row) {
|
||||||
return row?.urun_ana_grubu || ''
|
return row?.urun_ana_grubu || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanProductFirstGroupValue (value) {
|
||||||
|
const text = String(value || '').trim()
|
||||||
|
const normalized = text
|
||||||
|
.toLocaleUpperCase('tr-TR')
|
||||||
|
.replaceAll('İ', 'I')
|
||||||
|
.replaceAll('Ş', 'S')
|
||||||
|
.replaceAll('Ğ', 'G')
|
||||||
|
.replaceAll('Ü', 'U')
|
||||||
|
.replaceAll('Ö', 'O')
|
||||||
|
.replaceAll('Ç', 'C')
|
||||||
|
return ['YETISKIN', 'YETISKIN/GARSON', 'GARSON'].includes(normalized) ? '' : text
|
||||||
|
}
|
||||||
|
|
||||||
function rawProductCellValue (row, name) {
|
function rawProductCellValue (row, name) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'kategori': return productCategoryValue(row)
|
case 'kategori': return productCategoryValue(row)
|
||||||
|
|||||||
Reference in New Issue
Block a user