feat(836-2): M02 단가산출 M01 자동 따라옴 — 서버(사본 줄 · 부름 문서 · 고친 항목 다시 복사 · 알림)
- 새 M02_Sk_AutoRenew — 프로젝트 층 밖 SK 사본 줄 = 지금 M01(+ 내 기계) · 부름 문서 = 지금 M01 수식 문서 - 고침 판정 = 내용 대조(끊음 대 부름 · 따로 문서 대 처음) · 바꿨다 되돌림 = 안 고침 - M01 에서 바뀐 항목의 고침 = 지움 + 다시 복사 + 열기 답 사본.갱신 알림 · 사본.자동 표지 - 파일은 [저장] · 알림 확인(저장) 때만 씀 · 읽기 길 안 씀 · 프로젝트 층 그대로 - 옛 시험 8 개 = 손 갱신 길(프로젝트 층 꼴 · 자동 끔) 고정 — 개인 층 「금액 그대로」 단언이 낡음 - 새 시험 test_836_2_sk_auto_renew(㉠ ~ ㉦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,15 @@ from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Sangeun_Imported as imp
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
PCT = "GC001109" # 원/㎡ · 인력 둘 + 「노무비 * 3 / 100」
|
||||
MAN = "LB000002" # 보통인부
|
||||
|
||||
|
||||
@@ -32,6 +32,15 @@ from resources.tester.test_795_1_sk_copy import (
|
||||
)
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
KEY = "GC000211" # 합판거푸집 — 중간 시공량 · 형틀목공 · 보통인부 · 호표 0 = 형틀목공
|
||||
DOUBLE = [{"할일": "식", "자리": "호표:0", "식": "형틀목공 × 2", "까닭": "sub2임시 시험"}]
|
||||
|
||||
|
||||
@@ -28,6 +28,15 @@ from resources.tester.test_795_2_sc_copy import LB, PCT, _double, _labor, _sc
|
||||
from resources.tester.test_795_2_sc_copy import _calc as _sc_calc
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
FORM = "GC000211" # 합판거푸집(옵션 많음)
|
||||
BASIC = "GF000089" # 토사깍기(기계) — 굴착기 시간당 × 1 / 작업량(813-2 GC001148 지움 뒤)
|
||||
ADD = {"종류": "로직", "로직": BASIC, "수량": 2, "입력값": {}, "이름": "sub2임시 굴착기"}
|
||||
|
||||
@@ -26,6 +26,15 @@ from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Template_Layers as layers
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
DIG = "EQ000022" # 굴착기(무한궤도) 1.0㎥ — 연료 · 조종원 있음
|
||||
PCT = "GC001109" # M01 만 쓰는 SK 바탕
|
||||
NAME = "서브셋임시기계" # 찾기 기종 글(수 = 규격으로 읽음 · 창 표시는 글로)
|
||||
|
||||
@@ -22,6 +22,15 @@ from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
DIG, DIG_NO, DIG_LOGIC = "EQ000022", "0201-0100", "GC000267" # 굴착기(무한궤도) 1.0㎥
|
||||
DIG2_NO = "0201-0070" # 바꿔 끼울 굴착기
|
||||
MAN = "LB000002" # 보통인부
|
||||
|
||||
@@ -14,6 +14,8 @@ import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Doc_Import as dim
|
||||
from M02_MasterTemplete import M02_Doc_Sk as dsk
|
||||
@@ -24,6 +26,15 @@ from M02_MasterTemplete import M02_Sangeun_Imported as imp
|
||||
from resources.tester.test_822_1_copy_gap import _move
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
HERE = os.path.dirname(__file__)
|
||||
DIG = "GC000267" # 굴착기 시간당 경비
|
||||
NOW, NEW, NEW_EQ = "'0201-0070'", "'0201-0100'", "EQ000022" # 0.7㎥ → 1.0㎥
|
||||
|
||||
@@ -14,6 +14,8 @@ import copy
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Doc_Sk_Path as path
|
||||
from M02_MasterTemplete import M02_Item_Prices as prices
|
||||
@@ -36,6 +38,15 @@ from resources.tester.test_822_1_copy_gap import (
|
||||
)
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
DIG_BASE = "GC000088" # 터파기(기계) 보통토사 — 「기계」 고르기 후보를 닫힌 묶음이 다 담음
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,15 @@ from M02_MasterTemplete import M02_MyMachine_Draft as draft
|
||||
from M02_MasterTemplete import M02_MyMachine_Router as route
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _manual(monkeypatch):
|
||||
"""836-2 — 이 시험 = 손 갱신 길(프로젝트 층 꼴 · 자동 따라옴 끔) · 자동 = test_836_2."""
|
||||
from M02_MasterTemplete import M02_Sk_AutoRenew as renew
|
||||
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
DIG = "EQ000022" # 굴착기(무한궤도) 1.0㎥ — 연료 · 조종원 있음
|
||||
NAME = "sub1임시 기계"
|
||||
USER = {"role": "USER", "company_id": 7, "user_id": 42}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀
|
||||
"""836-2 M01 → M02 단가산출 자동 따라옴(요구 854) — 임시 storage + M01 메모리 사본(정본 파일 안 고침).
|
||||
|
||||
㉠ 노임 · 재료 · 기계 값 바뀜 = 누르지 않고 새 금액(수식 길 열기 · 옛 셈 길 목록 · 일위대가 펼침 같은 답)
|
||||
㉡ 부른 M01 수식 문서 바뀜 = 따라옴 ㉢ 고친 문서 + 그 문서 M01 바뀜 = 다시 복사 + 알림(전 · 후 · 내 고침)
|
||||
㉣ 고침 + 다른 항목만 바뀜 = 고침 그대로 ㉤ 바꿨다 되돌림 = 안 고침(알림 없음)
|
||||
㉥ 프로젝트 층 = 그대로 ㉦ 가져온 식(우리) = 값만 · 식 그대로 · 열기 = 파일 안 고침 · 알림 [확인] = 저장.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Doc_Sk_Path as path
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_822_1_copy_gap import (
|
||||
DIG,
|
||||
MACHINE,
|
||||
MAN,
|
||||
PCT,
|
||||
_at,
|
||||
_live,
|
||||
_move,
|
||||
_sk,
|
||||
_stack,
|
||||
_sum,
|
||||
)
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
TOOL = 2 # PCT 「공구손료 및 경장비」 금액 줄 차례
|
||||
|
||||
|
||||
def _doc_move(monkeypatch, key: str, fn) -> None:
|
||||
"""M01 수식 문서 하나 고침(메모리 · 폴더 그대로)."""
|
||||
live = dc.folder()
|
||||
new = copy.deepcopy(live[key])
|
||||
fn(new)
|
||||
fake = {**live, key: new}
|
||||
monkeypatch.setattr(dc, "folder", lambda: fake)
|
||||
|
||||
|
||||
def _rate(text: str):
|
||||
def fn(d: dict) -> None:
|
||||
d["금액"][TOOL]["단가"] = text
|
||||
|
||||
return fn
|
||||
|
||||
|
||||
def _edit(me, key: str, text: str) -> None:
|
||||
got = _at(me, path.read, key)
|
||||
doc = copy.deepcopy(got["문서"])
|
||||
doc["금액"][TOOL]["단가"] = text
|
||||
_at(me, path.save, key, {"문서": doc, "판": got["판"]})
|
||||
|
||||
|
||||
def _base(me) -> str:
|
||||
return _sk(me, 바탕={"로직": PCT}, 단위="㎡")
|
||||
|
||||
|
||||
def _labor_unit(me, key: str):
|
||||
"""일위대가 줄이 SK 참조를 펼치는 길(`Expand` → `calc.unit`) 1 단위 계."""
|
||||
from M02_MasterTemplete.M02_Labor_Expand import Expand
|
||||
|
||||
with store.at(me):
|
||||
ref = {"층": "personal", "주인": "7/42", "키": key}
|
||||
whole = _live()
|
||||
got = calc.unit(refs.read_ref(ref), whole, Expand(whole), ())
|
||||
return got["기준"]["계"] if got["기준"] else None
|
||||
|
||||
|
||||
def _list_unit(me, key: str):
|
||||
"""목록 · 옛 셈 길(`calc_doc`) 1 단위 계."""
|
||||
with store.at(me):
|
||||
got = calc.calc_doc(store.read("sangeun", key)["문서"], None, False)
|
||||
return got["1단위"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what", ["노임", "재료", "기계"])
|
||||
def test_values_follow(world, monkeypatch, what):
|
||||
"""㉠ 값 바뀜 = 묻지 않고 새 금액 · 세 길 같은 답 · 열기 = 파일 안 고침 · 알림 없음."""
|
||||
me = world["personal"]
|
||||
key = _sk(me)
|
||||
res = {"노임": MAN, "재료": next(iter(_live().index["MT"])), "기계": DIG}[what]
|
||||
link = MACHINE if what == "기계" else {"갈래": "요소", "키": res}
|
||||
part = {"노임": "노무비", "재료": "재료비", "기계": "묶음"}[what]
|
||||
_stack(me, key, [("자원", link, part)])
|
||||
was = _sum(me, key)
|
||||
file = me / "sangeun" / f"{key}.json"
|
||||
before = file.read_bytes()
|
||||
_move(monkeypatch, res)
|
||||
got = _at(me, path.read, key)
|
||||
assert got["셈"]["계"] > was
|
||||
assert got["사본"]["자동"] is True and got["사본"]["갱신"] == []
|
||||
assert not got["사본"]["단가새값"] and not got["사본"]["M01새판"]
|
||||
unit = _list_unit(me, key)
|
||||
assert unit["계"] == pytest.approx(got["셈"]["계"])
|
||||
assert _labor_unit(me, key) == pytest.approx(got["셈"]["계"])
|
||||
assert file.read_bytes() == before # 읽기 = 작업본 안 씀
|
||||
|
||||
|
||||
def test_logic_follows(world, monkeypatch):
|
||||
"""㉡ 부른 M01 수식 문서(기계 시간당) 바뀜 = 따라옴 · 알림 없음."""
|
||||
me = world["personal"]
|
||||
key = _sk(me)
|
||||
_stack(me, key, [("기계", MACHINE, "묶음")])
|
||||
was = _sum(me, key)
|
||||
|
||||
def twice(d: dict) -> None:
|
||||
for line in d["금액"]:
|
||||
line["수량"] = f"({line.get('수량') or 1}) × 2"
|
||||
|
||||
_doc_move(monkeypatch, MACHINE["키"], twice)
|
||||
got = _at(me, path.read, key)
|
||||
assert got["셈"]["계"] > was * 1.5 # 율 줄은 누계를 받아 두 배 넘음
|
||||
assert got["사본"]["갱신"] == [] and not got["사본"]["문서새판"]
|
||||
|
||||
|
||||
def test_edited_item_recopied(world, monkeypatch):
|
||||
"""㉢ 고친 문서 + 그 M01 문서 바뀜 = 고침 지우고 다시 복사 + 알림(전 · 후 · 내 고침) ·
|
||||
[확인](저장) 뒤 알림 없음 · 따로 아님."""
|
||||
me = world["personal"]
|
||||
key = _base(me)
|
||||
plain = _sum(me, key)
|
||||
_edit(me, key, "노무비 × 5%")
|
||||
assert _sum(me, key) > plain
|
||||
_doc_move(monkeypatch, PCT, _rate("노무비 × 4%"))
|
||||
got = _at(me, path.read, key)
|
||||
labor = got["셈"]["노무비"]
|
||||
assert got["셈"]["경비"] == pytest.approx(int(labor * 0.04), abs=1)
|
||||
assert got["문서"]["금액"][TOOL]["단가"] == "노무비 × 4%"
|
||||
[note] = got["사본"]["갱신"]
|
||||
assert note["키"] == PCT and note["갈래"] == "문서"
|
||||
assert any("3%" in x and "4%" in x for x in note["M01"])
|
||||
assert any("3%" in x and "5%" in x for x in note["내고침"])
|
||||
_at(me, path.save, key, {"할일": "갱신확인", "판": got["판"]})
|
||||
after = _at(me, path.read, key)
|
||||
assert after["사본"]["갱신"] == [] and after["사본"]["따로"] is False
|
||||
assert after["셈"]["계"] == got["셈"]["계"]
|
||||
|
||||
|
||||
def test_edit_kept_when_other_item_moves(world, monkeypatch):
|
||||
"""㉣ 고침 + 다른 항목(노임 값)만 바뀜 = 고침 그대로 · 값은 따라옴."""
|
||||
me = world["personal"]
|
||||
key = _base(me)
|
||||
_edit(me, key, "노무비 × 5%")
|
||||
was = _at(me, path.read, key)["셈"]
|
||||
_move(monkeypatch, MAN)
|
||||
got = _at(me, path.read, key)
|
||||
assert got["문서"]["금액"][TOOL]["단가"] == "노무비 × 5%"
|
||||
assert got["사본"]["따로"] is True and got["사본"]["갱신"] == []
|
||||
assert got["셈"]["노무비"] > was["노무비"]
|
||||
|
||||
|
||||
def test_reverted_is_not_edit(world, monkeypatch):
|
||||
"""㉤ 바꿨다 되돌려 저장 = 안 고침 — M01 바뀌면 조용히 따라옴(알림 없음)."""
|
||||
me = world["personal"]
|
||||
key = _base(me)
|
||||
_edit(me, key, "노무비 × 5%")
|
||||
_edit(me, key, "노무비 × 3%")
|
||||
_doc_move(monkeypatch, PCT, _rate("노무비 × 4%"))
|
||||
got = _at(me, path.read, key)
|
||||
assert got["사본"]["갱신"] == []
|
||||
assert got["문서"]["금액"][TOOL]["단가"] == "노무비 × 4%"
|
||||
|
||||
|
||||
def test_project_layer_keeps(world, monkeypatch, tmp_path):
|
||||
"""㉥ 프로젝트 층 사본 = 그대로(M01 바뀌어도 금액 같음 · 고침 그대로)."""
|
||||
me = world["personal"]
|
||||
key = _base(me)
|
||||
_edit(me, key, "노무비 × 5%")
|
||||
proj = me.parent / "p836" / "templates"
|
||||
(proj / "sangeun").mkdir(parents=True)
|
||||
shutil.copy(me / "sangeun" / f"{key}.json", proj / "sangeun" / f"{key}.json")
|
||||
with store.at(proj):
|
||||
assert refs.here()[0] == "project"
|
||||
was = _at(proj, path.read, key)
|
||||
_move(monkeypatch, MAN)
|
||||
_doc_move(monkeypatch, PCT, _rate("노무비 × 4%"))
|
||||
got = _at(proj, path.read, key)
|
||||
assert got["셈"]["계"] == was["셈"]["계"] and got["사본"]["자동"] is False
|
||||
assert got["문서"]["금액"][TOOL]["단가"] == "노무비 × 5%" and got["사본"]["갱신"] == []
|
||||
|
||||
|
||||
def test_imported_values_only(world, monkeypatch):
|
||||
"""㉦ 가져온 식 단가기준 우리 = 이음 노임만 따라옴 · 가져온 줄 식 그대로 · 엑셀 기준 = 엑셀 값."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Imported as imp
|
||||
|
||||
me = world["personal"]
|
||||
man = {"종류": "인력", "이름": "보통인부", "단위": "인", "수량": "0.5", "비목": "노무비"}
|
||||
row = {
|
||||
"이름": "sub2임시 가져온",
|
||||
"결과단위": "원/㎡",
|
||||
"호표": [{**man, "단가": 165545, "이음": MAN}],
|
||||
}
|
||||
key = _at(me, lambda: imp.create(row, None, "sub2임시 가져온")["이름"])
|
||||
excel = _sum(me, key)
|
||||
doc = _at(me, lambda: store.read("sangeun", key)["문서"])
|
||||
ours = _at(me, lambda: imp.to_price(doc, "우리")["문서"])
|
||||
_at(me, lambda: store.write("sangeun", key, store.read("sangeun", key)["판"], ours))
|
||||
was = _at(me, path.read, key)
|
||||
_move(monkeypatch, MAN)
|
||||
got = _at(me, path.read, key)
|
||||
assert got["셈"]["계"] == pytest.approx(was["셈"]["계"] * 2, abs=2)
|
||||
assert got["문서"]["금액"] == was["문서"]["금액"] and got["사본"]["갱신"] == []
|
||||
back = _at(me, lambda: imp.to_price(store.read("sangeun", key)["문서"], "엑셀")["문서"])
|
||||
_at(me, lambda: store.write("sangeun", key, store.read("sangeun", key)["판"], back))
|
||||
assert _sum(me, key) == excel
|
||||
Reference in New Issue
Block a user