支持供应商简称维护和订单PDF下载命名
This commit is contained in:
+6
-5
@@ -66,7 +66,7 @@ def read_rows(path):
|
||||
return out
|
||||
|
||||
|
||||
def read_table(path, keys, order):
|
||||
def read_table(path, keys, order, missing=""):
|
||||
"""通用表格读取:按关键词映射表头,返回按 order 排列的二维列表。
|
||||
|
||||
与 read_rows() 的区别是表头判定更宽松(命中任意关键词即可),
|
||||
@@ -110,7 +110,7 @@ def read_table(path, keys, order):
|
||||
vals = []
|
||||
for k in order:
|
||||
i = mapping.get(k)
|
||||
vals.append(row[i] if (i is not None and i < len(row)) else "")
|
||||
vals.append(row[i] if (i is not None and i < len(row)) else missing)
|
||||
out.append(vals)
|
||||
return out
|
||||
|
||||
@@ -124,6 +124,7 @@ MATERIAL_KEYS = {
|
||||
MATERIAL_ORDER = ["code", "spec", "unit", "price"]
|
||||
|
||||
SUPPLIER_KEYS = {
|
||||
"short_name": [u"简称", u"别名"],
|
||||
"code": [u"编号", u"供应商编号", u"代码"],
|
||||
"name": [u"名称", u"供应商名称", u"公司"],
|
||||
"contact": [u"联系人"],
|
||||
@@ -134,7 +135,7 @@ SUPPLIER_KEYS = {
|
||||
"bank_account": [u"银行帐号", u"银行账号", u"帐号", u"账号"],
|
||||
}
|
||||
SUPPLIER_ORDER = ["code", "name", "contact", "phone", "payment_terms",
|
||||
"tax_no", "bank_name", "bank_account"]
|
||||
"tax_no", "bank_name", "bank_account", "short_name"]
|
||||
|
||||
|
||||
def read_material_rows(path):
|
||||
@@ -143,5 +144,5 @@ def read_material_rows(path):
|
||||
|
||||
|
||||
def read_supplier_rows(path):
|
||||
"""读取供应商表,返回 [编号,名称,联系人,电话,付款方式,税号,开户银行,银行帐号]。"""
|
||||
return read_table(path, SUPPLIER_KEYS, SUPPLIER_ORDER)
|
||||
"""简称追加在末列;旧表缺少该列时以 None 表示,更新时保留已有简称。"""
|
||||
return read_table(path, SUPPLIER_KEYS, SUPPLIER_ORDER, missing=None)
|
||||
|
||||
Reference in New Issue
Block a user