fix(est): reject ambiguous progress inputs
This commit is contained in:
@@ -8,6 +8,14 @@ const EstProgress = (() => {
|
||||
return Math.max(0, (mantissa.split(".")[1]?.length || 0) - Number(exponent || 0));
|
||||
};
|
||||
const ordinary = (row) => num(row.Level) === 0 && ![54, 55, 58, 59].includes(num(row.LinkIndex));
|
||||
function ambiguousKeys(rows) {
|
||||
const counts = new Map();
|
||||
rows.forEach((row, index) => {
|
||||
const key = EstBusiness.rowKey(row, index);
|
||||
counts.set(key, (counts.get(key) || 0) + 1);
|
||||
});
|
||||
return new Set([...counts].filter(([, count]) => count > 1).map(([key]) => key));
|
||||
}
|
||||
function distribute(amount, row, digits) {
|
||||
const parts = components.map((field) => num(row[field]));
|
||||
const base = sum(row);
|
||||
@@ -31,6 +39,7 @@ const EstProgress = (() => {
|
||||
const errors = [],
|
||||
position = project.progress.indexOf(round),
|
||||
key = EstBusiness.rowKey;
|
||||
const ambiguous = ambiguousKeys(rows);
|
||||
const earlier = project.progress.slice(0, position);
|
||||
if (earlier.some((item) => !item.locked)) errors.push("전회 기성 회차를 먼저 확정하세요.");
|
||||
const previous = earlier.at(-1)?.result,
|
||||
@@ -39,8 +48,10 @@ const EstProgress = (() => {
|
||||
const separated = round.separateComponents !== false;
|
||||
rows.forEach((row, index) => {
|
||||
const id = key(row, index),
|
||||
input = round.inputs?.[id] || {},
|
||||
old = oldRows.get(id);
|
||||
input = ambiguous.has(id) ? {} : round.inputs?.[id] || {},
|
||||
old = ambiguous.has(id) ? null : oldRows.get(id);
|
||||
if (ambiguous.has(id) && (round.inputs?.[id] || oldRows.has(id)))
|
||||
errors.push(`기성 내역 식별자가 중복됩니다: ${id}`);
|
||||
for (const field of ["GN", "TC", "Ratio", ...components])
|
||||
row["Jun" + field] = num(old?.["Total" + field]);
|
||||
if (num(row.Level) > 0 || [54, 59].includes(num(row.LinkIndex))) {
|
||||
@@ -301,5 +312,5 @@ const EstProgress = (() => {
|
||||
}
|
||||
return project;
|
||||
}
|
||||
return { calculate, lock, unlock, rebuild };
|
||||
return { calculate, lock, unlock, rebuild, ambiguousKeys };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user