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 @@
{(item.codes || []).length ? item.codes.join(", ") : "-"}
+ {item.key === "공통배분분" && ( +
+
본사관리비 배부원천 x (프로젝트 기준값 / 전체 기준값)
+
기준값: {allocationMode === "income_ratio" ? "프로젝트 입금 / 전체입금" : "프로젝트 지출 / 전체지출"}
+ {(sharedAllocationDetails.length ? sharedAllocationDetails : [{ year_month: "", source_amount: 0, display_project_basis_amount: 0, display_total_basis_amount: 0, allocated_amount: item.amount || 0 }]) + .map((row, idx) => { + const sourceAmount = Number(row.source_amount || 0); + const allocatedAmount = Number(row.allocated_amount || 0); + const projectBasisAmount = Number(row.display_project_basis_amount ?? row.project_basis_amount ?? 0); + const totalBasisAmount = Number(row.display_total_basis_amount ?? row.total_basis_amount ?? 0); + return ( +
+ {((row.year_month || "").slice(0, 4) || "-")}년 · {fmt(sourceAmount)}원 x ({fmt(projectBasisAmount)}원 / {fmt(totalBasisAmount)}원) = {fmt(allocatedAmount)}원 +
+ ); + })} +
+ )}
{fmt(item.amount || 0)}원