# Generated by Django 6.0.4 on 2026-06-06 02:55

import apps.hr.models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AttendanceSettings',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('settings', models.JSONField(blank=True, default=dict)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': 'Attendance settings',
                'verbose_name_plural': 'Attendance settings',
                'db_table': 'hr_attendance_settings',
            },
        ),
        migrations.CreateModel(
            name='PayrollSettings',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('settings', models.JSONField(blank=True, default=dict)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': 'Payroll settings',
                'verbose_name_plural': 'Payroll settings',
                'db_table': 'hr_payroll_settings',
            },
        ),
        migrations.CreateModel(
            name='Communication',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('content', models.TextField()),
                ('communication_type', models.CharField(choices=[('announcement', 'Announcement'), ('memo', 'Memo'), ('meeting', 'Meeting'), ('policy', 'Policy')], max_length=20)),
                ('is_pinned', models.BooleanField(default=False)),
                ('attachments', models.JSONField(default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hr_communications', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'hr_communications',
                'ordering': ['-is_pinned', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Employee',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('employee_id', models.CharField(max_length=50, unique=True)),
                ('employment_type', models.CharField(choices=[('staff', 'Staff'), ('fellow', 'Fellow'), ('intern', 'Intern')], db_index=True, default='staff', max_length=20)),
                ('position', models.CharField(max_length=100)),
                ('department', models.CharField(max_length=100)),
                ('category', models.CharField(blank=True, help_text='Grade/rank code, e.g. III-C', max_length=20)),
                ('phone_extension', models.CharField(blank=True, help_text='Internal extension, e.g. 530', max_length=10)),
                ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('on_leave', 'On Leave'), ('terminated', 'Terminated')], default='active', max_length=20)),
                ('hire_date', models.DateField()),
                ('termination_date', models.DateField(blank=True, null=True)),
                ('salary', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('emergency_contact_name', models.CharField(blank=True, max_length=100)),
                ('emergency_contact_phone', models.CharField(blank=True, max_length=20)),
                ('address', models.TextField(blank=True)),
                ('notes', models.TextField(blank=True)),
                ('payroll_overrides', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='employee', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'hr_employees',
                'ordering': ['employee_id'],
            },
        ),
        migrations.CreateModel(
            name='Contract',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('contract_type', models.CharField(choices=[('full_time', 'Full Time'), ('part_time', 'Part Time'), ('contract', 'Contract'), ('internship', 'Internship')], max_length=20)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField(blank=True, null=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('expired', 'Expired'), ('terminated', 'Terminated'), ('renewed', 'Renewed')], default='active', max_length=20)),
                ('document', models.FileField(blank=True, null=True, upload_to='contracts/')),
                ('terms', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contracts', to='hr.employee')),
            ],
            options={
                'db_table': 'hr_contracts',
                'ordering': ['-start_date'],
            },
        ),
        migrations.CreateModel(
            name='Family',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=100)),
                ('relationship', models.CharField(choices=[('spouse', 'Spouse'), ('child', 'Child'), ('parent', 'Parent'), ('sibling', 'Sibling'), ('other', 'Other')], max_length=20)),
                ('date_of_birth', models.DateField(blank=True, null=True)),
                ('phone', models.CharField(blank=True, max_length=20)),
                ('email', models.EmailField(blank=True, max_length=254)),
                ('occupation', models.CharField(blank=True, max_length=100)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='family_members', to='hr.employee')),
            ],
            options={
                'db_table': 'hr_families',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Onboarding',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('stage', models.CharField(choices=[('pending', 'Pending'), ('in_progress', 'In Progress'), ('completed', 'Completed')], default='pending', max_length=20)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField(blank=True, null=True)),
                ('tasks', models.JSONField(default=list)),
                ('checklist', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('employee', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='onboarding', to='hr.employee')),
            ],
            options={
                'db_table': 'hr_onboardings',
            },
        ),
        migrations.CreateModel(
            name='Payroll',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('period_start', models.DateField()),
                ('period_end', models.DateField()),
                ('base_salary', models.DecimalField(decimal_places=2, max_digits=12)),
                ('allowances', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('deductions', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('net_salary', models.DecimalField(decimal_places=2, max_digits=12)),
                ('breakdown', models.JSONField(blank=True, default=dict)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('pending', 'Pending'), ('approved', 'Approved'), ('paid', 'Paid')], default='draft', max_length=20)),
                ('paid_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payrolls', to='hr.employee')),
            ],
            options={
                'db_table': 'hr_payrolls',
                'ordering': ['-period_start'],
            },
        ),
        migrations.CreateModel(
            name='Recruitment',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('position', models.CharField(max_length=200)),
                ('department', models.CharField(max_length=100)),
                ('employment_type', models.CharField(choices=[('full_time', 'Full Time'), ('part_time', 'Part Time'), ('contract', 'Contract'), ('internship', 'Internship')], default='full_time', max_length=20)),
                ('location', models.CharField(blank=True, max_length=150)),
                ('salary_range', models.CharField(blank=True, max_length=100)),
                ('deadline', models.DateField(blank=True, help_text='Application closing date', null=True)),
                ('description', models.TextField()),
                ('requirements', models.TextField()),
                ('status', models.CharField(choices=[('open', 'Open'), ('closed', 'Closed'), ('on_hold', 'On Hold')], default='open', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('hiring_manager', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='recruitments', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'hr_recruitments',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ShiftTemplate',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=100)),
                ('start_time', models.CharField(default='09:00', help_text='HH:MM', max_length=5)),
                ('end_time', models.CharField(default='18:00', help_text='HH:MM', max_length=5)),
                ('working_days', models.CharField(default='Mon-Fri', max_length=64)),
                ('flex_enabled', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('members', models.ManyToManyField(blank=True, related_name='shift_templates', to='hr.employee')),
            ],
            options={
                'verbose_name': 'Shift template',
                'verbose_name_plural': 'Shift templates',
                'db_table': 'hr_shift_templates',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Survey',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('description', models.TextField()),
                ('questions', models.JSONField(default=list)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('active', 'Active'), ('closed', 'Closed')], default='draft', max_length=20)),
                ('open_at', models.DateTimeField(blank=True, null=True)),
                ('close_at', models.DateTimeField(blank=True, null=True)),
                ('responses', models.JSONField(default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hr_surveys', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'hr_surveys',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Attendance',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('type', models.CharField(choices=[('check_in', 'Check In'), ('check_out', 'Check Out'), ('absent', 'Absent'), ('leave', 'Leave')], max_length=20)),
                ('date', models.DateField()),
                ('time', models.TimeField(blank=True, null=True)),
                ('location', models.CharField(blank=True, max_length=100)),
                ('photo', models.ImageField(blank=True, null=True, upload_to='attendance/%Y/%m/')),
                ('face_match_score', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attendance_records', to='hr.employee')),
            ],
            options={
                'db_table': 'hr_attendance',
                'ordering': ['-date', '-time'],
                'unique_together': {('employee', 'date', 'type')},
            },
        ),
        migrations.CreateModel(
            name='JobApplication',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('full_name', models.CharField(max_length=150)),
                ('email', models.EmailField(max_length=254)),
                ('phone', models.CharField(blank=True, max_length=30)),
                ('resume', models.FileField(blank=True, null=True, upload_to='applications/%Y/%m/')),
                ('writing_sample', models.FileField(blank=True, null=True, upload_to='applications/writing/%Y/%m/')),
                ('photo', models.ImageField(blank=True, null=True, upload_to='applications/photos/%Y/%m/')),
                ('cover_letter', models.TextField(blank=True)),
                ('stage', models.CharField(choices=[('applied', 'Applied'), ('screening', 'Screening'), ('interview', 'Interview'), ('offer', 'Offer'), ('hired', 'Hired'), ('rejected', 'Rejected')], db_index=True, default='applied', max_length=20)),
                ('notes', models.TextField(blank=True, help_text='Internal reviewer notes')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('converted_employee', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='source_application', to='hr.employee')),
                ('recruitment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='applications', to='hr.recruitment')),
            ],
            options={
                'db_table': 'hr_job_applications',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['recruitment', 'stage'], name='hr_job_appl_recruit_1ae4ea_idx')],
            },
        ),
        migrations.CreateModel(
            name='SurveyResponse',
            fields=[
                ('id', models.UUIDField(default=apps.hr.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('answers', models.JSONField(default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('respondent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='survey_responses', to=settings.AUTH_USER_MODEL)),
                ('survey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='response_set', to='hr.survey')),
            ],
            options={
                'db_table': 'hr_survey_responses',
                'ordering': ['-created_at'],
                'constraints': [models.UniqueConstraint(fields=('survey', 'respondent'), name='uniq_survey_respondent')],
            },
        ),
    ]
