fix(est): validate imported review targets

This commit is contained in:
2026-11-07 08:28:29 +09:00
parent a0461bf042
commit 35d3cc936c
3 changed files with 24 additions and 3 deletions
+3 -2
View File
@@ -255,14 +255,15 @@ def test_excel_exports_and_imports_contract_review_inputs():
const p=EstNative.empty();p.tables.EstMainDat=[{PkID:1,Code:'A',GN:2,GU:100}];
const row={RowKey:'row:1',GN:1,GU:80,Reason:'checked'};
const q=EstExchange.apply(p,{Review:[row]});let rejected=0;
for(const bad of [[row,row],[{...row,GU:'bad'}],[{...row,RowKey:'not-key'}]])
for(const bad of [[row,row],[{...row,GU:'bad'}],[{...row,RowKey:'not-key'}],
[{...row,RowKey:'row:missing'}],[{RowKey:'row:1',GC:4}]])
try{EstExchange.apply(p,{Review:bad})}catch{rejected++}
return {review:EstReview.calculate(q),edit:q.contractReview.edits['row:1'],rejected};
})()""",
)
assert result["review"]["after"] == 80
assert result["edit"]["Reason"] == "checked"
assert result["rejected"] == 3
assert result["rejected"] == 5
def test_excel_exports_only_unlocked_progress_and_annual_stages():
+20
View File
@@ -390,6 +390,26 @@ const EstExchange = (() => {
return merged;
});
}
if (Object.hasOwn(tables, "Review")) {
const targets = new Map();
next.tables.EstMainDat.forEach((row, index) => {
if (!EstReview.editable(row)) return;
const key = EstReview.rowKey(row, index),
matches = targets.get(key) || [];
matches.push(row);
targets.set(key, matches);
});
for (const [key, edit] of Object.entries(next.contractReview.edits)) {
const matches = targets.get(key) || [];
if (matches.length !== 1) throw Error(`심사 내역이 없거나 중복됩니다: ${key}`);
if (
Object.keys(edit).some(
(field) => field !== "Reason" && !EstReview.allowed(matches[0]).includes(field),
)
)
throw Error(`해당 내역에 사용할 수 없는 심사 입력: ${key}`);
}
}
if (Object.hasOwn(tables, "ProgressDrafts")) {
const counts = new Map();
next.tables.EstMainDat.forEach((row, index) => {
+1 -1
View File
@@ -160,5 +160,5 @@ const EstReview = (() => {
}
});
}
return { validate, calculate, copy, rowKey, render, install };
return { validate, calculate, copy, rowKey, editable, allowed, render, install };
})();