hrm增加退休
This commit is contained in:
parent
34de8fdfec
commit
88db4fbcd4
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2023-03-02 09:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hrm', '0006_alter_employee_user'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='employee',
|
||||
name='job_state',
|
||||
field=models.IntegerField(choices=[(10, '在职'), (20, '离职'), (30, '退休')], default=10, verbose_name='在职状态'),
|
||||
),
|
||||
]
|
|
@ -10,9 +10,11 @@ class Employee(CommonBModel):
|
|||
"""
|
||||
JOB_ON = 10
|
||||
JOB_OFF = 20
|
||||
JOB_RETIRE = 30
|
||||
jobstate_choices = (
|
||||
(JOB_ON, '在职'),
|
||||
(JOB_OFF, '离职'),
|
||||
(JOB_RETIRE, '退休')
|
||||
)
|
||||
PEOPLE_TYPE_CHOICES = (
|
||||
('employee', '内部员工'),
|
||||
|
|
|
@ -79,7 +79,7 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer):
|
|||
elif instance.type in ['visitor', 'driver']: # 如果是访客或司机
|
||||
from apps.vm.services import sync_to_visitor
|
||||
sync_to_visitor(instance)
|
||||
if instance.job_state == 20 and instance.user: # 如果离职了关闭账户
|
||||
if instance.job_state in [20, 30] and instance.user: # 如果离职了关闭账户
|
||||
instance.user.is_active = False
|
||||
instance.user.save()
|
||||
# 同时去除门禁授权
|
||||
|
@ -92,10 +92,10 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer):
|
|||
if instance.third_info.get('dh_face_card', None) is None and instance.type == 'employee': # 如果是正式员工,给长时间期限
|
||||
start_time = now
|
||||
end_time = now + timedelta(days=7300)
|
||||
if instance.job_state == 20 and old_job_state == 10: # 离职
|
||||
if instance.job_state in [20, 30] and old_job_state == 10: # 离职或退休
|
||||
start_time = now
|
||||
end_time = now + timedelta(minutes=60)
|
||||
elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职
|
||||
elif instance.job_state == 10 and old_job_state in [20, 30] and instance.type == 'employee': # 正式员工重新在职
|
||||
start_time = now
|
||||
end_time = now + timedelta(days=7300)
|
||||
HrmService.sync_dahua_employee(ep=instance, old_photo=old_photo,
|
||||
|
|
Loading…
Reference in New Issue