feat(est): apply all quantity sheets
This commit is contained in:
@@ -141,7 +141,7 @@ const EstQuantity = (() => {
|
||||
});
|
||||
return { rows, errors };
|
||||
}
|
||||
function totals(project, selected) {
|
||||
function totals(project, selected, allowEmpty = false) {
|
||||
let items;
|
||||
if (selected && selected !== "manual") {
|
||||
const sheet = project.quantitySheets?.find((s) => s.Code === selected);
|
||||
@@ -170,9 +170,17 @@ const EstQuantity = (() => {
|
||||
const index = targets[0].index;
|
||||
quantities.set(index, (quantities.get(index) || 0) + Number(item.GN || 0));
|
||||
}
|
||||
if (!quantities.size) throw Error("연결할 내역코드를 먼저 입력하세요.");
|
||||
if (!quantities.size && !allowEmpty) throw Error("연결할 내역코드를 먼저 입력하세요.");
|
||||
return quantities;
|
||||
}
|
||||
function allTotals(project) {
|
||||
const combined = new Map();
|
||||
for (const selected of ["manual", ...(project.quantitySheets || []).map((sheet) => sheet.Code)])
|
||||
for (const [index, value] of totals(project, selected, true))
|
||||
combined.set(index, (combined.get(index) || 0) + value);
|
||||
if (!combined.size) throw Error("연결할 내역코드를 먼저 입력하세요.");
|
||||
return combined;
|
||||
}
|
||||
function applyTotals(project, quantities) {
|
||||
for (const [index, value] of quantities) project.tables.EstMainDat[index].GN = value;
|
||||
}
|
||||
@@ -337,6 +345,7 @@ const EstQuantity = (() => {
|
||||
calculate,
|
||||
manual,
|
||||
totals,
|
||||
allTotals,
|
||||
applyTotals,
|
||||
targetSelect,
|
||||
newCode,
|
||||
|
||||
Reference in New Issue
Block a user