Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-08-18 13:38:32 +03:00
parent 6eaf0e3ed3
commit 474904481f
2 changed files with 20 additions and 9 deletions
@@ -1557,8 +1557,15 @@ function ensureBeforeUnloadGuard (enabled) {
return ''
}
}
function shouldIncludeRowInCostingTotal (row) {
// CM1/CM2 are labor-cost groups and always contribute to costing. For all
// other groups the explicit "Maliyete Dahil" selection is authoritative.
return isCMGroupName(row?.sAciklama3) ||
normalizeBooleanFlag(row?.maliyeteDahil ?? row?.maliyete_dahil ?? row?.Maliyete_dahil)
}
const toolbarSummary = computed(() => flatDetailRows.value.reduce((acc, row) => {
if (!normalizeBooleanFlag(row?.maliyeteDahil ?? row?.maliyete_dahil ?? row?.Maliyete_dahil)) return acc
if (!shouldIncludeRowInCostingTotal(row)) return acc
acc.tryTotal += resolveRowTRYTutar(row)
acc.usdTotal += resolveRowUSDTutar(row)
acc.eurTotal += resolveRowEURTutar(row)
@@ -2849,9 +2856,7 @@ function resolveRowUSDTutar (row) {
}
function shouldIncludeRowInGroupTotal (_grp, row) {
// Keep sub-header totals aligned with the top header and the value persisted
// to spUrtOnMLMas: only rows explicitly included in costing contribute.
return normalizeBooleanFlag(row?.maliyeteDahil ?? row?.maliyete_dahil ?? row?.Maliyete_dahil)
return shouldIncludeRowInCostingTotal(row)
}
function resolveGroupTRYTutar (grp) {
@@ -3926,10 +3931,14 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) {
const groupName = normalizeGroupName(meta?.groupName || '')
const hammaddeAdi = String(meta?.hammaddeAdi || '').trim()
const effectiveGroupName = groupName || 'TANIMSIZ'
const mtBolumID = (meta?.mtBolumID > 0 ? meta.mtBolumID : mappingMtBolumID) || 0
const metaParcaCandidate = normalizeGroupName((meta?.parcaAdi || '').trim())
// Defensive: if backend/lookup accidentally returns group label (DT/TP/...) as part name, ignore it.
const desiredParcaAdi = normalizeGroupName((metaParcaCandidate && !isKnownGroupName(metaParcaCandidate)) ? metaParcaCandidate : mappingParcaAdi)
// The product-type mapping is authoritative for the required part. A raw
// material type can be required for multiple parts, while its master
// record only carries one default MT section. Using that default here
// incorrectly made an existing recipe row satisfy every mapped part.
const mtBolumID = mappingMtBolumID > 0 ? mappingMtBolumID : (meta?.mtBolumID || 0)
const desiredParcaAdi = mappingMtBolumID > 0
? mappingParcaAdi
: normalizeGroupName(meta?.parcaAdi || mappingParcaAdi)
const anyMatch = flatDetailRows.value.find(r => {
if (normalizeHammaddeNo(r?.nHammaddeTuruNo) !== hNo) return false