fix(corporate-bank-account-payment-order): 恢复制单表头富文本并标识行号
这个提交包含在:
@@ -31,6 +31,40 @@ EXPECTED_HEADERS = [
|
||||
"收款人手机号码",
|
||||
"短信通知附加信息",
|
||||
]
|
||||
REQUIRED_HEADER_COLUMNS = (0, 1, 2, 3, 4, 5, 9, 10)
|
||||
|
||||
|
||||
def font_signature(font: xlrd.formatting.Font) -> tuple:
|
||||
return (
|
||||
font.name,
|
||||
font.height,
|
||||
font.bold,
|
||||
font.italic,
|
||||
font.struck_out,
|
||||
font.outline,
|
||||
font.shadow,
|
||||
font.colour_index,
|
||||
font.weight,
|
||||
font.escapement,
|
||||
font.underline_type,
|
||||
font.family,
|
||||
font.character_set,
|
||||
)
|
||||
|
||||
|
||||
def rich_text_signature(book: xlrd.book.Book, sheet: xlrd.sheet.Sheet, row: int, column: int) -> list[tuple]:
|
||||
text = sheet.cell_value(row, column)
|
||||
runs = sheet.rich_text_runlist_map.get((row, column), [])
|
||||
if not runs:
|
||||
return []
|
||||
signature = []
|
||||
if runs[0][0] > 0:
|
||||
base_font_index = book.xf_list[sheet.cell_xf_index(row, column)].font_index
|
||||
signature.append((0, runs[0][0], text[:runs[0][0]], font_signature(book.font_list[base_font_index])))
|
||||
for index, (offset, font_index) in enumerate(runs):
|
||||
end = runs[index + 1][0] if index + 1 < len(runs) else len(text)
|
||||
signature.append((offset, end, text[offset:end], font_signature(book.font_list[font_index])))
|
||||
return signature
|
||||
|
||||
|
||||
def visual_signature(book: xlrd.book.Book, sheet: xlrd.sheet.Sheet, row: int, column: int) -> tuple:
|
||||
@@ -80,6 +114,21 @@ def main() -> int:
|
||||
sheet = generated.sheet_by_index(0)
|
||||
stage = "headers"
|
||||
assert sheet.row_values(0) == EXPECTED_HEADERS
|
||||
stage = "header_rich_text"
|
||||
assert set(sheet.rich_text_runlist_map) == set(source_sheet.rich_text_runlist_map)
|
||||
for row_column in source_sheet.rich_text_runlist_map:
|
||||
row, column = row_column
|
||||
assert rich_text_signature(generated, sheet, row, column) == rich_text_signature(
|
||||
template,
|
||||
source_sheet,
|
||||
row,
|
||||
column,
|
||||
)
|
||||
for column in REQUIRED_HEADER_COLUMNS:
|
||||
parts = rich_text_signature(generated, sheet, 0, column)
|
||||
assert parts[0][2] == "*" and parts[0][3][7] == 10
|
||||
assert "".join(part[2] for part in parts[1:]) == EXPECTED_HEADERS[column][1:]
|
||||
assert all(part[3][7] == 8 for part in parts[1:])
|
||||
stage = "column_widths"
|
||||
stage = "explicit_column_widths"
|
||||
assert {column: info.width for column, info in sheet.colinfo_map.items()} == {
|
||||
@@ -103,11 +152,21 @@ def main() -> int:
|
||||
for column in (7, 13, 14):
|
||||
stage = f"empty_cell_{column}"
|
||||
assert sheet.cell_type(row, column) in (xlrd.XL_CELL_EMPTY, xlrd.XL_CELL_BLANK)
|
||||
stage = "payer_account_value"
|
||||
assert sheet.cell_value(1, 1) == "6217000000000012345"
|
||||
stage = "bank_type_value"
|
||||
assert sheet.cell_value(1, 3) == "01"
|
||||
stage = "payee_account_value"
|
||||
assert sheet.cell_value(1, 4) == "6222000000000012345"
|
||||
stage = "first_customer_serial_value"
|
||||
assert sheet.cell_value(1, 8) == "PB-20260803-001-R001"
|
||||
stage = "last_customer_serial_value"
|
||||
assert sheet.cell_value(4, 8) == "PB-20260803-001-R004"
|
||||
stage = "payee_name_value"
|
||||
assert sheet.cell_value(1, 5) == "合成员工1"
|
||||
stage = "purpose_value"
|
||||
assert sheet.cell_value(1, 10) == "报销款"
|
||||
stage = "sms_flag_value"
|
||||
assert sheet.cell_value(1, 12) == "0"
|
||||
for row in range(1, 5):
|
||||
assert sheet.cell_type(row, 9) == xlrd.XL_CELL_NUMBER
|
||||
|
||||
在新工单中引用
屏蔽一个用户