# Generated by Django 5.0.2 on 2025-07-23 18:46

import django.db.models.deletion
import django.utils.timezone
import uuid
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Department',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('description', models.TextField(blank=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_departments', to=settings.AUTH_USER_MODEL)),
                ('user_group', models.OneToOneField(blank=True, help_text='User group with specific permissions for this department', null=True, on_delete=django.db.models.deletion.SET_NULL, to='auth.group')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Employee',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('employee_id', models.CharField(editable=False, max_length=20, unique=True)),
                ('first_name', models.CharField(max_length=50)),
                ('last_name', models.CharField(max_length=50)),
                ('email', models.EmailField(max_length=254, unique=True)),
                ('phone', models.CharField(max_length=15)),
                ('id_number', models.CharField(help_text='National ID or Passport', max_length=50, unique=True)),
                ('kra_pin', models.CharField(blank=True, max_length=20, null=True)),
                ('nssf_number', models.CharField(blank=True, max_length=20, null=True)),
                ('nhif_number', models.CharField(blank=True, max_length=20, null=True)),
                ('physical_address', models.TextField()),
                ('postal_address', models.CharField(blank=True, max_length=200)),
                ('job_title', models.CharField(max_length=100)),
                ('employment_type', models.CharField(choices=[('full_time', 'Full Time'), ('part_time', 'Part Time'), ('contract', 'Contract'), ('intern', 'Intern')], default='full_time', max_length=20)),
                ('employment_status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('terminated', 'Terminated'), ('resigned', 'Resigned'), ('on_leave', 'On Leave')], default='active', max_length=20)),
                ('hire_date', models.DateField()),
                ('probation_end_date', models.DateField(blank=True, null=True)),
                ('termination_date', models.DateField(blank=True, null=True)),
                ('basic_salary', models.DecimalField(decimal_places=2, help_text='Monthly basic salary', max_digits=12)),
                ('emergency_contact_name', models.CharField(max_length=100)),
                ('emergency_contact_phone', models.CharField(max_length=15)),
                ('emergency_contact_relationship', models.CharField(max_length=50)),
                ('bank_name', models.CharField(blank=True, max_length=100)),
                ('bank_account_number', models.CharField(blank=True, max_length=50)),
                ('bank_branch', models.CharField(blank=True, max_length=100)),
                ('profile_picture', models.ImageField(blank=True, null=True, upload_to='employee_photos/')),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('department', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='employees', to='hr.department')),
                ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='employee_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['employee_id'],
            },
        ),
        migrations.CreateModel(
            name='Deduction',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('deduction_type', models.CharField(choices=[('tax', 'Tax'), ('insurance', 'Insurance'), ('loan', 'Loan Repayment'), ('advance', 'Salary Advance'), ('disciplinary', 'Disciplinary'), ('other', 'Other')], max_length=20)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10)),
                ('reason', models.TextField()),
                ('is_recurring', models.BooleanField(default=False, help_text='If true, this deduction applies every month')),
                ('is_active', models.BooleanField(default=True)),
                ('start_date', models.DateField(default=django.utils.timezone.now)),
                ('end_date', models.DateField(blank=True, help_text='Leave blank for ongoing deductions', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(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='deductions', to='hr.employee')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Bonus',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('bonus_type', models.CharField(choices=[('performance', 'Performance Bonus'), ('commission', 'Commission'), ('overtime', 'Overtime Pay'), ('holiday', 'Holiday Bonus'), ('achievement', 'Achievement Bonus'), ('other', 'Other')], max_length=20)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10)),
                ('reason', models.TextField()),
                ('is_recurring', models.BooleanField(default=False, help_text='If true, this bonus applies every month')),
                ('is_active', models.BooleanField(default=True)),
                ('date_earned', models.DateField(default=django.utils.timezone.now)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(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='bonuses', to='hr.employee')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='EmployeeInvitation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.UUIDField(default=uuid.uuid4, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('expires_at', models.DateTimeField()),
                ('is_used', models.BooleanField(default=False)),
                ('used_at', models.DateTimeField(blank=True, null=True)),
                ('employee', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='invitation', to='hr.employee')),
            ],
        ),
        migrations.CreateModel(
            name='Payslip',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('payslip_number', models.CharField(editable=False, max_length=50, unique=True)),
                ('pay_period_start', models.DateField()),
                ('pay_period_end', models.DateField()),
                ('pay_date', models.DateField()),
                ('basic_salary', models.DecimalField(decimal_places=2, max_digits=12)),
                ('total_deductions', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('total_bonuses', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('gross_salary', models.DecimalField(decimal_places=2, max_digits=12)),
                ('net_salary', models.DecimalField(decimal_places=2, max_digits=12)),
                ('paye_tax', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('nhif_deduction', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('nssf_deduction', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('is_generated', models.BooleanField(default=False)),
                ('is_paid', models.BooleanField(default=False)),
                ('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='payslips', to='hr.employee')),
                ('generated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-pay_period_start'],
                'unique_together': {('employee', 'pay_period_start', 'pay_period_end')},
            },
        ),
    ]
