fix(est): match prior unnamed cost codes
This commit is contained in:
@@ -224,11 +224,20 @@ const EstProgress = (() => {
|
||||
row[prefix + field] = children.reduce((n, child) => n + num(child[prefix + field]), 0);
|
||||
}
|
||||
const acceptedCost = round.approved ? sa : gum;
|
||||
const priorCosts = new Map(
|
||||
(previous?.costs || previous?.wonga || []).map((row) => [row.Gubun ?? row.Name, row]),
|
||||
);
|
||||
const costKeys = (items) => {
|
||||
const occurrences = new Map();
|
||||
return items.map((row) => {
|
||||
const identity = JSON.stringify(row.Gubun ? ["code", row.Gubun] : ["name", row.Name || ""]);
|
||||
const occurrence = occurrences.get(identity) || 0;
|
||||
occurrences.set(identity, occurrence + 1);
|
||||
return JSON.stringify([identity, occurrence]);
|
||||
});
|
||||
};
|
||||
const oldCosts = previous?.costs || previous?.wonga || [];
|
||||
const priorCosts = new Map(costKeys(oldCosts).map((key, index) => [key, oldCosts[index]]));
|
||||
const currentKeys = costKeys(acceptedCost.rows);
|
||||
const costs = acceptedCost.rows.map((row, index) => {
|
||||
const previous = priorCosts.get(row.Gubun ?? row.Name);
|
||||
const previous = priorCosts.get(currentKeys[index]);
|
||||
const jun = num(previous?.TotalCost ?? previous?.Cost);
|
||||
return {
|
||||
...row,
|
||||
|
||||
Reference in New Issue
Block a user