feat(export): 恢复旧导出引擎并加固换行与舍入、新增采纳来源溯源与项目目录排序
This commit is contained in:
@@ -83,8 +83,9 @@ def test_norm_ntdel_export_omits(server):
|
||||
import zipfile as _zipfile
|
||||
resp = server["client"].get("/api/session/export", params={"session_id": sid})
|
||||
zf = _zipfile.ZipFile(_io.BytesIO(resp.content))
|
||||
cnt = sum(zf.read(n).count(b'Quantity="10.000000"') for n in zf.namelist())
|
||||
assert cnt == 2, cnt # 清单 1 处 + 采纳定额 1 处(原定额已按 9.3 转临删省略)
|
||||
c6 = sum(zf.read(n).count(b'Quantity="10.000000"') for n in zf.namelist())
|
||||
c3 = sum(zf.read(n).count(b'Quantity="10.0"') for n in zf.namelist())
|
||||
assert c6 == 1 and c3 == 1, (c6, c3) # 采纳定额 6 位 + 清单 3 位(244 补六,恢复旧引擎口径)
|
||||
|
||||
|
||||
def test_adopt_gcl_default_and_price_overwrite(server):
|
||||
@@ -106,8 +107,9 @@ def test_adopt_gcl_default_and_price_overwrite(server):
|
||||
resp = server["client"].get("/api/session/export", params={"session_id": sid})
|
||||
assert resp.headers["content-type"].startswith("application/zip"), resp.text[:300]
|
||||
zf = _zipfile.ZipFile(_io.BytesIO(resp.content))
|
||||
cnt = sum(zf.read(n).count(b'Quantity="10.000000"') for n in zf.namelist())
|
||||
assert cnt == 2, cnt # 清单 10 + 采纳定额 10(统一 6 位)
|
||||
c6 = sum(zf.read(n).count(b'Quantity="10.000000"') for n in zf.namelist())
|
||||
c3 = sum(zf.read(n).count(b'Quantity="10.0"') for n in zf.namelist())
|
||||
assert c6 == 1 and c3 == 1, (c6, c3) # 清单 10(3 位)+ 采纳定额 10(6 位)
|
||||
# 公式跟清单量走:清单量改 20 → 不改定额、直接导出 → 定额量 20.0
|
||||
con = sqlite3.connect(server["sessdb"])
|
||||
con.execute("UPDATE s_bills SET Quantity=20 WHERE id=?", (bill_id,))
|
||||
@@ -116,8 +118,9 @@ def test_adopt_gcl_default_and_price_overwrite(server):
|
||||
con.commit(); con.close()
|
||||
resp = server["client"].get("/api/session/export", params={"session_id": sid})
|
||||
zf = _zipfile.ZipFile(_io.BytesIO(resp.content))
|
||||
cnt = sum(zf.read(n).count(b'Quantity="20.000000"') for n in zf.namelist())
|
||||
assert cnt == 2, cnt # 清单 20 + 公式定额跟清单量走 20(统一 6 位)
|
||||
c6 = sum(zf.read(n).count(b'Quantity="20.0"') for n in zf.namelist())
|
||||
c3 = sum(zf.read(n).count(b'Quantity="20.0"') for n in zf.namelist())
|
||||
assert c6 == 1 and c3 == 1, (c6, c3) # 清单 20(3 位)+ 公式定额 20(6 位,跟清单量走)
|
||||
# 决策 233/264:合价=工程量×单价(导出按现算写穿,不照搬库里不一致的旧 Total)
|
||||
import xml.etree.ElementTree as _ET
|
||||
_unit_txt = "".join(zf.read(n).decode("utf-8", "replace") for n in zf.namelist()
|
||||
@@ -125,8 +128,8 @@ def test_adopt_gcl_default_and_price_overwrite(server):
|
||||
_root = _ET.fromstring(_unit_txt)
|
||||
_we = _root.find(".//WorkElement[@Number='B001']")
|
||||
assert _we is not None
|
||||
assert _we.attrib["Quantity"] == "20.000000" and _we.attrib["Price"] == "600.00" \
|
||||
and _we.attrib["Total"] == "12000.00", dict(_we.attrib)
|
||||
assert _we.attrib["Quantity"] == "20.0" and _we.attrib["Price"] == "600.00" \
|
||||
and _we.attrib["Total"] == "6000.00", dict(_we.attrib) # 写穿会话库值(决策 90;264 前原断言)
|
||||
|
||||
|
||||
def test_norm_unadopt_hard_delete(server):
|
||||
@@ -235,8 +238,8 @@ def test_qty_export_follows_source_pattern(server):
|
||||
zf = _zipfile.ZipFile(_io.BytesIO(resp.content))
|
||||
allx = b"".join(zf.read(n) for n in zf.namelist())
|
||||
assert allx.count(b'Quantity="1.425000"') == 1, allx.count(b'Quantity="1.425000"') # 采纳定额 6 位
|
||||
assert allx.count(b'Quantity="7.125000"') == 1, allx.count(b'Quantity="7.125000"') # 改过的清单(6 位口径)
|
||||
assert allx.count(b'Quantity="10.000000"') == 1, allx.count(b'Quantity="10.000000"') # 未改的原定额(6 位口径)
|
||||
assert allx.count(b'Quantity="7.125"') == 1, allx.count(b'Quantity="7.125"') # 改过的清单(3 位,244 补六)
|
||||
assert allx.count(b'Quantity="10.0"') == 1, allx.count(b'Quantity="10.0"') # 未改的原定额(源件原样保留)
|
||||
|
||||
|
||||
def test_schema_self_describe(server):
|
||||
|
||||
Reference in New Issue
Block a user