# Generated by Django 4.2.30 on 2026-11-17 08:08

from decimal import Decimal
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='AdminUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('phone', models.CharField(blank=True, max_length=15, null=True)),
                ('email', models.EmailField(max_length=254, unique=True)),
                ('designation', models.CharField(blank=True, max_length=100, null=True)),
                ('email_verified_at', models.DateTimeField(blank=True, null=True)),
                ('password', models.CharField(max_length=255)),
                ('role', models.CharField(default='admin', max_length=20)),
                ('password_reset_ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('remember_token', models.CharField(blank=True, max_length=100, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='AttendanceMaster',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_time', models.TimeField()),
                ('end_time', models.TimeField()),
                ('late_grace_minutes', models.PositiveIntegerField(default=0)),
                ('allowed_break_minutes', models.PositiveIntegerField(default=0)),
                ('working_days', models.JSONField(default=list)),
                ('permission_hours_per_month', models.PositiveIntegerField(default=0)),
                ('max_permissions_per_month', models.PositiveIntegerField(default=0)),
                ('permission_is_paid', models.BooleanField(default=False)),
                ('deduct_excess_permission', models.BooleanField(default=False)),
                ('salary_cycle_start_day', models.PositiveIntegerField(default=1)),
                ('salary_cycle_end_day', models.PositiveIntegerField(default=31)),
                ('salary_payment_day', models.PositiveIntegerField(blank=True, default=5, null=True)),
                ('km_allowance_enabled', models.BooleanField(default=False)),
                ('km_rate', models.DecimalField(blank=True, decimal_places=2, default=0.0, max_digits=6, null=True)),
                ('paid_leave_enabled', models.BooleanField(default=False)),
                ('paid_leave_days_per_month', models.PositiveIntegerField(default=0)),
                ('paid_leave_days_per_year', models.PositiveIntegerField(default=0)),
                ('is_active', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('customer_name', models.CharField(max_length=200)),
                ('phone_number', models.CharField(max_length=15)),
                ('address', models.CharField(max_length=200)),
                ('aadhaar_number', models.CharField(max_length=12, unique=True, validators=[django.core.validators.RegexValidator('^[0-9]{12}$', 'Aadhaar number must be exactly 12 digits.')])),
                ('aadhaar_photo', models.ImageField(blank=True, null=True, upload_to='aadhaar/')),
                ('referral_name', models.CharField(blank=True, max_length=150, null=True)),
                ('referral_phone', models.CharField(blank=True, max_length=15, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'customers',
                'ordering': ['-id'],
            },
        ),
        migrations.CreateModel(
            name='Loan',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('loan_date', models.DateField()),
                ('loan_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('payment_type', models.CharField(choices=[('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly')], max_length=20)),
                ('first_due_date', models.DateField()),
                ('number_of_dues', models.PositiveIntegerField()),
                ('due_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('total_payable', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14)),
                ('status', models.CharField(choices=[('active', 'Active'), ('completed', 'Completed')], db_index=True, default='active', max_length=20)),
                ('closed_date', models.DateField(blank=True, null=True)),
                ('notes', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='loans', to='NexusApp.customer')),
            ],
            options={
                'ordering': ['-id'],
            },
        ),
        migrations.CreateModel(
            name='LoanLead',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('lead_date', models.DateField(default=django.utils.timezone.localdate)),
                ('followup_date', models.DateField()),
                ('name', models.CharField(max_length=150)),
                ('place', models.CharField(blank=True, max_length=150, null=True)),
                ('phone', models.CharField(max_length=10)),
                ('loan_type', models.CharField(choices=[('personal', 'Personal Loan'), ('business', 'Business Loan'), ('mortgage', 'Mortgage Loan'), ('vehicle', 'Vehicle Loan')], max_length=20)),
                ('loan_amount', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('payment_type', models.CharField(blank=True, choices=[('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly')], max_length=20, null=True)),
                ('source', models.CharField(choices=[('reference', 'Reference'), ('social_media', 'Social Media'), ('direct', 'Direct Walk-in'), ('advertisement', 'Advertisement')], max_length=20)),
                ('source_details', models.CharField(blank=True, max_length=200, null=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('confirmed', 'Confirmed')], default='active', max_length=20)),
                ('staff_name', models.CharField(blank=True, max_length=150, null=True)),
                ('staff_id', models.CharField(blank=True, max_length=50, null=True)),
                ('agent_name', models.CharField(blank=True, max_length=150, null=True)),
                ('agent_mobile', models.CharField(blank=True, max_length=10, null=True)),
                ('purpose', models.TextField(blank=True, null=True)),
                ('remarks', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'loan_leads',
                'ordering': ['-id'],
            },
        ),
        migrations.CreateModel(
            name='Place',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=150, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'places',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Staff',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('phone', models.CharField(max_length=15)),
                ('gender', models.CharField(blank=True, max_length=20, null=True)),
                ('date_of_birth', models.DateField(blank=True, null=True)),
                ('address', models.TextField(blank=True, null=True)),
                ('employee_id', models.CharField(max_length=50, unique=True)),
                ('joining_date', models.DateField()),
                ('salary', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('email', models.CharField(max_length=150, unique=True)),
                ('password', models.CharField(max_length=255)),
                ('status', models.CharField(default='Active', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
        ),
        migrations.CreateModel(
            name='StaffCheckIn',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('check_in_date', models.DateField()),
                ('check_in_time', models.DateTimeField()),
                ('status', models.CharField(choices=[('on_time', 'On Time'), ('late', 'Late')], default='on_time', max_length=20)),
                ('late_reason', models.TextField(blank=True, help_text='Reason provided by staff for late check-in', null=True)),
                ('late_minutes', models.PositiveIntegerField(default=0)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='checkins', to='NexusApp.staff')),
            ],
            options={
                'db_table': 'staff_checkins',
                'ordering': ['-check_in_date', '-check_in_time'],
            },
        ),
        migrations.CreateModel(
            name='LoanPayment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('payment_date', models.DateField()),
                ('amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('payment_method', models.CharField(choices=[('cash', 'Cash'), ('upi', 'UPI')], default='cash', max_length=10)),
                ('payment_status', models.CharField(choices=[('completed', 'Completed'), ('pending', 'Pending')], default='completed', max_length=10)),
                ('notes', models.CharField(blank=True, max_length=255, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('collected_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='collections', to='NexusApp.staff')),
                ('loan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='NexusApp.loan')),
            ],
            options={
                'db_table': 'loan_payments',
                'ordering': ['-payment_date', '-id'],
            },
        ),
        migrations.AddField(
            model_name='loan',
            name='place',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='loans', to='NexusApp.place'),
        ),
        migrations.AddField(
            model_name='loan',
            name='staff',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='loans', to='NexusApp.staff'),
        ),
        migrations.AddConstraint(
            model_name='staffcheckin',
            constraint=models.UniqueConstraint(fields=('staff', 'check_in_date'), name='unique_staff_daily_checkin'),
        ),
        migrations.AddIndex(
            model_name='loanpayment',
            index=models.Index(fields=['loan', 'payment_date'], name='loan_paymen_loan_id_69ffd8_idx'),
        ),
    ]
