Fix product performance grouped JSON build
This commit is contained in:
@@ -6282,8 +6282,8 @@ func productPerformanceProductScore(suffix string, salesUSD, salesIndex, margin,
|
|||||||
score := 0.30*productPerformanceMarginComponentScore(margin) +
|
score := 0.30*productPerformanceMarginComponentScore(margin) +
|
||||||
0.20*productPerformanceRatioScore(stockTurnover, productPerformanceStockTurnoverTarget(suffix)) +
|
0.20*productPerformanceRatioScore(stockTurnover, productPerformanceStockTurnoverTarget(suffix)) +
|
||||||
0.20*revenueScore +
|
0.20*revenueScore +
|
||||||
0.15*productPerformanceRatioScore(marketCount, 8) +
|
0.15*productPerformanceRatioScore(marketCount, productPerformanceMarketSpreadTarget(suffix)) +
|
||||||
0.15*productPerformanceRatioScore(customerCount, 25)
|
0.15*productPerformanceRatioScore(customerCount, productPerformanceCustomerSpreadTarget(suffix))
|
||||||
return productPerformanceRoundScore(score)
|
return productPerformanceRoundScore(score)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6291,6 +6291,32 @@ func productPerformanceStockTurnoverTarget(suffix string) float64 {
|
|||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func productPerformanceMarketSpreadTarget(suffix string) float64 {
|
||||||
|
switch suffix {
|
||||||
|
case "90d":
|
||||||
|
return 3
|
||||||
|
case "180d":
|
||||||
|
return 5
|
||||||
|
case "365d":
|
||||||
|
return 6
|
||||||
|
default:
|
||||||
|
return 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func productPerformanceCustomerSpreadTarget(suffix string) float64 {
|
||||||
|
switch suffix {
|
||||||
|
case "90d":
|
||||||
|
return 8
|
||||||
|
case "180d":
|
||||||
|
return 15
|
||||||
|
case "365d":
|
||||||
|
return 18
|
||||||
|
default:
|
||||||
|
return 25
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func productPerformanceCustomerScore(suffix string, salesUSD, margin, productGroupCount, salesQty float64) float64 {
|
func productPerformanceCustomerScore(suffix string, salesUSD, margin, productGroupCount, salesQty float64) float64 {
|
||||||
if salesUSD <= 0 {
|
if salesUSD <= 0 {
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -962,11 +962,37 @@ func productPerformanceExcelProductScore(suffix string, salesUSD, stockTurnover,
|
|||||||
score := 0.30*productPerformanceExcelMarginScore(margin) +
|
score := 0.30*productPerformanceExcelMarginScore(margin) +
|
||||||
0.20*productPerformanceExcelRatioScore(stockTurnover, 4) +
|
0.20*productPerformanceExcelRatioScore(stockTurnover, 4) +
|
||||||
0.20*revenueScore +
|
0.20*revenueScore +
|
||||||
0.15*productPerformanceExcelRatioScore(marketCount, 8) +
|
0.15*productPerformanceExcelRatioScore(marketCount, productPerformanceExcelMarketSpreadTarget(suffix)) +
|
||||||
0.15*productPerformanceExcelRatioScore(customerCount, 25)
|
0.15*productPerformanceExcelRatioScore(customerCount, productPerformanceExcelCustomerSpreadTarget(suffix))
|
||||||
return productPerformanceExcelRoundScore(score)
|
return productPerformanceExcelRoundScore(score)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func productPerformanceExcelMarketSpreadTarget(suffix string) float64 {
|
||||||
|
switch suffix {
|
||||||
|
case "90d":
|
||||||
|
return 3
|
||||||
|
case "180d":
|
||||||
|
return 5
|
||||||
|
case "365d":
|
||||||
|
return 6
|
||||||
|
default:
|
||||||
|
return 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func productPerformanceExcelCustomerSpreadTarget(suffix string) float64 {
|
||||||
|
switch suffix {
|
||||||
|
case "90d":
|
||||||
|
return 8
|
||||||
|
case "180d":
|
||||||
|
return 15
|
||||||
|
case "365d":
|
||||||
|
return 18
|
||||||
|
default:
|
||||||
|
return 25
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func productPerformanceExcelProductRevenueTarget(suffix string) float64 {
|
func productPerformanceExcelProductRevenueTarget(suffix string) float64 {
|
||||||
switch suffix {
|
switch suffix {
|
||||||
case "180d":
|
case "180d":
|
||||||
|
|||||||
@@ -3707,8 +3707,8 @@ function productScore100 ({ suffix = '90d', salesUSD = 0, margin = 0, stockTurno
|
|||||||
0.30 * marginScore(margin) +
|
0.30 * marginScore(margin) +
|
||||||
0.20 * ratioScore(stockTurnover, stockTurnoverTarget(suffix)) +
|
0.20 * ratioScore(stockTurnover, stockTurnoverTarget(suffix)) +
|
||||||
0.20 * revenue +
|
0.20 * revenue +
|
||||||
0.15 * ratioScore(marketCount, 8) +
|
0.15 * ratioScore(marketCount, marketSpreadTarget(suffix)) +
|
||||||
0.15 * ratioScore(customerCount, 25)
|
0.15 * ratioScore(customerCount, customerSpreadTarget(suffix))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3775,6 +3775,20 @@ function stockTurnoverTarget () {
|
|||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function marketSpreadTarget (suffix) {
|
||||||
|
if (suffix === '90d') return 3
|
||||||
|
if (suffix === '180d') return 5
|
||||||
|
if (suffix === '365d') return 6
|
||||||
|
return 8
|
||||||
|
}
|
||||||
|
|
||||||
|
function customerSpreadTarget (suffix) {
|
||||||
|
if (suffix === '90d') return 8
|
||||||
|
if (suffix === '180d') return 15
|
||||||
|
if (suffix === '365d') return 18
|
||||||
|
return 25
|
||||||
|
}
|
||||||
|
|
||||||
function periodCount (row, prefix, suffix) {
|
function periodCount (row, prefix, suffix) {
|
||||||
const keyed = Number(row?.[`${prefix}_${suffix}`] || 0)
|
const keyed = Number(row?.[`${prefix}_${suffix}`] || 0)
|
||||||
if (keyed > 0) return keyed
|
if (keyed > 0) return keyed
|
||||||
|
|||||||
Reference in New Issue
Block a user