Files
Aislo/resources/tester/helper_855_c4_doc_text.cjs
T
eomsangdonandClaude Opus 5.5 c42d66ad68 feat(855-C): 2-C4 기준 목록 · 계산서를 수식 문서 셈으로 · 서버 산출근거 글 모듈 새로
- 새 `master_doc_text.py` — 문서 셈 답 → 산출근거 글(금액 줄 · 묶음 줄 · 계 줄 · 계산서 묶음) · 화면 짝(line_stack_out · eqText · unitText · moneyUnits · offLine) 규칙을 옮김 · 거울 시험 `test_855_c4_doc_text`(+ helper .cjs)
- `M02_Logic_Standard` — 기준 목록 축 = 문서 선택 변수 · 표 조건 입력 변수 · 바탕 = 문서 기본값 · 금액 = 문서 셈 · 계산서 = 문서 셈 + 새 글 · 파생 저장본 열쇠에 수식 문서 지문(SHAPE 4) · 답 꼴 그대로(화면 안 고침) · `M02_Logic_Settle` 은 B09 짝이라 남김
- 전수(1,521 기초 · 옛 줄 11,267): 같은 입력이면 금액 같음 11,165 · 다름 101 = 옛 목록만의 B09 산근 끝수(settle) — 새 값 = 옛 엔진 값 = M02 단가산출 값 · 옛 엔진 멈춤 1(새 0 원 줄은 목록에서 빠짐)
- 바탕 = 문서 기본값(옛 = master_auto 자동값) — 114 기초의 바탕 줄 규격이 바뀜(시험입력 · 기본 칸을 담은 문서 기본값)
- 시험 고침: test_704_logic_standard(옛 엔진 끝수 차 3 원 허용 → 수식 탭 셈과 같음) · test_704_settle(축 · 금액 인자가 문서) · test_714_1 의 「M01 /text 와 M02 계산서가 같은 줄 꼴」 시험 지움(M02 계산서가 옛 덧칸 길을 안 탐 — 까닭: 855-C 새 길)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 17:59:31 +09:00

72 lines
3.2 KiB
JavaScript

/* 855-C 2-C4 거울 헬퍼 — 산출근거 글 규칙(TS)을 Node 로 돌림(`master_doc_text.py` 짝).
* stdin = {수: [값], 단위: [글], 금액줄: [{줄, 단가변수, 부름}], 꺼짐: [{문서, 값}], 원: [수]}
* stdout = {eq: [eqText], one: [one], won: [won], 단위: [unitText], 금액줄: [moneyUnits],
* 꺼짐: [[offLine …] …], 비목: COST_SHOW, 항: LONG_SUM}
* `one` · `won` · `COST_SHOW` · `LONG_SUM` = `line_stack_out.ts` 안 정의를 그대로 읽어 돌림(내보내지 않는 값). */
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const cache = new Map();
function load(at) {
if (cache.has(at)) return cache.get(at);
const js = ts.transpileModule(fs.readFileSync(at, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
cache.set(at, box.exports);
const need = (p) => {
if (p.endsWith(".css")) return {};
return p.startsWith(".") ? load(path.resolve(path.dirname(at), `${p}.ts`)) : require(p);
};
new Function("exports", "module", "require", js)(box.exports, box, need);
return box.exports;
}
const ROOT = path.join(__dirname, "..", "..");
const eq = load(path.join(ROOT, "ui_template", "ui_template_equation.ts"));
const unit = load(path.join(ROOT, "common_util", "common_util_line_stack_unit.ts"));
const view = load(path.join(ROOT, "common_util", "common_util_formula_doc_view.ts"));
const stack = load(path.join(ROOT, "common_util", "common_util_line_stack.ts"));
// line_stack_out.ts 안 정의(내보내지 않음) — 그 줄 글을 그대로 떼어 돌림
const out = fs.readFileSync(path.join(ROOT, "A00_Common", "line_stack_out.ts"), "utf8");
const grab = (re) => {
const m = out.match(re);
if (!m) throw new Error(`line_stack_out.ts 에서 못 찾음: ${re}`);
return m[0];
};
const defs = [
grab(/const COST_SHOW: Record<string, string> = \{[^}]*\};/),
grab(/const won = \(n: number\): string => [^;]*;/),
grab(/const one = \(n: number\): string =>\s*n\.toLocaleString\([^;]*;/),
grab(/const LONG_SUM = \d+;/),
].join("\n");
const js = ts.transpileModule(`${defs}\nreturn { COST_SHOW, won, one, LONG_SUM };`, {
compilerOptions: { target: ts.ScriptTarget.ES2020 },
}).outputText;
const local = new Function("eqText", js)(eq.eqText);
const input = JSON.parse(fs.readFileSync(0, "utf8"));
const res = {
eq: (input.수 || []).map((v) => eq.eqText(v)),
one: (input.원 || []).map((v) => local.one(v)),
won: (input.원 || []).map((v) => local.won(v)),
단위: (input.단위 || []).map((u) => unit.unitText(u)),
금액줄: (input.금액줄 || []).map((x) =>
unit.moneyUnits(
x.줄,
view.tryParse(x.줄.단가),
view.tryParse(x.줄.수량),
x.단가변수 || undefined,
x.부름 || null,
),
),
기호: (input.금액줄 || []).map((x) => stack.priceSym(x.줄)),
꺼짐: (input.꺼짐 || []).map((x) =>
(x.문서.금액 || []).map((line) => view.offLine(line, x.값, view.lineMap(x.문서))),
),
비목: local.COST_SHOW,
항: local.LONG_SUM,
};
process.stdout.write(JSON.stringify(res));