feat(lifecycle): add selectable common allocation mode (expense/income ratio)
This commit is contained in:
1 parent
68eabcc228
commit
21ad66c8b4
2 files changed
+155
-9
No files matched your search
@@ -1924,6 +1924,7 @@
|
||||
const [lifecycleAccountDetailModalLoading, setLifecycleAccountDetailModalLoading] = useState(false);
|
||||
const [lifecycleAllocationModal, setLifecycleAllocationModal] = useState(null);
|
||||
const [lifecycleAllocationSaving, setLifecycleAllocationSaving] = useState(false);
|
||||
const [lifecycleCommonAllocationSaving, setLifecycleCommonAllocationSaving] = useState(false);
|
||||
const [projectEditModalOpen, setProjectEditModalOpen] = useState(false);
|
||||
const [relatedProjectSearch, setRelatedProjectSearch] = useState("");
|
||||
const [projectTxnDateFrom, setProjectTxnDateFrom] = useState("");
|
||||
@@ -3605,6 +3606,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function saveLifecycleCommonAllocationMode(nextMode) {
|
||||
if (!selectedProjectCode) return;
|
||||
if (!["expense_ratio", "income_ratio"].includes(nextMode || "")) return;
|
||||
setLifecycleCommonAllocationSaving(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/lifecycle-common-allocation/upsert`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
base_project_code: selectedProjectCode,
|
||||
allocation_mode: nextMode,
|
||||
}),
|
||||
});
|
||||
if (!res.ok) throw new Error("common allocation save failed");
|
||||
await res.json();
|
||||
const detailRes = await fetch(`${API_BASE}/api/project-detail?${detailQuery}`);
|
||||
if (detailRes.ok) {
|
||||
const nextDetail = await detailRes.json();
|
||||
setDetail(nextDetail);
|
||||
}
|
||||
} catch (err) {
|
||||
setError("공통배분 기준 저장에 실패했습니다.");
|
||||
} finally {
|
||||
setLifecycleCommonAllocationSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveProjectMaster() {
|
||||
if (!selectedProjectCode) return;
|
||||
setSaving(true);
|
||||
@@ -5182,6 +5211,19 @@
|
||||
<div>
|
||||
<div style={{ fontSize: 18, fontWeight: 700 }}>프로젝트 생애주기 원가</div>
|
||||
<div className="subtle" style={{ marginTop: 6 }}>현재 시공 프로젝트를 포함해 연결된 전체 비용을 시공비, 인건비, 관리비로 나눠 봅니다.</div>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: 8, marginTop: 10 }}>
|
||||
<span className="subtle">공통배분 기준</span>
|
||||
<select
|
||||
value={detail?.lifecycle_cost?.summary?.common_allocation_mode || "expense_ratio"}
|
||||
onChange={(e) => saveLifecycleCommonAllocationMode(e.target.value)}
|
||||
disabled={lifecycleCommonAllocationSaving}
|
||||
style={{ minWidth: 220 }}
|
||||
>
|
||||
<option value="expense_ratio">프로젝트 지출 / 전체지출 비율</option>
|
||||
<option value="income_ratio">프로젝트 입금 / 전체입금 비율</option>
|
||||
</select>
|
||||
<span className="subtle">{lifecycleCommonAllocationSaving ? "저장 중..." : ""}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, minmax(120px, 1fr))", gap: 24, minWidth: 560 }}>
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user