Merge pull request !10660 from 李鹏宇/dev
This commit is contained in:
@@ -491,16 +491,13 @@ class PropertyStatementsWizard(models.Model):
|
||||
lending_direction = 'borrow'
|
||||
amount_str = get_val(8).replace(',', '') # I列:发生额
|
||||
else:
|
||||
_logger.info('[xy_debug] 跳过:direction_val=%r 行首=%r', direction_val, get_val(0))
|
||||
return
|
||||
|
||||
try:
|
||||
original_amount = float(amount_str)
|
||||
except Exception:
|
||||
_logger.info('[xy_debug] 金额转换失败:amount_str=%r', amount_str)
|
||||
return
|
||||
if not original_amount:
|
||||
_logger.info('[xy_debug] 金额为0跳过')
|
||||
return
|
||||
|
||||
name = get_val(9) # 对方账号
|
||||
@@ -513,7 +510,6 @@ class PropertyStatementsWizard(models.Model):
|
||||
your_own_unit = self.classify_by_last_four(your_own_account)
|
||||
company_id = self._get_company_by_unit(your_own_unit)
|
||||
if not company_id:
|
||||
_logger.info('[xy_debug] 公司匹配失败:your_own_account=%r your_own_unit=%r', your_own_account, your_own_unit)
|
||||
return
|
||||
|
||||
dedup_key = serial_number if serial_number and serial_number != '0' else (time_val + name)
|
||||
@@ -540,29 +536,12 @@ class PropertyStatementsWizard(models.Model):
|
||||
existing_record.write(bank_data)
|
||||
|
||||
def _get_company_by_unit(self, unit_name):
|
||||
"""根据简称匹配 yuthon.property.company 配置,再匹配 res.company"""
|
||||
if not unit_name:
|
||||
return False
|
||||
# 先从物业公司配置表找到全称
|
||||
company_config = self.env['yuthon.property.company'].sudo().search(
|
||||
[('referred', '=', unit_name)], limit=1
|
||||
)
|
||||
if company_config:
|
||||
# 用全称匹配 res.company
|
||||
company = self.env['res.company'].sudo().search(
|
||||
[('name', '=', company_config.name)], limit=1
|
||||
)
|
||||
if company:
|
||||
return company
|
||||
# 兑容旧逻辑
|
||||
if unit_name in ['天河投资', '天投城建', '兴源公司', '车陂民政', '中城公司']:
|
||||
return self.env['res.company'].sudo().search([('name', '=', '集团本部')], limit=1)
|
||||
elif unit_name == '天河物管':
|
||||
if unit_name == '天河物管':
|
||||
return self.env['res.company'].sudo().search([('name', '=', '天河物管')], limit=1)
|
||||
elif unit_name == '天河粮储':
|
||||
return self.env['res.company'].sudo().search([('name', '=', '天河粮储')], limit=1)
|
||||
_logger.warning('[银行流水导入] 未能匹配公司: unit_name=%s', unit_name)
|
||||
return False
|
||||
else:
|
||||
return self.env['res.company'].sudo().search([('name', '=', '集团本部')], limit=1)
|
||||
|
||||
def classify_by_last_four(self, input_str):
|
||||
if not isinstance(input_str, str) or not input_str.strip():
|
||||
|
||||
Reference in New Issue
Block a user