social_security_parameters = preFuncParameterDict.get('F_GetSocialSecurityFundRuleData', [])
value_dict = {}
if social_security_parameters:
for parameter in social_security_parameters:
parameters = eval(parameter['func_args'])
for par in parameters:
if isinstance(par, tuple):
par = list(par)
value_dict.setdefault(tuple([eval(i) for i in par]), None)
else:
value_dict.setdefault((eval(par),), None)
result = []
res = {}
pay_month = payslip_run_record.payroll_period.name
current_period = datetime.datetime.strptime(str(pay_month), '%Y%m')
for args in value_dict.keys():
if len(args) == 0:
continue
else:
rule_code = args[0] # 规则编码
rule_ = env['fund.rule'].search([('code', '=', rule_code),('active', '=', True)])
if rule_ and rule_.version_ids:
version_ids = sorted(rule_.version_ids, key=lambda r: r.effective_period, reverse=True)
for version in version_ids:
if current_period >= datetime.datetime.strptime(version.effective_period, '%Y-%m'):
if version.rule_ids:
for rule_id in version.rule_ids:
res[rule_id.insurance_code] = {
"max_base":rule_id.max_base,
"max_base_company": rule_id.max_base_company,
"min_base": rule_id.min_base,
"min_base_company": rule_id.min_base_company,
"personal_ratio": rule_id.personal_ratio,
"company_ratio": rule_id.company_ratio}
result.append(res)
break
else:
continue