From 372d7a8761f85bbaccff4fc2fd760b6786a78088 Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Wed, 26 Aug 2026 20:15:24 +0300 Subject: [PATCH] Fix product performance grouped JSON build --- .../ProductionProductCostingHasCostDetail.vue | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue index fc87e08..207a3d1 100644 --- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue +++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue @@ -3900,6 +3900,24 @@ function normalizeGroupName (value) { 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 () { const ilk = String(detailHeader.value?.UrunIlkGrubu || '').trim() const ana = String(detailHeader.value?.UrunAnaGrubu || '').trim() @@ -3908,14 +3926,22 @@ async function fetchRequiredParcaMappings () { const alt = altRaw || '-' 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, only_active: 1, - urun_ilk_grubu: ilk, + urun_ilk_grubu: urunIlkGrubu, urun_ana_grubu: ana, 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) { @@ -3959,6 +3985,7 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) { const list = Array.isArray(mappings) ? mappings : [] requiredParcaMappings.value = list 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). // IMPORTANT: Placeholders are keyed by (nUrtMTBolumID + nHammaddeTuruNo). The same hammadde type can be required @@ -4098,9 +4125,9 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) { inputPricePrBr: 'USD', fiyat_girilen: 0, fiyat_doviz: 'USD', - maliyeteDahil: true, - maliyete_dahil: 1, - Maliyete_dahil: 1, + maliyeteDahil: requiredRowsIncludedInCost, + maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0, + Maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0, cmPriceTypeId: normalizeCMPriceTypeId(1, groupName), cm_price_type_id: normalizeCMPriceTypeId(1, groupName), sBirim: 'AD', @@ -4205,9 +4232,9 @@ async function ensureNoCostRequiredRowsFromMappings (mappings) { inputPricePrBr: 'USD', fiyat_girilen: 0, fiyat_doviz: 'USD', - maliyeteDahil: true, - maliyete_dahil: 1, - Maliyete_dahil: 1, + maliyeteDahil: requiredRowsIncludedInCost, + maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0, + Maliyete_dahil: requiredRowsIncludedInCost ? 1 : 0, cmPriceTypeId: normalizeCMPriceTypeId(1, effectiveGroupName), cm_price_type_id: normalizeCMPriceTypeId(1, effectiveGroupName), sBirim: 'AD',