Merge remote-tracking branch 'origin/sub_laptop_1' into main_laptop_1
This commit is contained in:
@@ -96,7 +96,8 @@ def test_참조_줄_재료_연료_뺌_고른_품목(tmp_path, monkeypatch):
|
||||
price = {"묶음": {"줄": [{"키": "MT9", "이름": "레디믹스트 레미콘", "규격": "25-18-80"}]}}
|
||||
frozen = {
|
||||
ref_id(SC): {
|
||||
"담은로직": [{"로직": "L1", "수량": {"손": 2}}, {"참조": SP}],
|
||||
# 굳힌 옛 사본 = 안 줄 손 다 있음(723-1 앞 · 빈 수량 = 이은 칸 값 · 없으면 안 셈)
|
||||
"담은로직": [{"로직": "L1", "수량": {"손": 2}}, {"참조": SP, "수량": {"손": 1}}],
|
||||
"알약": [{"로직": ["L1"], "배": 10}],
|
||||
},
|
||||
ref_id(SP): {"담은로직": [{"로직": "L2"}], "배": 4},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
175-1 화면 · 저장 — 서고 모드 자재목록 · 로직 자재 세 칸 막힘 풂 · 저장 `_combo_lines` 가
|
||||
고름 · 자재표시 남김 · 문서 `자재`(일위대가 자재 검사 · 로직 자재와 같은 품목 400).
|
||||
175-2 셈 — 담은 자재(손 · 빈칸 = 안 셈)가 사전조합 1 단위 값(`Expand._combo` · 안 줄) · B08 참조 줄
|
||||
175-2 셈 — 담은 자재(수량 = 이은 알약 값 · 723-1 · 손은 저장 안 함)가 사전조합 1 단위 값(`Expand._combo` · 안 줄) · B08 참조 줄
|
||||
재료(`_ref_mats`) · B09 겹 대가 자재 줄 · 프로젝트 사본 단가 묶음(`frozen_materials`)에 들어감.
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@ from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 임시 층 fixture
|
||||
from resources.tester.test_m02_labor_ref import _area, world # noqa: F401 — 임시 층 fixture
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
SRC = os.path.join(HERE, "..", "..", "M02_MasterTemplete")
|
||||
@@ -51,7 +51,7 @@ def test_저장_왕복_고름_자재표시_자재_남음(world): # noqa: F811
|
||||
_, got = _save(world["system"], {"담은로직": [line], "자재": mats})
|
||||
one = got["담은로직"][0]
|
||||
assert one["고름"] == {"4": NET_ITEM} and one["자재표시"] == {"3": {"자재구분": "관급"}}
|
||||
assert [(m["코드"], m["수량"]) for m in got["자재"]] == [(MAT, {"손": 2}), (WIRE, None)]
|
||||
assert [(m["코드"], m["수량"]) for m in got["자재"]] == [(MAT, None), (WIRE, None)] # 723-1
|
||||
assert got["자재"][0]["운반비"] == "미포함" and got["자재"][0]["이름"] != "틀린 이름"
|
||||
# 자재 없음 = 빈 목록(옛 문서 꼴 그대로 읽힘)
|
||||
_, empty = _save(world["system"], {"담은로직": [{"로직": NET}]})
|
||||
@@ -73,8 +73,23 @@ def _price(code):
|
||||
return Decimal(str(labor.material_price(whole, code, None)["기준단가"]))
|
||||
|
||||
|
||||
def _given(key):
|
||||
"""안 줄 알약 값(723-1) — STONE 1 · NET 0 · MAT 2 · WIRE 0."""
|
||||
rid = refs.ref_id({**SYS, "키": key})
|
||||
return {f"{rid}#0": 1, f"{rid}#1": 0, f"{rid}#자재|{MAT}": 2, f"{rid}#자재|{WIRE}": 0}
|
||||
|
||||
|
||||
def _legacy(world, key): # noqa: F811
|
||||
"""옛 손 수량 문서(723-1 앞 · 굳힌 사본 꼴) — B08 · B09 셈 길 시험용 · 파일은 안 바꿈."""
|
||||
doc = json.loads((world["system"] / "precombo" / f"{key}.json").read_bytes())
|
||||
hands = ({"손": 1}, {"손": 0})
|
||||
lines = [{**one, "수량": q} for one, q in zip(doc["담은로직"], hands)]
|
||||
mats = [{**m, "수량": {"손": 2} if m["코드"] == MAT else None} for m in doc["자재"]]
|
||||
return {**doc, "담은로직": lines, "자재": mats}
|
||||
|
||||
|
||||
def _world_combo(world): # noqa: F811
|
||||
"""STONE 1 + MAT 손 2 + WIRE 빈칸(안 셈) · NET 고름 4 = NET_ITEM — (키, 손셈 1 단위 값)."""
|
||||
"""STONE 1 + MAT 2 + WIRE 0 · NET 고름 4 = NET_ITEM — (키, 1 단위 값) · 수량은 `_given`."""
|
||||
lines = [
|
||||
{"로직": STONE, "수량": {"손": 1}},
|
||||
{"로직": NET, "수량": {"손": 0}, "고름": {"4": NET_ITEM}},
|
||||
@@ -95,34 +110,42 @@ def test_사전조합_값에_자재_금액_빈칸은_안_셈_안_줄에_자재(w
|
||||
doc = labor.clean(
|
||||
{"열": "rv", "담은로직": [{"참조": {**SYS, "키": key}, "수량": {"손": 3}}]}
|
||||
)
|
||||
one = labor.calc(doc, {})["줄"][0]
|
||||
bare = labor.calc(doc, {})["줄"][0]
|
||||
one = labor.calc(doc, _given(key))["줄"][0]
|
||||
assert bare["기준"] is None and "수량 없음" in bare["까닭"] # 723-1 — 안 이으면 값 없음
|
||||
assert one["기준"]["계"] == pytest.approx(float(want))
|
||||
assert one["반영"]["계"] == pytest.approx(float(want * 3))
|
||||
mats = [x for x in one["안"] if x.get("자재")]
|
||||
assert [(x["자재"], x["수량"]) for x in mats] == [(MAT, 2)] # WIRE 빈칸 = 안 셈
|
||||
assert [(x["자재"], x["수량"]) for x in mats] == [(MAT, 2)] # WIRE = 기본 별도계상(안 셈)
|
||||
assert mats[0]["기준"]["재료비"] == pytest.approx(float(_price(MAT)))
|
||||
# 목록 기준금액(51-4)도 같은 펼침
|
||||
# 목록 기준금액(51-4) — 이은 값 없음 = 빈 값(723-1)
|
||||
rows = [{"종류": "precombo", "이름": key}]
|
||||
refs.summaries(world["system"], rows)
|
||||
assert rows[0]["기준금액"] == pytest.approx(float(want))
|
||||
assert rows[0]["기준금액"] is None
|
||||
|
||||
|
||||
def test_B08_참조_줄_재료에_사전조합_자재_손_곱(world): # noqa: F811
|
||||
from B08_Quantity.B08_Quantity_Router_Material import _ref_mats
|
||||
|
||||
key, _ = _world_combo(world)
|
||||
with store.at(world["system"]):
|
||||
outer = refs.create(
|
||||
"precombo",
|
||||
{
|
||||
"이름": "겹",
|
||||
"단위": "㎡",
|
||||
"담은로직": [{"참조": {**SYS, "키": key}, "수량": {"손": 3}}],
|
||||
},
|
||||
)["이름"]
|
||||
got = _ref_mats(m01.loaded()[1], refs.read_ref, {**SYS, "키": outer})
|
||||
outer = {
|
||||
"이름": "겹",
|
||||
"단위": "㎡",
|
||||
"담은로직": [{"참조": {**SYS, "키": key}, "수량": {"손": 3}}],
|
||||
}
|
||||
docs = {"SC-겹": outer, key: _legacy(world, key)} # 옛 손 문서(723-1 앞 꼴 · B08 길만 잼)
|
||||
got = _ref_mats(m01.loaded()[1], lambda r: docs.get(r["키"]), {**SYS, "키": "SC-겹"})
|
||||
mats = [(m["품목"]["키"], q) for m, q in got if m.get("자재")]
|
||||
assert mats == [(MAT, pytest.approx(6.0))] # 2 × 겹 손 3 · WIRE 빈칸 없음
|
||||
# 723-1 — 수량 없는 새 문서 = 면적 알약 값(given)으로 · 안 이으면 안 셈
|
||||
live = {"SC-겹": outer, key: refs.read_ref({**SYS, "키": key})}
|
||||
bare = _ref_mats(m01.loaded()[1], lambda r: live.get(r["키"]), {**SYS, "키": "SC-겹"})
|
||||
assert [m for m, _ in bare if m.get("자재")] == []
|
||||
got = _ref_mats(
|
||||
m01.loaded()[1], lambda r: live.get(r["키"]), {**SYS, "키": "SC-겹"}, given=_given(key)
|
||||
)
|
||||
mats = [(m["품목"]["키"], q) for m, q in got if m.get("자재")]
|
||||
assert mats == [(MAT, pytest.approx(6.0))]
|
||||
|
||||
|
||||
def test_B09_겹_대가에_자재_줄(world): # noqa: F811
|
||||
@@ -131,7 +154,7 @@ def test_B09_겹_대가에_자재_줄(world): # noqa: F811
|
||||
key, _ = _world_combo(world)
|
||||
ref = {**SYS, "키": key}
|
||||
build = Builder()
|
||||
bid = build.precombo(m01.loaded()[1], ref, refs.read_ref(ref), {})
|
||||
bid = build.precombo(m01.loaded()[1], ref, _legacy(world, key), {}) # 옛 손 문서(723-1 앞)
|
||||
mats = [x for x in build.blocks[bid]["lines"] if x["kind"] == "material"]
|
||||
assert [(x["key"], x["qty"]) for x in mats] == [(MAT, 2.0), (WIRE, None)]
|
||||
assert mats[0]["name"] and mats[0]["unit"]
|
||||
@@ -150,5 +173,5 @@ def test_사본_단가_묶음에_사전조합_자재_고름_사본_값_같음(wo
|
||||
assert "refs.frozen_materials(" in open(source.__file__, encoding="utf-8").read()
|
||||
bundle = prices.to_json(prices.collect(refs.frozen_logics(rows["참조사본"]), mats))
|
||||
(world["system"] / "precombo" / f"{key}.json").unlink() # 원본이 사라져도 굳힌 사본
|
||||
got = prices.calc(rows, bundle, {}, {}, None)["줄"][0]
|
||||
got = prices.calc(rows, bundle, {}, {}, _area(_given(key)))["줄"][0] # 사본 면적 칸 = 안 줄 값
|
||||
assert got["기준"]["계"] == pytest.approx(float(want), rel=1e-9)
|
||||
|
||||
@@ -32,8 +32,12 @@ def _sc(folder, lines, unit="㎡"):
|
||||
|
||||
|
||||
def _value(folder, key):
|
||||
"""안 줄 수량 = 모두 1(723-1 · 저장 안 함 → 쓰는 쪽 알약 값)."""
|
||||
ref = {**MINE, "키": key}
|
||||
with store.at(folder):
|
||||
return refs.Expand(_whole())({**MINE, "키": key})
|
||||
lines = refs.read_ref(ref)["담은로직"]
|
||||
given = {f"{refs.ref_id(ref)}#{i}": 1 for i in range(len(lines))}
|
||||
return refs.Expand(_whole(), given=given)(ref)
|
||||
|
||||
|
||||
def test_logic_line_cover_in_precombo(world):
|
||||
|
||||
@@ -61,22 +61,24 @@ def test_확인한_줄만_별칭_수량_빠진_줄_장부(client):
|
||||
assert origin["확인"]["누가"] == {"id": 42, "이름": "갑"} and origin["확인"]["때"]
|
||||
stone, *made, soil = doc["담은로직"] # 705-3 — 확인 안 한 줄 · 「우리에 없음」 = 고정 줄
|
||||
assert stone["고정"]["단가"] == {"노무비": 0, "재료비": 1400000, "경비": 0}
|
||||
assert stone["고정"]["출처"]["줄"] == 0 and stone["수량"] == {"손": 1}
|
||||
assert soil["고정"]["이름"] == "잔토처리(인력100%)" and soil["수량"] == {"손": 0.09}
|
||||
hands = origin["실무수량"]["줄"] # 723-1 — 수량 = 저장 안 함 · 엑셀 수량은 출처 기록만
|
||||
assert stone["고정"]["출처"]["줄"] == 0 and stone["수량"] is None and hands["0"] == 1
|
||||
assert soil["고정"]["이름"] == "잔토처리(인력100%)" and soil["수량"] is None
|
||||
assert hands[str(len(doc["담은로직"]) - 1)] == 0.09
|
||||
assert origin["품셈"] == [1, 2] and got["줄수"]["고정"] == 2 and got["빠진줄"] == []
|
||||
assert made == [
|
||||
{
|
||||
"로직": "GF000101",
|
||||
"입력값": {"지역": "서울"},
|
||||
"별칭": "구조물터파기(인력100%)",
|
||||
"수량": {"손": 0.14},
|
||||
"수량": None, # 723-1 — 엑셀 0.14 = 본뜬.실무수량
|
||||
"메모": "실무 0.14㎥ × 1 · 토사",
|
||||
},
|
||||
{
|
||||
"로직": "GF000113",
|
||||
"입력값": {},
|
||||
"별칭": "구조물되메우기(인력100%)",
|
||||
"수량": {"손": 0.1}, # 엑셀 0.05 × 배 2
|
||||
"수량": None, # 엑셀 0.05 × 배 2 = 본뜬.실무수량(723-1)
|
||||
"메모": "실무 0.05㎥ × 2",
|
||||
},
|
||||
]
|
||||
@@ -108,14 +110,20 @@ def test_로직_여럿_같은_별칭_감쌈_자재_몫_덮음(client):
|
||||
first, second, fx, wrapped = doc["담은로직"]
|
||||
assert fx["고정"]["출처"]["줄"] == 2 # 확인 안 한 줄 = 고정(705-3)
|
||||
assert first["별칭"] == second["별칭"] == "구조물터파기(인력100%)" # 한 줄 로직 둘 = 같은 별칭
|
||||
assert second["수량"] == {"손": 0.014} and second["메모"] == "실무 0.14㎥ × 0.1(몫 0.1) · 토사"
|
||||
assert wrapped["별칭"] == "잔토처리(인력100%)" and wrapped["수량"] == {"손": 0.09}
|
||||
hands = doc["본뜬"]["실무수량"]["줄"] # 723-1 — 저장 수량 없음 · 엑셀 수량 = 출처 기록
|
||||
assert second["수량"] is None and hands["1"] == 0.014
|
||||
assert second["메모"] == "실무 0.14㎥ × 0.1(몫 0.1) · 토사"
|
||||
assert (
|
||||
wrapped["별칭"] == "잔토처리(인력100%)" and wrapped["수량"] is None and hands["3"] == 0.09
|
||||
)
|
||||
inner = _doc(mine, wrapped["참조"]["키"])
|
||||
assert inner["본뜬"]["키"] == "HP-000001 제3호표 4째 줄 GF000101"
|
||||
assert inner["담은로직"][0]["로직"] == "GF000101" and inner["담은로직"][0]["수량"] == {"손": 1}
|
||||
assert inner["담은로직"][0]["로직"] == "GF000101" and inner["담은로직"][0]["수량"] is None
|
||||
assert inner["본뜬"]["실무수량"]["줄"] == {"0": 1}
|
||||
assert [(m["코드"], m["수량"], m["별도계상"]) for m in doc["자재"]] == [
|
||||
("MT004258", {"손": 1}, "직접계산")
|
||||
("MT004258", None, "직접계산")
|
||||
]
|
||||
assert doc["본뜬"]["실무수량"]["자재"] == {"MT004258": 1}
|
||||
stone = next(v for k, v in _book(mine).items() if k.startswith("임도표지석(받침"))
|
||||
assert stone["짝"][0]["자재"] == "MT004258"
|
||||
files = sorted(p.name for p in (mine / "precombo").glob("*.json"))
|
||||
@@ -232,14 +240,15 @@ def test_하위_호표_먼저_확인_퍼센트_빠짐_통째(client):
|
||||
assert rate["비율"] == {"기준": "재료비", "비목": "재료비"}
|
||||
got = _build(client, 45, ref)
|
||||
mine = layers.personal_dir(7, 42)
|
||||
line = _doc(mine, got["참조"]["키"])["담은로직"][0]
|
||||
made = _doc(mine, got["참조"]["키"])
|
||||
line = made["담은로직"][0]
|
||||
assert line["참조"] == child["참조"] and line["별칭"] == "고화매트재료비"
|
||||
assert line["수량"] == {"손": 2.3}
|
||||
assert line["수량"] is None and made["본뜬"]["실무수량"]["줄"]["0"] == 2.3 # 723-1
|
||||
assert "고화매트재료비||m2" not in _book(mine) # 호표 참조 줄 = 장부 안 씀
|
||||
whole = _build(client, 3, 통째={"대상": [{"로직": "GF000101", "배": 1}]})
|
||||
doc = _doc(mine, whole["참조"]["키"])
|
||||
assert [x["로직"] for x in doc["담은로직"]] == ["GF000101"]
|
||||
assert doc["담은로직"][0]["수량"] == {"손": 1}
|
||||
assert doc["담은로직"][0]["수량"] is None and doc["본뜬"]["실무수량"]["줄"] == {"0": 1}
|
||||
assert {x["까닭"] for x in whole["빠진줄"]} == {"호표 통째로 대신"}
|
||||
head = next(v for k, v in _book(mine).items() if k.startswith("호표|임도표지석|"))
|
||||
assert head["짝"][0]["로직"] == "GF000101" and head["원래"]["품명"] == "임도표지석"
|
||||
|
||||
@@ -128,8 +128,10 @@ def test_섞인_줄_몫_배(client):
|
||||
assert screen["lines"][0]["checkable"] and not screen["lines"][0]["checked"]
|
||||
one = {k: part[k] for k in ("로직", "입력값", "배", "몫")}
|
||||
made = _build(client, "HP-000001", no, [{"차례": line["차례"], "대상": [one]}])
|
||||
row = next(x for x in _doc(made["참조"])["담은로직"] if x.get("로직") == "GF000211")
|
||||
assert row["수량"]["손"] == round(line["수량"] * 0.1, 6)
|
||||
doc = _doc(made["참조"])
|
||||
at = next(i for i, x in enumerate(doc["담은로직"]) if x.get("로직") == "GF000211")
|
||||
assert doc["담은로직"][at]["수량"] is None # 723-1 — 수량 저장 안 함 · 엑셀 수량 = 출처 기록
|
||||
assert doc["본뜬"]["실무수량"]["줄"][str(at)] == round(line["수량"] * 0.1, 6)
|
||||
|
||||
|
||||
def test_막는_길(client):
|
||||
|
||||
@@ -73,6 +73,13 @@ def _combo(folder, lines, name="조합"):
|
||||
return refs.create("precombo", {"이름": name, "단위": "㎡", "담은로직": lines})["이름"]
|
||||
|
||||
|
||||
def _area(given):
|
||||
"""면적산출 사본 꼴 — 알약 키마다 칸 하나(723-1 · 안 줄 수량 = 이은 칸 값)."""
|
||||
cells = {f"A{i}": {"값": v} for i, v in enumerate(given.values(), 1)}
|
||||
links = [{"칸": f"A{i}", "키": k} for i, k in enumerate(given, 1)]
|
||||
return {"시트": [{"id": "s", "칸": cells, "연결": links}]}
|
||||
|
||||
|
||||
def _read(folder, kind, key):
|
||||
return json.loads((folder / kind / f"{key}.json").read_bytes())
|
||||
|
||||
@@ -221,7 +228,9 @@ def test_calc_는_참조를_펼침_승격은_기준_나누기_배_사전조합
|
||||
ref = {**SYS, "키": sc}
|
||||
with store.at(world["system"]):
|
||||
doc = labor.clean({"열": "rv", "담은로직": [{"참조": ref, "수량": {"손": 5}}]})
|
||||
got = labor.calc(doc, {})
|
||||
bare = labor.calc(doc, {})["줄"][0] # 723-1 — 안 줄 손은 저장 안 함 · 안 이으면 수량 없음
|
||||
got = labor.calc(doc, {f"{refs.ref_id(ref)}#0": 2}) # 안 줄 알약 = 구조물 조합 칸 값
|
||||
assert bare["기준"] is None and "수량 없음" in bare["까닭"] and bare["안"][0]["수량"] is None
|
||||
one = got["줄"][0]
|
||||
want = Decimal(str(_base(TEN)["계"])) / 10 * 2
|
||||
assert one["기준"]["계"] == pytest.approx(float(want))
|
||||
@@ -233,7 +242,9 @@ def test_calc_는_참조를_펼침_승격은_기준_나누기_배_사전조합
|
||||
assert one["반영"]["계"] == pytest.approx(float(want * 5))
|
||||
assert one["안"][0]["수량"] == 2 and one["안"][0]["참조"]["키"] == sp
|
||||
pills = labor.pills(doc)
|
||||
assert pills == [{"키": refs.ref_id(ref), "이름": "둘", "단위": "㎡", "로직": [], "참조": ref}]
|
||||
assert pills[0] == {"키": refs.ref_id(ref), "이름": "둘", "단위": "㎡", "로직": [], "참조": ref}
|
||||
assert [p["키"] for p in pills[1:]] == [f"{refs.ref_id(ref)}#0"] # 안 줄 알약(723-1)
|
||||
assert pills[1]["이름"].startswith("둘 · ")
|
||||
|
||||
|
||||
def test_승격_줄_상세는_원_로직_키_표_사전조합은_안_줄만(world):
|
||||
@@ -386,9 +397,10 @@ def test_프로젝트는_참조사본으로_굳힘_원본을_지워도_같은_
|
||||
sp = _promote(world["system"])
|
||||
sc = _combo(world["system"], [{"참조": {**SYS, "키": sp}, "수량": {"손": 2}}])
|
||||
ref = {**SYS, "키": sc}
|
||||
given = {f"{refs.ref_id(ref)}#0": 2} # 723-1 — 안 줄 수량 = 이은 칸 값
|
||||
with store.at(world["system"]):
|
||||
doc = labor.clean({"열": "rv", "담은로직": [{"참조": ref, "수량": {"손": 1}}]})
|
||||
live = labor.calc(doc, {})["줄"][0]["기준"]["계"]
|
||||
live = labor.calc(doc, given)["줄"][0]["기준"]["계"]
|
||||
rows = source.labor_doc_rows(doc)
|
||||
assert set(rows["참조사본"]) == {refs.ref_id(ref), refs.ref_id({**SYS, "키": sp})}
|
||||
assert refs.frozen_logics(rows["참조사본"]) == [TEN]
|
||||
@@ -396,7 +408,7 @@ def test_프로젝트는_참조사본으로_굳힘_원본을_지워도_같은_
|
||||
for key in (sc, sp): # 원본이 사라져도 프로젝트는 사본만 봄
|
||||
kind = refs.kind_of(key)
|
||||
(world["system"] / kind / f"{key}.json").unlink()
|
||||
got = prices.calc(rows, bundle, {}, {}, None)
|
||||
got = prices.calc(rows, bundle, {}, {}, _area(given))
|
||||
line = got["줄"][0]
|
||||
assert not line["까닭"] and line["참조"] == ref # 층 셈 꼴(142-1)
|
||||
assert line["기준"]["계"] == pytest.approx(live, rel=1e-9)
|
||||
@@ -438,8 +450,8 @@ def test_층_목록_서고_줄은_이름_단위_기준금액을_실음(world):
|
||||
sc = _combo(world["system"], [{"참조": {**SYS, "키": sp}, "수량": {"손": 3}}], "셋")
|
||||
rows = [{"종류": "precombo", "이름": sc}, {"종류": "labor", "이름": "rv"}]
|
||||
refs.summaries(world["system"], rows)
|
||||
one = float(Decimal(str(_base(TEN)["계"])) / 10)
|
||||
assert (rows[0]["제목"], rows[0]["기준금액"]) == ("셋", pytest.approx(one * 3))
|
||||
# 723-1 — 안 줄 수량 저장 안 함 → 목록 기준금액 없음(쓰는 쪽 알약으로만 값)
|
||||
assert (rows[0]["제목"], rows[0]["기준금액"]) == ("셋", None)
|
||||
assert "기준금액" not in rows[1]
|
||||
|
||||
|
||||
@@ -456,16 +468,17 @@ def test_사전조합_로직_줄_섞임_합은_손셈_지우기_409_굳힘(world
|
||||
]
|
||||
sc = _combo(world["system"], lines, "섞음")
|
||||
saved = _read(world["system"], "precombo", sc)["담은로직"]
|
||||
assert saved[1:] == [
|
||||
{"로직": STONE, "입력값": {}, "수량": {"손": 3}, "메모": "돌"},
|
||||
{"로직": TEN, "입력값": {}, "수량": {"손": 1}, "메모": None},
|
||||
assert saved[1:] == [ # 723-1 — 안 줄 수량 저장 안 함
|
||||
{"로직": STONE, "입력값": {}, "수량": None, "메모": "돌"},
|
||||
{"로직": TEN, "입력값": {}, "수량": None, "메모": None},
|
||||
]
|
||||
ten, stone = (Decimal(str(_base(c)["계"])) for c in (TEN, STONE))
|
||||
want = ten / 10 * 2 + stone * 3 + ten / 10 * 1 # 손셈 — 승격 · TEN 은 원/10㎡(배 10)
|
||||
want = ten / 10 * 2 + stone * 3 + ten / 10 * 1 # 이은 수량 — 승격 · TEN 은 원/10㎡(배 10)
|
||||
ref = {**SYS, "키": sc}
|
||||
given = {f"{refs.ref_id(ref)}#{i}": q for i, q in enumerate((2, 3, 1))}
|
||||
with store.at(world["system"]):
|
||||
doc = labor.clean({"열": "rv", "담은로직": [{"참조": ref, "수량": {"손": 5}}]})
|
||||
one = labor.calc(doc, {})["줄"][0]
|
||||
one = labor.calc(doc, given)["줄"][0]
|
||||
assert one["기준"]["계"] == pytest.approx(float(want))
|
||||
assert one["반영"]["계"] == pytest.approx(float(want * 5))
|
||||
assert [x.get("로직") or x["참조"]["키"] for x in one["안"]] == [sp, STONE, TEN]
|
||||
@@ -482,16 +495,16 @@ def test_사전조합_로직_줄_섞임_합은_손셈_지우기_409_굳힘(world
|
||||
bundle = prices.to_json(prices.collect([TEN, STONE]))
|
||||
for key in (sc, sp): # 원본이 사라져도 굳힌 사본으로 같은 값
|
||||
(world["system"] / refs.kind_of(key) / f"{key}.json").unlink()
|
||||
got = prices.calc(rows, bundle, {}, {}, None)["줄"][0]
|
||||
got = prices.calc(rows, bundle, {}, {}, _area(given))["줄"][0]
|
||||
assert got["기준"]["계"] == pytest.approx(float(want), rel=1e-9)
|
||||
|
||||
|
||||
def test_사전조합이_자기_자신을_담으면_422_수량_기본_1(world):
|
||||
def test_사전조합이_자기_자신을_담으면_422_수량_없음(world):
|
||||
sp = _promote(world["system"])
|
||||
a = _combo(world["system"], [{"참조": {**SYS, "키": sp}}], "가")
|
||||
with store.at(world["system"]):
|
||||
have = store.read("precombo", a)
|
||||
assert have["문서"]["담은로직"][0]["수량"] == {"손": 1}
|
||||
assert have["문서"]["담은로직"][0]["수량"] is None # 723-1 — 기본 1 걷음
|
||||
with pytest.raises(store.StoreError) as e:
|
||||
store.write(
|
||||
"precombo",
|
||||
@@ -535,14 +548,16 @@ def test_사전조합_굳힘은_안_로직_알약도_사본_값_142_2(world, mon
|
||||
with store.at(world["system"]):
|
||||
doc = labor.clean({"열": "rv", "담은로직": [{"참조": ref, "수량": {"손": 1}}]})
|
||||
rows = source.labor_doc_rows(doc)
|
||||
given = {f"{refs.ref_id(ref)}#0": 1}
|
||||
kept = rows["참조사본"][refs.ref_id(ref)]["알약"]
|
||||
assert [(p["로직"], p.get("배")) for p in kept] == [([TEN], 10)]
|
||||
assert "알약" not in _read(world["system"], "precombo", sc) # 층 문서는 그대로
|
||||
bundle = prices.to_json(prices.collect([TEN]))
|
||||
before = prices.calc(rows, bundle, {}, {}, None)["줄"][0]["기준"]["계"]
|
||||
before = prices.calc(rows, bundle, {}, {}, _area(given))["줄"][0]["기준"]["계"]
|
||||
changed = {"물량": [{"키": "x|㎡", "이름": "x", "단위": "㎡", "로직": [TEN]}]} # 배 1 로 바뀜
|
||||
monkeypatch.setattr(combo_store, "combo_pills", lambda row: changed)
|
||||
assert prices.calc(rows, bundle, {}, {}, None)["줄"][0]["기준"]["계"] == pytest.approx(before)
|
||||
again = prices.calc(rows, bundle, {}, {}, _area(given))["줄"][0]["기준"]["계"]
|
||||
assert again == pytest.approx(before)
|
||||
with store.at(world["system"]):
|
||||
live = labor.calc(doc, {})["줄"][0]["기준"]["계"]
|
||||
live = labor.calc(doc, given)["줄"][0]["기준"]["계"]
|
||||
assert live == pytest.approx(before * 10) # 층 셈은 지금 M01(배 1)
|
||||
|
||||
Reference in New Issue
Block a user