Files
shanxia2.0/backend/tests/test_crm_contract_attachment_clear.py
T
wuzilongandCursor bde19c0644 feat: 锁定执行中计划并按装卸明细差量归档库存,补齐派车日历数量与酸碱类型。
执行中的运输计划不再随意改单;库存流水记到装卸产品明细;手工派车日历区分酸碱并记录数量。同时收紧合同附件与子表的差量保存,并清理已废弃的 bak 备份目录。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-29 07:59:53 +08:00

37 lines
1.1 KiB
Python

"""合同附件:没传不动,显式空数组清空。"""
from decimal import Decimal
from types import SimpleNamespace
from app.crud.crm.contract import _apply_contract_entity_fields
_STORED = '[{"ossId":"/contract/a.pdf","category":"scan"}]'
def _entity():
return SimpleNamespace(
attachment_files=_STORED,
customer_id="",
contact_id=None,
owner_user_id=None,
status="executing",
tax_rate=None,
received_amount=Decimal("0"),
invoice_amount=Decimal("0"),
amount=Decimal("1"),
)
def test_omitted_attachment_files_are_left_unchanged():
entity = _entity()
_apply_contract_entity_fields(entity, {"remark": "只改备注"}, db=None, tenant_no="t", is_create=False)
assert entity.attachment_files == _STORED
def test_explicit_empty_attachment_values_clear_the_field():
for empty in ("[]", "", []):
entity = _entity()
_apply_contract_entity_fields(
entity, {"attachmentFiles": empty}, db=None, tenant_no="t", is_create=False
)
assert entity.attachment_files == "[]"