feat: show shared allocation formula inline in shared project row
This commit is contained in:
@@ -5397,6 +5397,7 @@
|
|||||||
{(lifecycleBreakdownModal.projects || []).length ? (
|
{(lifecycleBreakdownModal.projects || []).length ? (
|
||||||
(() => {
|
(() => {
|
||||||
const projects = Array.isArray(lifecycleBreakdownModal.projects) ? lifecycleBreakdownModal.projects : [];
|
const projects = Array.isArray(lifecycleBreakdownModal.projects) ? lifecycleBreakdownModal.projects : [];
|
||||||
|
const accounts = Array.isArray(lifecycleBreakdownModal.accounts) ? lifecycleBreakdownModal.accounts : [];
|
||||||
const roleAmount = {
|
const roleAmount = {
|
||||||
영업: 0,
|
영업: 0,
|
||||||
설계: 0,
|
설계: 0,
|
||||||
@@ -5419,6 +5420,31 @@
|
|||||||
}
|
}
|
||||||
sharedAmount += shared;
|
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 = [
|
const groupedRows = [
|
||||||
{ key: "영업", label: "영업", amount: roleAmount.영업, showWhenZero: false, codes: Array.from(roleCodes.영업) },
|
{ key: "영업", label: "영업", amount: roleAmount.영업, showWhenZero: false, codes: Array.from(roleCodes.영업) },
|
||||||
{ key: "설계", label: "설계", amount: roleAmount.설계, showWhenZero: false, codes: Array.from(roleCodes.설계) },
|
{ key: "설계", label: "설계", amount: roleAmount.설계, showWhenZero: false, codes: Array.from(roleCodes.설계) },
|
||||||
@@ -5448,6 +5474,24 @@
|
|||||||
<div className="subtle" style={{ marginTop: 4 }}>
|
<div className="subtle" style={{ marginTop: 4 }}>
|
||||||
{(item.codes || []).length ? item.codes.join(", ") : "-"}
|
{(item.codes || []).length ? item.codes.join(", ") : "-"}
|
||||||
</div>
|
</div>
|
||||||
|
{item.key === "공통배분분" && (
|
||||||
|
<div className="subtle" style={{ marginTop: 6, lineHeight: 1.5 }}>
|
||||||
|
<div>본사관리비 배부원천 x (프로젝트 기준값 / 전체 기준값)</div>
|
||||||
|
<div>기준값: {allocationMode === "income_ratio" ? "프로젝트 입금 / 전체입금" : "프로젝트 지출 / 전체지출"}</div>
|
||||||
|
{(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 (
|
||||||
|
<div key={`shared-inline-alloc-${idx}`}>
|
||||||
|
{((row.year_month || "").slice(0, 4) || "-")}년 · {fmt(sourceAmount)}원 x ({fmt(projectBasisAmount)}원 / {fmt(totalBasisAmount)}원) = {fmt(allocatedAmount)}원
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ textAlign: "right", fontWeight: 700 }}>
|
<div style={{ textAlign: "right", fontWeight: 700 }}>
|
||||||
{fmt(item.amount || 0)}원
|
{fmt(item.amount || 0)}원
|
||||||
|
|||||||
Reference in New Issue
Block a user