fix(est-test): handle percent details and subtotals

This commit is contained in:
2026-11-09 23:33:40 +09:00
parent 741805ffde
commit ae31ac00fb
9 changed files with 99 additions and 14 deletions
+9 -9
View File
@@ -7,7 +7,7 @@ const { exportMachines } = require("./jdl-machine-export.cjs");
const { orderUnits } = require("./jdl-unit-order.cjs");
const { isFixedPart, exportUnitPart } = require("./jdl-unit-part.cjs");
const { canPreserveSpecial, fixedSpecialPart } = require("./jdl-special-unit.cjs");
const { ordinaryMachinePart } = require("./jdl-machine-parts.cjs");
const { ordinaryMachinePart, machineQuantity } = require("./jdl-machine-parts.cjs");
const decoder = new TextDecoder("euc-kr", { fatal: true });
function fingerprint(project) {
const { originalJdlState, id, ...content } = project;
@@ -360,9 +360,7 @@ function read(bytes, project) {
const identifiable =
parts.length > 0 &&
uniqueSequences.size === parts.length &&
parts.every(
(part) => Boolean(part.F_SEQ) && num(part.F_QQTY) > 0 && !["%", "%"].includes(part.F_UNIT),
);
parts.every((part) => Boolean(part.F_SEQ) && num(part.F_QQTY) > 0);
const ordinary = identifiable && parts.every((part) => ordinaryMachinePart(part, num));
const matches = (weighted) =>
[
@@ -373,14 +371,14 @@ function read(bytes, project) {
([field, value]) =>
Math.abs(
parts.reduce(
(sum, part) => sum + num(part[field]) * (weighted ? num(part.F_QQTY) : 1),
(sum, part) => sum + num(part[field]) * (weighted ? machineQuantity(part, num) : 1),
0,
) - value,
) < 1e-6,
);
const direct = identifiable && matches(false);
const weighted = identifiable && !direct && matches(true);
const basic = (direct && parts.every((part) => num(part.F_QQTY) === 1)) || weighted;
const basic = (direct && parts.every((part) => machineQuantity(part, num) === 1)) || weighted;
project.tables.MachMainDat.push({
PkID: project.tables.MachMainDat.length + 1,
Index: 1,
@@ -396,7 +394,7 @@ function read(bytes, project) {
machineWeighted ||= weighted;
machineSpecial ||= !ordinary;
for (const part of parts) {
const factor = weighted ? num(part.F_QQTY) : 1,
const factor = weighted ? machineQuantity(part, num) : 1,
GC = num(part.F_MPRICE) * factor,
NC = num(part.F_LPRICE) * factor,
JC = num(part.F_EPRICE) * factor;
@@ -410,7 +408,7 @@ function read(bytes, project) {
Name: part.F_DES,
Size: part.F_SIZE,
Unite: part.F_UNIT,
GN: 1,
GN: num(part.F_QQTY),
GC,
NC,
JC,
@@ -435,7 +433,9 @@ function read(bytes, project) {
"기계 상세는 저장 금액별로 표시하며, 산식과 원천 단가 연결은 원본 JDL에 보존됩니다.",
);
if (machineWeighted)
unitWarnings.push("일부 기계 상세는 수량×단가가 저장 합계와 일치해 계산 금액으로 표시합니다.");
unitWarnings.push(
"일부 기계 상세는 단위에 따른 수량×단가가 저장 합계와 일치해 계산 금액으로 표시합니다.",
);
if (machineSpecial)
unitWarnings.push("특수 기계 상세는 저장 금액으로 고정하며 특수 산식은 원문에 보존합니다.");
if (machineFallback)