新增订单收票付款交货跟进并完善使用升级手册

增加部分付款和部分交货状态、工作台筛选、权限校验、跟进记录及 v4 数据迁移;补充 Windows EXE 构建与验收脚本。附 16 页 PDF 使用升级手册及企业微信详细配置说明、生成脚本和测试截图。验证:76 项回归测试、EXE 浏览器验收与 PDF 逐页校验通过。
This commit is contained in:
reddaniel110
2026-09-16 13:40:43 +08:00
parent bf952196fa
commit 768b4705dc
28 changed files with 3783 additions and 43 deletions
+48
View File
@@ -7,6 +7,54 @@ import pytest
SCHEMA = Path(__file__).parent / 'fixtures' / 'legacy_schema.sql'
def test_v3_tracking_upgrade_preserves_existing_state_and_archives(tmp_path):
import hashlib
from models import Order, OrderVersion, User, init_db
path = tmp_path / 'po.db'
engine, factory = init_db(str(path))
old_pdf = b'%PDF-1.4 immutable v3 archive'
digest = hashlib.sha256(old_pdf).hexdigest()
with factory() as db:
db.add(User(id=1, username='owner', name='Owner', role='admin', password_hash='hash',
session_version=7, must_change_password=False))
db.add(Order(id=1, order_no='V3-APPROVED', status='approved', revision=1, row_version=1))
db.add(Order(id=2, order_no='V3-PENDING', status='pending_approval', revision=1))
db.flush()
db.add(OrderVersion(order_id=1, revision=1, content_json='{}', pdf_data=old_pdf,
pdf_sha256=digest, template_version='po-v3'))
db.commit()
engine.dispose()
with sqlite3.connect(path) as con:
for field in ('needs_prepayment', 'invoice_status', 'delivery_status', 'payment_status',
'payment_date', 'fulfillment_note', 'payment_note', 'fulfillment_revision', 'payment_revision'):
con.execute('ALTER TABLE orders DROP COLUMN ' + field)
con.execute('PRAGMA user_version=3')
engine, factory = init_db(str(path))
with factory() as db:
row = db.get(Order, 1)
assert row.status == 'approved' and row.revision == row.row_version == 1
assert row.invoice_status == row.delivery_status == row.payment_status == 'unknown'
assert row.fulfillment_revision == row.payment_revision == -1
assert not row.fulfillment_stale and not row.payment_stale
pending_order = db.get(Order, 2)
assert pending_order.status == 'pending_approval' and pending_order.row_version == 1
assert db.get(User, 1).session_version == 7
archive = db.query(OrderVersion).one()
assert (archive.pdf_data, archive.pdf_sha256, archive.template_version) == (old_pdf, digest, 'po-v3')
engine.dispose()
backups = list(tmp_path.glob('*.bak'))
assert len(backups) == 1
with sqlite3.connect(backups[0]) as con:
assert con.execute('PRAGMA user_version').fetchone()[0] == 3
assert 'payment_status' not in {row[1] for row in con.execute('PRAGMA table_info(orders)')}
with sqlite3.connect(path) as con:
assert con.execute('PRAGMA user_version').fetchone()[0] == 4
assert con.execute('PRAGMA integrity_check').fetchone()[0] == 'ok'
engine, _ = init_db(str(path))
engine.dispose()
assert len(list(tmp_path.glob('*.bak'))) == 1
def legacy(path, duplicate=False):
with sqlite3.connect(path) as con:
con.executescript(SCHEMA.read_text(encoding='utf-8'))