32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
"""704-2 딸림 — 계산서 끝수(줄마다 0.1 · 비목 소계 정수) · 계 = 기준 목록 금액(문서 셈).
|
|
|
|
옛 거울(엔진 줄 + B09 끝수 = `M02_Logic_Settle`)은 부르는 곳 0 이라 그 파일과 함께 걷음(855 L2 ⓑ).
|
|
"""
|
|
|
|
import sys
|
|
from decimal import Decimal
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from M01_MasterData import M01_MasterData_Doc as m01_doc # noqa: E402
|
|
from M01_MasterData import M01_MasterData_Store as m01 # noqa: E402
|
|
from M02_MasterTemplete import M02_Logic_Standard as ls # noqa: E402
|
|
|
|
|
|
def test_계산서_줄_소계_계가_맞물림():
|
|
files, whole = m01.loaded()
|
|
key = "GF000089"
|
|
got = ls.sheet(key, {})
|
|
assert got["묶음"], key
|
|
for group in got["묶음"]:
|
|
lines = [Decimal(str(x["금액"] or 0)) for x in group["줄"]]
|
|
assert all(v == v.quantize(Decimal("0.1")) for v in lines), group["비목"]
|
|
assert group["소계"] == int(group["소계"])
|
|
assert group["소계"] <= sum(lines) < group["소계"] + 1 + Decimal("0.05"), group["비목"]
|
|
assert got["계"] == sum(g["소계"] for g in got["묶음"])
|
|
doc = m01_doc.docs()[key] # 855-C 계산서 = 문서 셈(목록 금액과 같은 값)
|
|
assert got["계"] == ls._money(doc, ls._links(whole), ls._given(whole, doc, {})[0])
|