# Generated by Django 5.0.6 on 2026-11-02 07:03

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('Company', '0001_initial'),
        ('Employee', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='TimesheetProject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('code', models.CharField(max_length=30)),
                ('title', models.CharField(max_length=250)),
                ('client_department', models.CharField(blank=True, max_length=200, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('status', models.CharField(choices=[('Planning', 'Planning'), ('Active', 'Active'), ('On Hold', 'On Hold'), ('Completed', 'Completed'), ('Cancelled', 'Cancelled')], db_index=True, default='Active', max_length=10)),
                ('budget_hours', models.DecimalField(blank=True, decimal_places=2, max_digits=9, null=True)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('is_billable', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_projects', to='Company.company_details')),
                ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='Employee.department')),
                ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_timesheet_projects', to='Employee.employeedt')),
            ],
            options={
                'ordering': ['code'],
                'unique_together': {('company', 'code')},
            },
        ),
        migrations.CreateModel(
            name='TimesheetSetting',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('standard_daily_hours', models.DecimalField(decimal_places=2, default=Decimal('8'), max_digits=4)),
                ('max_daily_hours', models.DecimalField(decimal_places=2, default=Decimal('24'), max_digits=4)),
                ('auto_overtime', models.BooleanField(default=True)),
                ('overtime_multiplier', models.DecimalField(decimal_places=2, default=Decimal('1.00'), max_digits=3)),
                ('week_start_day', models.PositiveSmallIntegerField(default=0)),
                ('backdate_limit_days', models.PositiveIntegerField(default=31)),
                ('enforce_allocation', models.BooleanField(default=True)),
                ('company', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_setting', to='Company.company_details')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='OvertimeClaim',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('month', models.PositiveSmallIntegerField()),
                ('year', models.PositiveSmallIntegerField()),
                ('approved_hours', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=6)),
                ('hourly_rate', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=8)),
                ('multiplier', models.DecimalField(decimal_places=2, default=Decimal('1.00'), max_digits=3)),
                ('calculated_pay', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
                ('approver_code', models.CharField(blank=True, db_index=True, max_length=100, null=True)),
                ('status', models.CharField(choices=[('Pending', 'Pending Approval'), ('Approved', 'Approved'), ('Rejected', 'Rejected'), ('Passed to Payroll', 'Passed to Payroll'), ('Cancelled', 'Cancelled')], db_index=True, default='Pending', max_length=17)),
                ('source', models.CharField(choices=[('Auto', 'Generated from approved timesheets'), ('Manual', 'Entered by HR'), ('Employee', 'Requested by employee')], default='Auto', max_length=8)),
                ('remarks', models.TextField(blank=True, null=True)),
                ('decided_by', models.CharField(blank=True, max_length=150, null=True)),
                ('decided_at', models.DateTimeField(blank=True, null=True)),
                ('decision_remarks', models.TextField(blank=True, null=True)),
                ('passed_to_payroll_at', models.DateTimeField(blank=True, null=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='overtime_claims', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='overtime_claims', to='Employee.employeedt')),
            ],
            options={
                'ordering': ['-year', '-month', 'employee__name'],
                'indexes': [models.Index(fields=['company', 'year', 'month'], name='Timesheet_o_company_9b4b66_idx'), models.Index(fields=['company', 'approver_code', 'status'], name='Timesheet_o_company_661aac_idx')],
            },
        ),
        migrations.CreateModel(
            name='TimesheetEntry',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('work_date', models.DateField(db_index=True)),
                ('week_start', models.DateField(db_index=True)),
                ('task_summary', models.CharField(max_length=500)),
                ('hours', models.DecimalField(decimal_places=2, max_digits=4)),
                ('overtime_hours', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=4)),
                ('ot_manual', models.BooleanField(default=False)),
                ('is_billable', models.BooleanField(default=True)),
                ('status', models.CharField(choices=[('Draft', 'Draft'), ('Submitted', 'Submitted'), ('Approved', 'Approved'), ('Rejected', 'Rejected')], db_index=True, default='Submitted', max_length=10)),
                ('submitted_at', models.DateTimeField(blank=True, null=True)),
                ('approver_code', models.CharField(blank=True, db_index=True, max_length=100, null=True)),
                ('decided_by', models.CharField(blank=True, max_length=150, null=True)),
                ('decided_at', models.DateTimeField(blank=True, null=True)),
                ('decision_remarks', models.TextField(blank=True, null=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_entries', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_entries', to='Employee.employeedt')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='entries', to='Timesheet.timesheetproject')),
            ],
            options={
                'ordering': ['-work_date', '-id'],
                'indexes': [models.Index(fields=['company', 'status'], name='Timesheet_t_company_49da54_idx'), models.Index(fields=['company', 'employee', 'work_date'], name='Timesheet_t_company_548933_idx'), models.Index(fields=['company', 'approver_code', 'status'], name='Timesheet_t_company_63de35_idx')],
            },
        ),
        migrations.CreateModel(
            name='ProjectAllocation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('role', models.CharField(blank=True, max_length=100, null=True)),
                ('allocation_percent', models.PositiveSmallIntegerField(default=100)),
                ('start_date', models.DateField(default=django.utils.timezone.localdate)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('is_billable', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_allocations', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='timesheet_allocations', to='Employee.employeedt')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='Timesheet.timesheetproject')),
            ],
            options={
                'ordering': ['project__code', 'employee__name'],
                'indexes': [models.Index(fields=['company', 'employee'], name='Timesheet_p_company_3143e2_idx')],
            },
        ),
    ]
