product performance grouped kpi improvements

This commit is contained in:
M_Kececi
2026-07-03 03:58:15 +03:00
parent a05e6bf1e2
commit 60eef45769
2 changed files with 30 additions and 59 deletions
@@ -2789,7 +2789,7 @@ function salesGroupPerformanceScore (row) {
function productSalesPeriodScore (row) {
const salesIndex = Number(row?.sales_index_90d || 0)
const margin = Number(row?.gross_margin_cost_90d ?? row?.gross_margin_90d ?? 0)
const margin = Number(row?.gross_margin_cost_90d ?? 0)
const invoices = Number(row?.invoice_count_90d || 0)
const qty = Number(row?.sales_qty_90d || 0)
let stockTurnover = Number(row?.stock_turnover_90d || 0)
@@ -2803,8 +2803,7 @@ function productSalesPeriodScore (row) {
}
function productPeriodMetricSource (row, suffix) {
const salesUSD = Number(row?.[`sales_usd_${suffix}`] || 0)
const salesIndex = Number(row?.[`sales_index_${suffix}`] || 0) || (salesUSD > 0 ? salesUSD / 1000 : 0)
const salesIndex = Number(row?.[`sales_index_${suffix}`] || 0)
const qty = Number(row?.[`sales_qty_${suffix}`] || 0)
const stockQty = Number(row?.stock_qty || 0)
return {
@@ -2833,7 +2832,7 @@ function customerSalesGroupPerformanceScore (row) {
function customerSalesPeriodScore (row) {
const salesUSD = Number(row?.sales_usd || 0)
const margin = Number(row?.gross_margin_cost ?? row?.gross_margin ?? 0)
const margin = Number(row?.gross_margin_cost ?? 0)
const invoices = Number(row?.invoice_count || 0)
const qty = Number(row?.sales_qty || 0)
const productCount = Number(row?.product_count || 0)
@@ -2873,9 +2872,9 @@ function sumRows (sourceRows, field) {
}
function productVariantStockKey (row) {
const productCode = String(row?.product_code || row?.image_product_code || '').trim()
const colorCode = String(row?.color_code || row?.image_color_code || '').trim()
const yakaKodu = String(row?.yaka_kodu || row?.image_yaka_kodu || '').trim()
const productCode = String(row?.product_code || '').trim()
const colorCode = String(row?.color_code || '').trim()
const yakaKodu = String(row?.yaka_kodu || '').trim()
if (!productCode && !colorCode && !yakaKodu) return ''
return `${productCode}|${colorCode}|${yakaKodu}`
}
@@ -2980,7 +2979,7 @@ function weightedAverageOrAverage (sourceRows, valueField, qtyField) {
if (qty > 0) {
return weightedRows.reduce((sum, row) => sum + row.value * row.qty, 0) / qty
}
return averageRows(sourceRows, valueField)
return 0
}
function marginFromSalesCost (salesUSD, qty, unitCost) {
@@ -2999,8 +2998,7 @@ function marginFromRows (sourceRows, salesField, qtyField, unitCostField) {
}
function normalizeGroupValue (value) {
const text = String(value || '').trim()
return text || '-'
return String(value || '').trim()
}
function isGroupExpanded (key) {
@@ -3065,11 +3063,11 @@ function hasProductVariantImageKey (row) {
}
function canShowProductImage (row) {
return activeTab.value === 'products' && !row?.__group && hasProductVariantImageKey(row)
return activeTab.value === 'products' && hasProductVariantImageKey(row)
}
function groupShowsImage () {
return false
function groupShowsImage (row) {
return activeTab.value === 'products' && row?.__group && hasProductVariantImageKey(row)
}
const groupDimensionFields = new Set(dimensionColumnNames)