补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
805 B
Python
33 lines
805 B
Python
"""证件与计划数量单位都按字典编码比较。历史证面可能直接存了中文标签。"""
|
|
|
|
_LABEL_TO_CODE = {
|
|
'千克': 'kg',
|
|
'吨': 'dun',
|
|
'升': 'sheng',
|
|
'瓶': 'ping',
|
|
'袋': 'dai',
|
|
'桶': 'tong',
|
|
'毫升': 'hs',
|
|
'套': 'set',
|
|
'个': 'piece',
|
|
'台': 'unit',
|
|
}
|
|
|
|
|
|
def canonical_quantity_unit(unit) -> str:
|
|
text = str(unit or '').strip()
|
|
return _LABEL_TO_CODE.get(text, text)
|
|
|
|
|
|
_CODE_TO_LABEL = {code: label for label, code in _LABEL_TO_CODE.items()}
|
|
|
|
|
|
def display_quantity_unit(unit) -> str:
|
|
text = str(unit or '').strip()
|
|
code = canonical_quantity_unit(text)
|
|
return _CODE_TO_LABEL.get(code, text or code)
|
|
|
|
|
|
def same_quantity_unit(left, right) -> bool:
|
|
return canonical_quantity_unit(left) == canonical_quantity_unit(right)
|