Merge remote-tracking branch 'origin/dev' into sub_laptop_2
This commit is contained in:
@@ -178,3 +178,133 @@ def test_줄_갈래_읽기_쉬운_식_산출서_상태줄():
|
||||
assert got["status"] == {"원래": 51000, "지금": 51419, "전": 50000} # 원래 = 바탕 셈 계
|
||||
assert got["origin"]["원래"] == 49000 # 790-2 `원래` 있으면 그 값
|
||||
assert got["diff"] == ["+383", "−419", ""]
|
||||
|
||||
|
||||
# ── 790-3 E2 화면 이음(식 속 상수 · 표값 · 글 줄 · 까닭 · M01 원래로 · M01 바뀜) ──────────
|
||||
EDIT = M02 / "M02_MasterTemplete_Sangeun_SheetEdit.ts"
|
||||
|
||||
|
||||
def test_790_3_숫자_넓힘_칸_정적():
|
||||
s = _text(EDIT)
|
||||
assert "<button" not in s and "<input" not in s and "document.createElement" not in s
|
||||
assert "fetch(" not in s and "sessionStorage." not in s and len(s.splitlines()) < 700
|
||||
for call in (
|
||||
"setConst(c.doc, spot, p.n, x)", # 식 속 숫자 = 상수 덮개
|
||||
"setTable(c.doc, spot, p.n, x)", # 표 꼬리표 값 = 표값 덮개
|
||||
'createBadge(t("Cut"), "warning")', # 표 연결 끊김
|
||||
"addText(c.doc, spot,", # 글 줄 더함 · 고침 · 지움
|
||||
"editText(c.doc, i, v)",
|
||||
"dropText(c.doc, i)",
|
||||
"setReason(c.doc, key, x)", # 까닭
|
||||
"restoreM01(c.doc, spot)", # 줄마다 M01 원래로
|
||||
"restoreM01(c.doc)", # 전체
|
||||
'createBadge(t("Changed"), "danger")', # M01 바뀜
|
||||
"c.spots?.짝잃음",
|
||||
):
|
||||
assert call in s, call
|
||||
sheet = _text(SHEET)
|
||||
for call in (
|
||||
"formulaEditor(ctx, it.자리)",
|
||||
"reasonCell(ctx, it.자리, it.changed)",
|
||||
"spotTail(ctx, it.자리,",
|
||||
"restoreAll(ctx)",
|
||||
"lostBanner(ctx)",
|
||||
"removedReasons(ctx, d.removed)",
|
||||
"dropAddKeys(d.doc as ConstDoc, r.added)", # 뺀 더한줄 = 까닭 · 글줄 열쇠 당김
|
||||
"liftAddKeys(d.doc as ConstDoc, at)", # 되살림 = 거꾸로 밂
|
||||
"paperLines(d.text, d.rows, d.ans, (d.doc as ConstDoc).글줄)", # 글 줄 산출서에
|
||||
"spots: spotsOf(d.ans)",
|
||||
):
|
||||
assert call in sheet, call
|
||||
assert "Object.assign(doc, next);" in sheet # 상세가 쥔 같은 문서 객체 · 자동저장 없음
|
||||
assert len(sheet.splitlines()) < 700
|
||||
|
||||
|
||||
SPOT = {
|
||||
"식": "찾기(QC000431, 유형=유형).시공량 * (1 - (높이감률 + 만약(지붕슬래브 == '아님', 0, 17)) / 100)",
|
||||
"상수": [{"n": 0, "값": 1, "원값": 1}, {"n": 1, "값": 0, "원값": 0},
|
||||
{"n": 2, "값": 17, "원값": 17}, {"n": 3, "값": 100, "원값": 100}],
|
||||
"표값": [{"n": 0, "글": "찾기(QC000431, 유형=유형).시공량", "값": 45, "원값": 45}],
|
||||
} # fmt: skip
|
||||
|
||||
|
||||
def _run_e2():
|
||||
src = IMPORTS.sub("", _text(MODEL))
|
||||
bad = {**SPOT, "상수": SPOT["상수"][:3]}
|
||||
body = (
|
||||
f"\nconst S = {json.dumps(SPOT, ensure_ascii=False)};"
|
||||
f"\nconst B = {json.dumps(bad, ensure_ascii=False)};"
|
||||
f"\nconst F = {json.dumps(FIX, ensure_ascii=False)};"
|
||||
"\nconst show = (p) => p && p.map((x) => x.t === '글' ? x.글 : x.t === '수' ? `[#${x.n}]` : `[표${x.n} ${x.표}]`).join('');"
|
||||
"\nconst notes = [{ 자리: '', 글: '맨 위 글' }, { 자리: 'labor:LB000007#0', 글: '형틀 뒤 글' },"
|
||||
" { 자리: 'material:폼타이#0', 글: '꺼진 줄 뒤' }, { 자리: 'labor:LB000007#0', 글: '' }];"
|
||||
"\nconsole.log(JSON.stringify({"
|
||||
"\n parts: show(formulaParts(S)),"
|
||||
"\n bad: formulaParts(B),"
|
||||
"\n none: formulaParts({ 식: '형틀목공', 상수: [], 표값: [] }),"
|
||||
"\n spots: numSpots(\"만약(a == '3회', LB000007 * 2.5, 줄.'합판 12㎜' / 10)\"),"
|
||||
"\n paper: paperLines(F.text, F.rows, F.ans, notes).map((p) => p.kind + ':' + p.글),"
|
||||
"\n lift: liftAddKeys({ 까닭: { 'add:#0': 'a', 'add:#1/x#0': 'b', 'mid:q': 'c' },"
|
||||
" 글줄: [{ 자리: 'add:#2', 글: 'g' }] }, 1),"
|
||||
"\n spotsNone: spotsOf(null),"
|
||||
"\n}));"
|
||||
) # fmt: skip
|
||||
result = subprocess.run(
|
||||
["node", "--experimental-strip-types", "--no-warnings",
|
||||
"--input-type=module-typescript", "-"],
|
||||
input=src + body, capture_output=True, text=True, encoding="utf-8", timeout=60,
|
||||
) # fmt: skip
|
||||
assert result.returncode == 0, result.stderr
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
def test_790_3_식_조각_글줄_산출서_열쇠_밂():
|
||||
got = _run_e2()
|
||||
assert got["parts"] == (
|
||||
"[표0 QC000431] × ([#0] - (높이감률 + 만약(지붕슬래브 == '아님', [#1], [#2])) / [#3])"
|
||||
) # 서버 scan 차례 그대로 · 표 찾기 = 한 칸
|
||||
assert got["bad"] is None and got["none"] is None # 차례가 안 맞으면 숫자 칸 안 그림
|
||||
assert len(got["spots"]) == 2 # 2.5 · 10 만 — 따옴표 글(3회 · 12㎜) · 이름(LB000007) 안 숫자 뺌
|
||||
paper = got["paper"]
|
||||
assert paper[0] == "글:맨 위 글" and paper[1] == "글:꺼진 줄 뒤" # 맨 위 · 안 그린 줄 = 위로
|
||||
i = paper.index("줄:형틀목공 : 275,790 × 0.1111 = 30,643.3")
|
||||
assert paper[i + 1] == "글:형틀 뒤 글" and "글:" not in paper[i + 2] # 빈 글 안 찍음
|
||||
assert got["lift"]["까닭"] == {"add:#0": "a", "add:#2/x#0": "b", "mid:q": "c"}
|
||||
assert got["lift"]["글줄"] == [{"자리": "add:#3", "글": "g"}]
|
||||
assert got["spotsNone"] is None
|
||||
|
||||
|
||||
# ── 792 식 칸 화면(줄 식 고침 · 칠 때마다 검사 · 변수 줄) ────────────────────────────
|
||||
FX = M02 / "M02_MasterTemplete_Sangeun_SheetFormula.ts"
|
||||
|
||||
|
||||
def test_792_식_칸_정적():
|
||||
s = _text(FX)
|
||||
assert "<button" not in s and "<input" not in s and "document.createElement" not in s
|
||||
assert "sessionStorage." not in s and len(s.splitlines()) < 700
|
||||
for call in (
|
||||
"/sangeun/formula-check", # 검사 길(셈 · 저장 없음)
|
||||
"ctl?.abort();", # 칠 때마다 · 옛 요청 끊기
|
||||
"signal,",
|
||||
'box.input.addEventListener("input"',
|
||||
'box.setError(got.되나 ? undefined : got.까닭.join(" · "))', # 빨간 칸 + 까닭
|
||||
"if (!got?.되나) return", # 틀린 식은 문서에 안 넣음
|
||||
"setFormula(doc, spot, engine)", # 엔진 식을 문서에
|
||||
"clearNums(c.doc as FormulaDoc, spot)", # 같은 자리 상수 · 표값 · 품 덮개 걷음
|
||||
"addVar(c.doc as FormulaDoc,",
|
||||
"editVar(c.doc as FormulaDoc, v.이름, { 이름: to })",
|
||||
"dropVar(c.doc as FormulaDoc, v.이름)",
|
||||
):
|
||||
assert call in s, call
|
||||
sheet = _text(SHEET)
|
||||
for call in (
|
||||
"rowFormula(ctx, it.자리,",
|
||||
"formulaToggle(ctx, it.자리,",
|
||||
"varRows(ctx, (v) => v.자리 === it.자리)",
|
||||
"addVarButton(ctx)",
|
||||
"scope: opt.scope,",
|
||||
'coverKinds(d.doc as ConstDoc, r.cid).includes("식")', # 식 덮개 = 품 칸 안 둠
|
||||
):
|
||||
assert call in sheet, call
|
||||
assert "addRate: () => rateButton.click(), scope }" in _text(DETAIL) # 탭 등록 줄에 층만
|
||||
assert "fetch(" not in s # 길 = Api_Fetch.call(로그인 쿠키)
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
"""793-2a 지킴 — 경쟁사 산근 → 우리 엔진 로직 줄 꼴(`M02_San_Emit`) · 엔진 셈 = 엑셀.
|
||||
|
||||
여덟 파일 STmate 233 · EST 222 블록을 로직 JSON 으로 내보내 `master_formula.run` →
|
||||
`master_cut.engine` 으로 셈 — 노 · 재 · 경 · 계 = 엑셀(STmate 계 꼬리 · EST 총괄표) =
|
||||
참조 평가기(`M02_San_Eval`) · 줄마다(STmate 금액 줄 · EST 돈 · 값 줄) · 계표시(단계) 같음.
|
||||
단가 전파 견본 = `_분석_649-G2` 4 장(보통인부 → 180,000) · 계약단가(낙찰률)는 B09 몫 — 엔진 계 ×
|
||||
낙찰률 원 버림 = 엑셀 머리만 확인. 엑셀 = `helper_m02_hopyo_golden.FILES`(읽기만 · 없으면 skip).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import math
|
||||
from functools import lru_cache
|
||||
|
||||
import helper_m02_hopyo_golden as golden
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01 # noqa: F401 — scripts 길을 둠
|
||||
from M02_MasterTemplete import M02_San_Book as book
|
||||
from M02_MasterTemplete import M02_San_Emit as em
|
||||
from M02_MasterTemplete import M02_San_Est as est
|
||||
from M02_MasterTemplete import M02_San_Eval as ev
|
||||
from M02_MasterTemplete import M02_San_Stmate as stm
|
||||
|
||||
mf = importlib.import_module("master_formula")
|
||||
mcut = importlib.import_module("master_cut")
|
||||
ms = importlib.import_module("master_formula_sum")
|
||||
|
||||
STMATE = { # 파일: (블록, 금액 줄, 계표시 줄, 끝전)
|
||||
"봉화": (62, 349, 184, "비목버림"),
|
||||
"동부청영월": (69, 411, 230, "합버림_큰나머지"),
|
||||
"울진대흥": (47, 261, 128, "비목버림"),
|
||||
"영덕계류": (15, 86, 41, "비목버림"),
|
||||
"울진소광": (40, 208, 112, "비목버림"),
|
||||
}
|
||||
EST = {"북부청임도": (94, 1252), "북부청사방": (67, 849), "거창": (61, 802)} # (블록, 돈 · 값 줄)
|
||||
# 엑셀 글 식이 보인 값과 안 맞는 줄(793-1 틀린 줄 2) — 보인 값으로 얼림 · 블록 금액은 같음
|
||||
EST_FROZEN = {"북부청임도": {27: 1, 33: 1}}
|
||||
K = ("노무비", "재료비", "경비", "계")
|
||||
LABOR = {"종류": "노임", "이름": "보통인부", "규격": "", "열쇠비목": "L"}
|
||||
|
||||
|
||||
def engine(out: dict) -> dict:
|
||||
"""내보낸 로직 → 엔진 셈 — 단가 줄은 SK 서버처럼 값을 얹음(요소 대신 값묶음 {비목: 단가})."""
|
||||
logic = {**out["로직"], "키": "GX990001"}
|
||||
items = []
|
||||
for item in logic["호표"]:
|
||||
one = {k: v for k, v in item.items() if k not in ("이음", "자원", "단가", "규격")}
|
||||
if "단가" in item:
|
||||
money = dict.fromkeys(K[:3], 0) | {item["비목"]: item["단가"]}
|
||||
one |= {"종류": "로직", "값묶음": money}
|
||||
del one["비목"]
|
||||
items.append(one | {"요소": None})
|
||||
logic["호표"] = items
|
||||
master = mf.Master({"로직.json": {"그룹": "로직", "줄": [logic]}})
|
||||
return mcut.engine(master, logic["키"], mf.run(master, logic["키"], {}))
|
||||
|
||||
|
||||
def money(got: dict) -> tuple:
|
||||
return tuple(int(got[k]) for k in K)
|
||||
|
||||
|
||||
@lru_cache(maxsize=8)
|
||||
def _load(tag: str) -> dict:
|
||||
path = golden.FILES[tag]
|
||||
if not path.exists():
|
||||
pytest.skip(f"실무 엑셀 없음 {path.name}")
|
||||
return book.load(path)
|
||||
|
||||
|
||||
def _stmate(tag: str, blk: dict) -> tuple[list, dict]:
|
||||
nodes = stm.parse_block(blk["몸"])
|
||||
return nodes, em.stmate(blk, nodes, _load(tag)["단가"], STMATE[tag][3])
|
||||
|
||||
|
||||
def _lines_equal(out: dict, got: dict) -> tuple[list, int, int]:
|
||||
"""원본 글줄마다 엔진 줄 금액(계) = 엑셀 · 단계 = 계표시 줄 → (틀린 것, 줄 수, 단계 수)."""
|
||||
lines = {x["이름"]: x for x in got["줄"]}
|
||||
steps = {x["이름"]: x for x in got.get("단계", [])}
|
||||
bad, n_line, n_step = [], 0, 0
|
||||
for g in out["원본"]["글줄"]:
|
||||
if g.get("값") is None or not g.get("자리") or g["자리"].startswith("mid:"):
|
||||
continue
|
||||
if g["자리"].startswith("단계:"):
|
||||
n_step += 1
|
||||
have = float(steps[g["자리"][3:]]["계"])
|
||||
tol = 0.15
|
||||
else:
|
||||
n_line += 1
|
||||
have = sum(float(lines[n]["금액"] or 0) for n in g.get("자리들") or [g["자리"]])
|
||||
tol = 0.05
|
||||
if abs(have - g["값"]) >= tol:
|
||||
bad.append((g["행"], g["글"].strip(), have, g["값"]))
|
||||
return bad, n_line, n_step
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", list(STMATE))
|
||||
def test_stmate_engine_equals_excel(tag: str) -> None:
|
||||
data = _load(tag)
|
||||
blocks, n_lines, n_steps, rule = STMATE[tag]
|
||||
n, wrong, lines, steps = 0, [], 0, 0
|
||||
for blk in data["블록"]:
|
||||
if not any(ln["G"].strip() for ln in blk["몸"]):
|
||||
continue
|
||||
n += 1
|
||||
nodes, out = _stmate(tag, blk)
|
||||
got = engine(out)
|
||||
ref = ev.stmate_block(blk, nodes, data["단가"], rule)["계"]
|
||||
want = out["원본"]["엑셀금액"]
|
||||
same = money(got) == tuple(round(want[k]) for k in K)
|
||||
same &= money(got) == (ref["L"], ref["M"], ref["S"], ref["T"])
|
||||
bad, a, b = _lines_equal(out, got)
|
||||
bad += ms.check(out["로직"], blk["코드"]) + out["원본"]["표지"]
|
||||
lines, steps = lines + a, steps + b
|
||||
if deal := out["원본"].get("계약"): # B09 몫 — 엔진 계 × 낙찰률 원 버림 = 엑셀 머리
|
||||
cut = [math.floor(round(int(got[k]) * deal["낙찰률"] / 100, 6)) for k in K[:3]]
|
||||
same &= cut == [deal["금액"][k] for k in K[:3]]
|
||||
if not same or bad:
|
||||
wrong.append((blk["코드"], money(got), bad[:3]))
|
||||
assert (n, wrong) == (blocks, [])
|
||||
assert (lines, steps) == (n_lines, n_steps)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", list(EST))
|
||||
def test_est_engine_equals_excel(tag: str) -> None:
|
||||
data = _load(tag)
|
||||
n, wrong, lines = 0, [], 0
|
||||
for blk in data["블록"]:
|
||||
want = data["총괄"].get(blk["번"])
|
||||
if not want or not (want["T"] or any(want[c] for c in "LMS")):
|
||||
continue
|
||||
n += 1
|
||||
parsed = est.parse_block(blk["글"], data["단가"])
|
||||
out = em.est(blk, parsed, want)
|
||||
got = engine(out)
|
||||
ref = ev.est_block(parsed, ev.designate(parsed, want))["금액"]
|
||||
same = money(got) == (want["L"], want["M"], want["S"], want["T"])
|
||||
same &= money(got) == (ref["L"], ref["M"], ref["S"], ref["T"])
|
||||
bad, a, _ = _lines_equal(out, got)
|
||||
bad += ms.check(out["로직"], str(blk["번"]))
|
||||
lines += a
|
||||
frozen = len(out["원본"]["표지"])
|
||||
if not same or bad or frozen != EST_FROZEN.get(tag, {}).get(blk["번"], 0):
|
||||
wrong.append((blk["번"], money(got), bad[:3], out["원본"]["표지"]))
|
||||
assert (n, wrong, lines) == (EST[tag][0], [], EST[tag][1])
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"tag, code, labor, before, after",
|
||||
[
|
||||
("봉화", "D00102", "L00007", (34119, 11192, 341), (34697, 11192, 346)),
|
||||
("동부청영월", "D00003", "L00002", (4764, 310, 397), (5097, 309, 397)),
|
||||
("울진소광", "D01489", "L00016", (182223, 230359, 8152), (185067, 230359, 8209)),
|
||||
],
|
||||
)
|
||||
def test_stmate_price_propagates(tag, code, labor, before, after) -> None:
|
||||
blk = next(b for b in _load(tag)["블록"] if b["코드"] == code)
|
||||
_, out = _stmate(tag, blk)
|
||||
assert money(engine(out))[:3] == before
|
||||
assert em.reprice(out["로직"], {"코드": labor}, {"L": 180000}) >= 1
|
||||
assert money(engine(out))[:3] == after
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"tag, no, after",
|
||||
[
|
||||
("북부청사방", 31, (14877, 5491, 0)),
|
||||
("북부청임도", 2, (22774, 3235, 3830)),
|
||||
("거창", 1, (3485, 832, 1049)),
|
||||
("북부청사방", 3, (20147, 391, 0)),
|
||||
],
|
||||
)
|
||||
def test_est_price_propagates(tag, no, after) -> None:
|
||||
data = _load(tag)
|
||||
blk = next(b for b in data["블록"] if b["번"] == no)
|
||||
out = em.est(blk, est.parse_block(blk["글"], data["단가"]), data["총괄"][no])
|
||||
assert em.reprice(out["로직"], LABOR, {"L": 180000.0}) >= 1
|
||||
assert money(engine(out))[:3] == after
|
||||
|
||||
|
||||
def test_link_keys_m01() -> None:
|
||||
"""호표 줄 = 793-2 꼴(종류 · 단가 · 이음 = 1차 줄 판정 M01 키) · 덧칸 자원 · 원본."""
|
||||
tag = "봉화"
|
||||
blk = next(b for b in _load(tag)["블록"] if b["코드"] == "D00102")
|
||||
out = em.stmate(blk, stm.parse_block(blk["몸"]), _load(tag)["단가"], "비목버림", True)
|
||||
labor = next(x for x in out["로직"]["호표"] if x["이름"] == "보통인부")
|
||||
assert {k: v for k, v in labor.items() if k != "자원"} == {
|
||||
"이름": "보통인부",
|
||||
"규격": "",
|
||||
"단위": "인",
|
||||
"수량": "(2 / 50)",
|
||||
"종류": "인력",
|
||||
"비목": "노무비",
|
||||
"단가": 165545,
|
||||
"이음": "LB000002",
|
||||
"번지": "A02",
|
||||
}
|
||||
assert labor["자원"] == {
|
||||
"꼴": "STmate",
|
||||
"갈래": "인력",
|
||||
"코드": "L00007",
|
||||
"이름": "보통인부",
|
||||
"규격": None,
|
||||
"단위": "인",
|
||||
"단가": {"L": 165545, "M": 0, "S": 0},
|
||||
"비목": "L",
|
||||
"옮김": None,
|
||||
}
|
||||
src = out["원본"]
|
||||
assert {k: src[k] for k in ("시트", "갈래", "코드", "행")} == {
|
||||
"시트": "단가산출근거",
|
||||
"갈래": "STmate",
|
||||
"코드": "D00102",
|
||||
"행": [2912, 2937],
|
||||
}
|
||||
assert src["엑셀금액"] == {"노무비": 34119, "재료비": 11192, "경비": 341, "계": 45652}
|
||||
assert next(g for g in src["글줄"] if g.get("자리") == "보통인부")["값"] == 6621.8
|
||||
|
||||
|
||||
# ── 엑셀 없이 도는 문법 견본(793-1 `test_stmate_grammar_sample` + 다시 대입 · 뒤 줄) ──
|
||||
def test_stmate_grammar_sample_engine() -> None:
|
||||
prices = {
|
||||
"M00081": {"T": 11468, "L": 0, "M": 11468, "S": 0, "meta": {}, "이름": "합판(내수)"},
|
||||
"L00007": {"T": 165545, "L": 165545, "M": 0, "S": 0, "meta": {}, "이름": "보통인부"},
|
||||
"L00099": {"T": 2, "L": 2, "M": 0, "S": 0, "meta": {"UNT": "L%"}, "이름": "공구"},
|
||||
}
|
||||
text = [
|
||||
"'합판(내수) :'&M00081& * 1.03 * 0.327 :=A01",
|
||||
";;Q = 2.5 / 3 =",
|
||||
"'보통인부' &L00007& * [Q] / 4 :=A02",
|
||||
"&PA01M:M& * 11'%' =",
|
||||
"&PA02L:S& * 1'%' = // 공구손료",
|
||||
"(=)",
|
||||
"&L00099& * 2 =",
|
||||
"(-=)",
|
||||
"'별도' &M00081& * 2 =",
|
||||
"Q = 1 / 3 =",
|
||||
"&L00099& * [Q] =",
|
||||
"'뒤 인부' &L00007& * 0.01 =",
|
||||
]
|
||||
rows = [{"행": i, "G": g} for i, g in enumerate(text)]
|
||||
nodes = stm.parse_block(rows)
|
||||
block = {"코드": "D00001", "이름": "견본", "꼬리": [], "몸": rows}
|
||||
block["머리"] = {"A": "", "B": "", "C": 0, "D": 0, "E": 0, "F": 0}
|
||||
out = em.stmate(block, nodes, prices, "비목버림")
|
||||
logic = out["로직"]
|
||||
assert logic["중간"] == [
|
||||
{"이름": "q", "식": "(2.5 / 3)", "표시": 2},
|
||||
{"이름": "q_2", "식": "(1 / 3)", "표시": 2}, # 다시 대입 = 새 이름
|
||||
]
|
||||
assert ms.check(logic, "견본") == [] and out["원본"]["표지"] == []
|
||||
got = engine(out)
|
||||
lines, tot = ev.run_stmate(nodes, prices)
|
||||
want = ev.block_total(tot, "비목버림")
|
||||
assert money(got) == (want["L"], want["M"], want["S"], want["T"])
|
||||
by = {x["이름"]: x for x in got["줄"]}
|
||||
assert by["보통인부"]["비목"]["노무비"] == 34350.5 # 165,545 × 0.83 / 4
|
||||
assert by["공구"]["비목"]["노무비"] == 687 # 노무 누계 × 2 % · (-=) 로 합에서 뺌
|
||||
assert logic["덧줄"][-1]["식"] == "(노무비 - 줄.'뒤 인부') * ((q_2)) / 100" # 뒤 줄을 뺀 누계
|
||||
assert (
|
||||
float(by["공구_2"]["비목"]["노무비"]) == lines[10]["값"]["L"] == 113.3
|
||||
) # 34,350.5 × 0.33 %
|
||||
|
||||
|
||||
def test_est_grammar_sample_engine() -> None:
|
||||
prices = [{"종류": "노임", "이름": "보통인부", "규격": "", "비목": "L", "값": 172068.0}]
|
||||
text = [
|
||||
"보통인부 : 172,068 × 0.09 인 = 15,486.1",
|
||||
"공구손료 : 15,486.1 × 3 % = 464.5",
|
||||
"소 계 : 15,950.6",
|
||||
"노무비 : 15,950.6 × 1 = 15,950",
|
||||
]
|
||||
lines = est.parse_block(text, prices)
|
||||
want = {"T": 15950.0, "L": 15950.0, "M": 0.0, "S": 0.0}
|
||||
out = em.est({"번": 1, "이름": "견본", "단위": "㎡"}, lines, want)
|
||||
logic = out["로직"]
|
||||
assert [x["식"] for x in logic["덧줄"]] == [
|
||||
"((줄.'보통인부' * 3) / 100)",
|
||||
"줄.'보통인부' + 공구손료",
|
||||
"소계",
|
||||
]
|
||||
assert logic["호표"][0]["종류"] == "인력" and logic["호표"][0]["단가"] == 172068
|
||||
assert logic["덧줄"][2]["자리"] == {"방법": "버림", "자리": 0}
|
||||
assert [x.get("합밖") for x in (*logic["호표"], *logic["덧줄"])] == [True, True, True, None]
|
||||
assert money(engine(out)) == (15950, 0, 0, 15950)
|
||||
em.reprice(logic, LABOR, {"L": 180000.0})
|
||||
assert money(engine(out)) == (16686, 0, 0, 16686) # 793-1 run_est 전파와 같음
|
||||
Reference in New Issue
Block a user