Fix product performance grouped JSON build
This commit is contained in:
@@ -3900,6 +3900,24 @@ function normalizeGroupName (value) {
|
|||||||
return String(value || 'TANIMSIZ').trim() || 'TANIMSIZ'
|
return String(value || 'TANIMSIZ').trim() || 'TANIMSIZ'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeProductFirstGroup (value) {
|
||||||
|
return String(value || '')
|
||||||
|
.trim()
|
||||||
|
.toLocaleUpperCase('tr-TR')
|
||||||
|
.replaceAll('İ', 'I')
|
||||||
|
.replaceAll('Ş', 'S')
|
||||||
|
.replaceAll('Ğ', 'G')
|
||||||
|
.replaceAll('Ü', 'U')
|
||||||
|
.replaceAll('Ö', 'O')
|
||||||
|
.replaceAll('Ç', 'C')
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMalzemesizFasonProduct () {
|
||||||
|
// Keep the legacy MAZLEMESIZ spelling compatible with existing product cards.
|
||||||
|
const firstGroup = normalizeProductFirstGroup(detailHeader.value?.UrunIlkGrubu)
|
||||||
|
return firstGroup === 'MALZEMESIZ FASON' || firstGroup === 'MAZLEMESIZ FASON'
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchRequiredParcaMappings () {
|
async function fetchRequiredParcaMappings () {
|
||||||
const ilk = String(detailHeader.value?.UrunIlkGrubu || '').trim()
|
const ilk = String(detailHeader.value?.UrunIlkGrubu || '').trim()
|
||||||
const ana = String(detailHeader.value?.UrunAnaGrubu || '').trim()
|
const ana = String(detailHeader.value?.UrunAnaGrubu || '').trim()
|
||||||
@@ -3908,14 +3926,22 @@ async function fetchRequiredParcaMappings () {
|
|||||||
const alt = altRaw || '-'
|
const alt = altRaw || '-'
|
||||||
if (!ilk || !ana) return []
|
if (!ilk || !ana) return []
|
||||||
|
|
||||||
const data = await get('/pricing/production-product-costing/maliyet-parca-eslestirme', {
|
const fetchMappings = urunIlkGrubu => get('/pricing/production-product-costing/maliyet-parca-eslestirme', {
|
||||||
trace_id: traceId.value,
|
trace_id: traceId.value,
|
||||||
only_active: 1,
|
only_active: 1,
|
||||||
urun_ilk_grubu: ilk,
|
urun_ilk_grubu: urunIlkGrubu,
|
||||||
urun_ana_grubu: ana,
|
urun_ana_grubu: ana,
|
||||||
urun_alt_grubu: alt
|
urun_alt_grubu: alt
|
||||||
})
|
})
|
||||||
return Array.isArray(data) ? data : []
|
|
||||||
|
const data = await fetchMappings(ilk)
|
||||||
|
const mappings = Array.isArray(data) ? data : []
|
||||||
|
if (mappings.length > 0 || !isMalzemesizFasonProduct()) return mappings
|
||||||
|
|
||||||
|
// MALZEMESIZ FASON uses the same required-part definition as its
|
||||||
|
// MALZEMELI FASON counterpart for the same product main/sub group.
|
||||||
|
const fallback = await fetchMappings('MALZEMELI FASON')
|
||||||
|
return Array.isArray(fallback) ? fallback : []
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveHammaddeMetaForRequired (hNo) {
|
async function resolveHammaddeMetaForRequired (hNo) {
|
||||||
@@ -3959,6 +3985,7 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) {
|
|||||||
const list = Array.isArray(mappings) ? mappings : []
|
const list = Array.isArray(mappings) ? mappings : []
|
||||||
requiredParcaMappings.value = list
|
requiredParcaMappings.value = list
|
||||||
if (list.length === 0) return
|
if (list.length === 0) return
|
||||||
|
const requiredRowsIncludedInCost = !isMalzemesizFasonProduct()
|
||||||
|
|
||||||
// Defensive: The mapping payload may contain duplicate hammadde numbers across rows (or even inside a single row).
|
// Defensive: The mapping payload may contain duplicate hammadde numbers across rows (or even inside a single row).
|
||||||
// IMPORTANT: Placeholders are keyed by (nUrtMTBolumID + nHammaddeTuruNo). The same hammadde type can be required
|
// IMPORTANT: Placeholders are keyed by (nUrtMTBolumID + nHammaddeTuruNo). The same hammadde type can be required
|
||||||
@@ -4098,9 +4125,9 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) {
|
|||||||
inputPricePrBr: 'USD',
|
inputPricePrBr: 'USD',
|
||||||
fiyat_girilen: 0,
|
fiyat_girilen: 0,
|
||||||
fiyat_doviz: 'USD',
|
fiyat_doviz: 'USD',
|
||||||
maliyeteDahil: true,
|
maliyeteDahil: requiredRowsIncludedInCost,
|
||||||
maliyete_dahil: 1,
|
maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0,
|
||||||
Maliyete_dahil: 1,
|
Maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0,
|
||||||
cmPriceTypeId: normalizeCMPriceTypeId(1, groupName),
|
cmPriceTypeId: normalizeCMPriceTypeId(1, groupName),
|
||||||
cm_price_type_id: normalizeCMPriceTypeId(1, groupName),
|
cm_price_type_id: normalizeCMPriceTypeId(1, groupName),
|
||||||
sBirim: 'AD',
|
sBirim: 'AD',
|
||||||
@@ -4205,9 +4232,9 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) {
|
|||||||
inputPricePrBr: 'USD',
|
inputPricePrBr: 'USD',
|
||||||
fiyat_girilen: 0,
|
fiyat_girilen: 0,
|
||||||
fiyat_doviz: 'USD',
|
fiyat_doviz: 'USD',
|
||||||
maliyeteDahil: true,
|
maliyeteDahil: requiredRowsIncludedInCost,
|
||||||
maliyete_dahil: 1,
|
maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0,
|
||||||
Maliyete_dahil: 1,
|
Maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0,
|
||||||
cmPriceTypeId: normalizeCMPriceTypeId(1, effectiveGroupName),
|
cmPriceTypeId: normalizeCMPriceTypeId(1, effectiveGroupName),
|
||||||
cm_price_type_id: normalizeCMPriceTypeId(1, effectiveGroupName),
|
cm_price_type_id: normalizeCMPriceTypeId(1, effectiveGroupName),
|
||||||
sBirim: 'AD',
|
sBirim: 'AD',
|
||||||
|
|||||||
Reference in New Issue
Block a user