diff --git a/PTC/management_dashboard_preview.html b/PTC/management_dashboard_preview.html index ac06651..33472ec 100644 --- a/PTC/management_dashboard_preview.html +++ b/PTC/management_dashboard_preview.html @@ -5397,6 +5397,7 @@ {(lifecycleBreakdownModal.projects || []).length ? ( (() => { const projects = Array.isArray(lifecycleBreakdownModal.projects) ? lifecycleBreakdownModal.projects : []; + const accounts = Array.isArray(lifecycleBreakdownModal.accounts) ? lifecycleBreakdownModal.accounts : []; const roleAmount = { 영업: 0, 설계: 0, @@ -5419,6 +5420,31 @@ } sharedAmount += shared; }); + const allocationMode = + (accounts.find((acc) => (acc.allocation_mode || "").trim()) || {}).allocation_mode || effectiveCommonAllocationMode; + const aggregatedByYearMonth = {}; + accounts.forEach((acc) => { + const rows = Array.isArray(acc.allocation_details) ? acc.allocation_details : []; + rows.forEach((row) => { + const key = String(row.year_month || ""); + if (!aggregatedByYearMonth[key]) { + aggregatedByYearMonth[key] = { + year_month: key, + source_amount: 0, + project_basis_amount: Number(row.project_basis_amount || 0), + total_basis_amount: Number(row.total_basis_amount || 0), + display_project_basis_amount: Number(row.display_project_basis_amount ?? row.project_basis_amount ?? 0), + display_total_basis_amount: Number(row.display_total_basis_amount ?? row.total_basis_amount ?? 0), + allocated_amount: 0, + }; + } + aggregatedByYearMonth[key].source_amount += Number(row.source_amount || 0); + aggregatedByYearMonth[key].allocated_amount += Number(row.allocated_amount || 0); + }); + }); + const sharedAllocationDetails = Object.values(aggregatedByYearMonth).sort((a, b) => + String(a.year_month || "").localeCompare(String(b.year_month || "")) + ); const groupedRows = [ { key: "영업", label: "영업", amount: roleAmount.영업, showWhenZero: false, codes: Array.from(roleCodes.영업) }, { key: "설계", label: "설계", amount: roleAmount.설계, showWhenZero: false, codes: Array.from(roleCodes.설계) }, @@ -5448,6 +5474,24 @@