def F_MealAllowance():
result = 0
departure_time = str(individual_dict['ref_departure_time'])
departure_time_ = datetime.datetime.strptime(
departure_time, '%Y-%m-%d') if departure_time else None
hire_date = str(individual_dict['ref_hire_date'])
hire_date_ = datetime.datetime.strptime(hire_date,
'%Y-%m-%d') if hire_date else None
date_end = global_dict['ref_date_end']
date_start = global_dict['ref_date_start']
current_perid_date_start = datetime.datetime.strptime(
date_start, '%Y-%m-%d')
current_perid_date_end = datetime.datetime.strptime(date_end, '%Y-%m-%d')
last_month_date_start = current_perid_date_start + relativedelta.relativedelta(
months=-1)
last_month = last_month_date_start.replace(day=28) + datetime.timedelta(
days=4)
last_month_date_end = last_month - datetime.timedelta(days=last_month.day)
if departure_time_:
# 4/1~4/30; 4/1~4/29号离职
if hire_date_<current_perid_date_start<=departure_time_<current_perid_date_end:
in_service_days = (departure_time_ - current_perid_date_start).days + 1
result = 3000 / 30 * in_service_days
# 4/1~4/30; 4/2~4/30号入职
elif current_perid_date_start<hire_date_<=current_perid_date_end<departure_time_:
in_service_days = (current_perid_date_end - hire_date_).days + 1
result = 3000 / 30 * in_service_days
# 4/1~4/30; 4/2入职,4/29离职
elif current_perid_date_start<hire_date_<departure_time_<current_perid_date_end:
in_service_days = (departure_time_ - hire_date_).days + 1
result = 3000 / 30 * in_service_days
else:
result = 3000
else:
if current_perid_date_start<hire_date_<=current_perid_date_end:
in_service_days = (current_perid_date_end - hire_date_).days + 1
result = 3000 / 30 * in_service_days
else:
result = 3000
return result