fix(est): distinguish repeated change items
This commit is contained in:
@@ -54,10 +54,15 @@ const EstBusiness = (() => {
|
||||
}
|
||||
function changes(project) {
|
||||
const old = project.baseline?.tables.EstMainDat || [];
|
||||
const seen = new Set();
|
||||
const groups = new Map();
|
||||
old.forEach((row, index) => {
|
||||
const key = rowKey(row, index),
|
||||
group = groups.get(key) || [];
|
||||
group.push({ row, index });
|
||||
groups.set(key, group);
|
||||
});
|
||||
const changes = project.tables.EstMainDat.map((row, index) => {
|
||||
seen.add(rowKey(row, index));
|
||||
const saved = old.find((r, i) => rowKey(r, i) === rowKey(row, index));
|
||||
const saved = groups.get(rowKey(row, index))?.shift()?.row;
|
||||
const stored =
|
||||
!project.baseline && ["Code_", "Name_", "GN_", "TC_"].some((key) => row[key] != null)
|
||||
? Object.fromEntries(
|
||||
@@ -87,22 +92,22 @@ const EstBusiness = (() => {
|
||||
originalSource: saved ? "baseline" : stored ? "file" : null,
|
||||
};
|
||||
});
|
||||
old.forEach((row, index) => {
|
||||
if (seen.has(rowKey(row, index))) return;
|
||||
changes.push({
|
||||
key: rowKey(row, index),
|
||||
Code: row.Code || "",
|
||||
Name: row.Name || "",
|
||||
originalGN: num(row.GN),
|
||||
originalTC: num(row.TC),
|
||||
GN: 0,
|
||||
TC: 0,
|
||||
difference: -num(row.TC),
|
||||
NewItem: false,
|
||||
status: "deleted",
|
||||
originalSource: "baseline",
|
||||
});
|
||||
});
|
||||
for (const group of groups.values())
|
||||
for (const { row, index } of group) {
|
||||
changes.push({
|
||||
key: rowKey(row, index),
|
||||
Code: row.Code || "",
|
||||
Name: row.Name || "",
|
||||
originalGN: num(row.GN),
|
||||
originalTC: num(row.TC),
|
||||
GN: 0,
|
||||
TC: 0,
|
||||
difference: -num(row.TC),
|
||||
NewItem: false,
|
||||
status: "deleted",
|
||||
originalSource: "baseline",
|
||||
});
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function costChanges(project) {
|
||||
|
||||
Reference in New Issue
Block a user