增加一个应用公式代码:
def get_ytd_tax_exemption_amount_m1(work_type=0):
result = 0
employee_id = individual_dict['ref_employee_id']
current_taxagent = global_dict['F_ALLEmployeeCurrentTaxAgent'].get(employee_id, {})
current_tax_month = current_taxagent.get('current_tax_month', '')
current_withholding_agent = current_taxagent.get('current_withholding_agent', 0)
current_period = 0
if not current_tax_month:
return 0
current_agent_relationship = global_dict['F_ALLEmployeeCurrentAgentRelationship'].get((employee_id, current_withholding_agent), {})
hire_date = current_agent_relationship.get('hire_date') or individual_dict['ref_hire_date']
departure_time = current_agent_relationship.get('departure_time')
is_reduction = current_agent_relationship.get('is_reduction', False)
current_year = datetime.datetime.strptime(current_tax_month, "%Y-%m").year
current_month = datetime.datetime.strptime(current_tax_month, "%Y-%m").month
compare_date = 0
if current_agent_relationship and hire_date and departure_time and departure_time >= str(current_year) + '-01-01':
first_diff_date = min(current_tax_month, departure_time[:7])
first_diff_year = datetime.datetime.strptime(first_diff_date, "%Y-%m").year
first_diff_month = datetime.datetime.strptime(first_diff_date, "%Y-%m").month
second_diff_date = max(hire_date[:7], str(current_year) + '-01')
second_diff_year = datetime.datetime.strptime(second_diff_date, "%Y-%m").year
second_diff_month = datetime.datetime.strptime(second_diff_date, "%Y-%m").month
compare_date = abs((first_diff_year - second_diff_year) * 12 + (first_diff_month - second_diff_month)) + 1
if not departure_time and hire_date:
second_diff_date = max(hire_date[:7], str(current_year) + '-01')
second_diff_year = datetime.datetime.strptime(second_diff_date, "%Y-%m").year
second_diff_month = datetime.datetime.strptime(second_diff_date, "%Y-%m").month
compare_date = abs((current_year - second_diff_year) * 12 + (current_month - second_diff_month)) + 1
if work_type == 1 and current_agent_relationship and current_tax_month:
first_diff_date = current_tax_month
first_diff_month = datetime.datetime.strptime(first_diff_date, "%Y-%m").month
compare_date = first_diff_month
- 根据持续成功同事要求对再当前期间对应年分入职的员工compare_date-1
period_name = int(global_dict['ref_payroll_period_name'])
if datetime.datetime.strptime(hire_date,'%Y-%m-%d').year==period_name//100:
compare_date-=1
- ==============
result = compare_date * 5000
if is_reduction:
result = 60000
return result