Merge remote-tracking branches 'origin/main_desktop_1' and 'origin/sub_laptop_1' into sub_laptop_3
This commit is contained in:
@@ -185,6 +185,12 @@ def post_calc(body: CalcBody) -> dict:
|
||||
return _call(store.calc, body.key, body.inputs, body.row, body.file)
|
||||
|
||||
|
||||
@router.post("/text")
|
||||
def post_text(body: CalcBody) -> dict:
|
||||
"""읽는 식 줄 — 몸은 `/calc` 와 같음."""
|
||||
return _call(store.text, body.key, body.inputs, body.row, body.file)
|
||||
|
||||
|
||||
@router.post("/save")
|
||||
def post_save(body: SaveBody) -> dict:
|
||||
return {"files": _call(store.save, [f.model_dump() for f in body.files])}
|
||||
|
||||
@@ -20,6 +20,7 @@ sys.path.insert(0, str(SCRIPTS))
|
||||
|
||||
import check_master as cm # noqa: E402
|
||||
import master_keys as mk # noqa: E402
|
||||
import master_text as mtx # noqa: E402
|
||||
|
||||
from M01_MasterData.M01_MasterData_Store_Shape import dump, keep_shape # noqa: E402
|
||||
|
||||
@@ -540,6 +541,18 @@ def calc(key: str, inputs: dict, row: dict | None = None, file: str | None = Non
|
||||
}
|
||||
|
||||
|
||||
def text(key: str, inputs: dict, row: dict | None = None, file: str | None = None):
|
||||
"""사람이 읽는 식 줄 — 비목 묶음마다 「이름 : 단가 * 수량식 = 금액」 과 소계(`master_text`)."""
|
||||
given = {k: _dec(v) for k, v in inputs.items()}
|
||||
files = cm.load(folder=FOLDER)
|
||||
if row is not None:
|
||||
key = _swap(files, str(row.get("키") or key), row, file)
|
||||
try:
|
||||
return mtx.lines(files, key, given)
|
||||
except (cm.mf.FormulaError, ArithmeticError, KeyError, TypeError, ValueError) as e:
|
||||
return {"ok": False, "reason": str(e) or type(e).__name__}
|
||||
|
||||
|
||||
# ── 저장 ──────────────────────────────────────────────────────────────
|
||||
def _dec(v):
|
||||
"""화면이 보낸 수 → Decimal(파일을 읽은 모양과 같게)."""
|
||||
|
||||
Reference in New Issue
Block a user