# Generated by Django 5.2.19 on 2026-12-01 02:11

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


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0010_voucherregisterviewconfig_and_more'),
        ('banking', '0001_initial'),
        ('projects', '0002_dailysitereport_projectactivity_projectadvance_and_more'),
        ('tenancy', '0003_taxconfig_calculation_rule_taxconfig_category_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterUniqueTogether(
            name='bankaccount',
            unique_together={('company', 'account_number_hash')},
        ),
        migrations.AlterUniqueTogether(
            name='chequeleaf',
            unique_together={('bank_account', 'cheque_number', 'direction')},
        ),
        migrations.AddField(
            model_name='bank',
            name='bank_category',
            field=models.CharField(choices=[('CLASS_A_COMMERCIAL', 'Class A — Commercial Bank'), ('CLASS_B_DEVELOPMENT', 'Class B — Development Bank'), ('CLASS_C_FINANCE', 'Class C — Finance Company'), ('CLASS_D_MICROFINANCE', 'Class D — Microfinance'), ('FOREIGN', 'Permitted Foreign Bank'), ('OTHER', 'Other Financial Institution')], default='CLASS_A_COMMERCIAL', max_length=24),
        ),
        migrations.AddField(
            model_name='bank',
            name='nrb_directory_version',
            field=models.CharField(blank=True, max_length=40),
        ),
        migrations.AddField(
            model_name='bank',
            name='nrb_institution_code',
            field=models.CharField(blank=True, max_length=24),
        ),
        migrations.AddField(
            model_name='bank',
            name='nrb_source_date',
            field=models.CharField(blank=True, max_length=24),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='account_code',
            field=models.CharField(blank=True, max_length=32),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='account_open_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='bank_charge_ledger',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='charge_bank_accounts', to='accounting.account'),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='cheque_facility_enabled',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='interest_income_ledger',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='interest_bank_accounts', to='accounting.account'),
        ),
        migrations.AddField(
            model_name='bankaccount',
            name='online_banking_ref',
            field=models.CharField(blank=True, max_length=120),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='deposits_in_transit',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='other_reconciling_items',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='outstanding_cheques',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='reopen_reason',
            field=models.CharField(blank=True, max_length=255),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='reopened_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='bankreconciliationsession',
            name='reopened_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='bankstatementimport',
            name='statement_period_end',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='bankstatementimport',
            name='statement_period_start',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='bankstatementline',
            name='match_confidence',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5),
        ),
        migrations.AddField(
            model_name='bankstatementline',
            name='match_reason',
            field=models.CharField(blank=True, max_length=160),
        ),
        migrations.AddField(
            model_name='bankstatementline',
            name='supporting_doc_ref',
            field=models.CharField(blank=True, max_length=255),
        ),
        migrations.AddField(
            model_name='cashaccount',
            name='is_frozen',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='cashaccount',
            name='max_holding_limit',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18),
        ),
        migrations.AddField(
            model_name='cashcountreconciliation',
            name='attachment_ref',
            field=models.CharField(blank=True, max_length=255),
        ),
        migrations.AddField(
            model_name='cashcountreconciliation',
            name='denominations',
            field=models.JSONField(blank=True, default=dict),
        ),
        migrations.AddField(
            model_name='cashcountreconciliation',
            name='is_surprise_check',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='cashtransfer',
            name='fee_amount',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18),
        ),
        migrations.AddField(
            model_name='cashtransfer',
            name='transfer_ref',
            field=models.CharField(blank=True, db_index=True, max_length=64),
        ),
        migrations.AddField(
            model_name='chequebook',
            name='assigned_to',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='chequebook',
            name='low_stock_threshold',
            field=models.PositiveSmallIntegerField(default=5),
        ),
        migrations.AddField(
            model_name='chequebook',
            name='status',
            field=models.CharField(choices=[('ACTIVE', 'Active'), ('EXHAUSTED', 'Exhausted'), ('CANCELLED', 'Cancelled')], default='ACTIVE', max_length=16),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='bank_reconciled',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='bounce_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='clearing_voucher',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cheque_clearings', to='accounting.voucher'),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='currency',
            field=models.CharField(default='NPR', max_length=3),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='deposit_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='drawer_account_ref',
            field=models.CharField(blank=True, max_length=64),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='drawer_bank',
            field=models.CharField(blank=True, max_length=150),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='drawer_name',
            field=models.CharField(blank=True, max_length=200),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='expected_presentation_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='image_ref',
            field=models.CharField(blank=True, max_length=255),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='party',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='accounting.party'),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='project',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='projects.project'),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='purpose',
            field=models.CharField(blank=True, max_length=200),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='receiving_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='chequeleaf',
            name='signing_authority',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='signed_cheques', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='bankaccount',
            name='status',
            field=models.CharField(choices=[('ACTIVE', 'Active'), ('FROZEN', 'Frozen'), ('CLOSED', 'Closed')], default='ACTIVE', max_length=12),
        ),
        migrations.AlterField(
            model_name='bankreconciliationsession',
            name='status',
            field=models.CharField(choices=[('DRAFT', 'In Progress'), ('APPROVED', 'Approved & Locked'), ('REOPENED', 'Reopened for Review')], default='DRAFT', max_length=16),
        ),
        migrations.AlterField(
            model_name='bankstatementline',
            name='match_status',
            field=models.CharField(choices=[('UNMATCHED', 'Unmatched Bank'), ('MATCHED', 'Matched'), ('PARTIAL', 'Partially Matched'), ('PENDING_CHEQUE', 'Pending Cheque'), ('DEPOSIT_IN_TRANSIT', 'Deposit in Transit'), ('BANK_CHARGE', 'Bank Charges'), ('BANK_INTEREST', 'Bank Interest'), ('DUPLICATE', 'Duplicate'), ('UNDER_REVIEW', 'Under Review'), ('FINALIZED', 'Finalized'), ('EXCLUDED', 'Excluded')], db_index=True, default='UNMATCHED', max_length=24),
        ),
        migrations.AlterField(
            model_name='cashaccount',
            name='cash_type',
            field=models.CharField(choices=[('HEAD_OFFICE', 'Head Office Cash'), ('ADMINISTRATIVE', 'Administrative Cash'), ('BRANCH', 'Branch Cash'), ('SITE', 'Project Site Cash'), ('PETTY', 'Petty Cash'), ('EMPLOYEE_CUSTODY', 'Employee Cash Custody'), ('EMERGENCY', 'Emergency Cash'), ('IMPREST', 'Imprest Cash'), ('FOREIGN_CURRENCY', 'Foreign Currency Cash')], default='HEAD_OFFICE', max_length=20),
        ),
        migrations.AlterField(
            model_name='chequeleaf',
            name='status',
            field=models.CharField(choices=[('AVAILABLE', 'Available'), ('PREPARED', 'Prepared'), ('APPROVED', 'Approved'), ('ISSUED', 'Issued'), ('PRESENTED', 'Presented at Bank'), ('RECEIVED', 'Received'), ('VERIFIED', 'Verified'), ('DEPOSITED', 'Deposited'), ('UNDER_CLEARING', 'Under Clearing'), ('IN_HAND', 'Cheque in Hand'), ('CLEARED', 'Cleared'), ('BOUNCED', 'Bounced'), ('CANCELLED', 'Cancelled'), ('LOST_DAMAGED', 'Lost / Damaged'), ('STALE', 'Stale / Expired')], db_index=True, default='AVAILABLE', max_length=20),
        ),
        migrations.CreateModel(
            name='BankAccountDocument',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('doc_category', models.CharField(default='OPENING_FORM', max_length=32)),
                ('title', models.CharField(max_length=200)),
                ('document_ref', models.CharField(blank=True, max_length=120)),
                ('file_name', models.CharField(blank=True, max_length=255)),
                ('uploaded_at', models.DateTimeField(auto_now_add=True)),
                ('bank_account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='banking.bankaccount')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tenancy.company')),
                ('uploaded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='BankAccountSignatory',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('full_name', models.CharField(max_length=150)),
                ('designation', models.CharField(blank=True, max_length=100)),
                ('signing_limit_npr', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('joint_signature_required', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('bank_account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='signatories', to='banking.bankaccount')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tenancy.company')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['full_name'],
            },
        ),
        migrations.CreateModel(
            name='BankStatementTemplate',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('template_name', models.CharField(max_length=120)),
                ('file_format', models.CharField(default='CSV', max_length=16)),
                ('date_format', models.CharField(default='%Y-%m-%d', max_length=32)),
                ('column_mapping', models.JSONField(blank=True, default=dict)),
                ('is_active', models.BooleanField(default=True)),
                ('bank', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='banking.bank')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='statement_templates', to='tenancy.company')),
            ],
        ),
        migrations.CreateModel(
            name='CashCustodyHandover',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('handover_date', models.DateField()),
                ('physical_amount', models.DecimalField(decimal_places=2, max_digits=18)),
                ('denominations', models.JSONField(blank=True, default=dict)),
                ('certificate_no', models.CharField(blank=True, max_length=48)),
                ('notes', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('PENDING_ACCEPTANCE', 'Pending Receiver Confirmation'), ('COMPLETED', 'Handover Completed'), ('REJECTED', 'Disputed / Rejected')], default='PENDING_ACCEPTANCE', max_length=24)),
                ('confirmed_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('cash_account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='handovers', to='banking.cashaccount')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tenancy.company')),
                ('confirmed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('from_custodian', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cash_handovers_out', to=settings.AUTH_USER_MODEL)),
                ('to_custodian', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cash_handovers_in', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ImprestAdvance',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('imprest_no', models.CharField(max_length=40)),
                ('purpose', models.CharField(blank=True, max_length=255)),
                ('request_date', models.DateField()),
                ('due_date', models.DateField(blank=True, null=True)),
                ('approved_limit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('issued_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('settled_expense_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('returned_cash_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('status', models.CharField(choices=[('REQUESTED', 'Requested'), ('MANAGER_APPROVED', 'Manager Approved'), ('FINANCE_APPROVED', 'Finance Authorized'), ('ISSUED', 'Issued to Custodian'), ('PARTIALLY_SETTLED', 'Partially Settled'), ('SETTLED', 'Fully Settled'), ('REJECTED', 'Rejected')], db_index=True, default='REQUESTED', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('cash_account', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='imprests', to='banking.cashaccount')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='imprest_advances', to='tenancy.company')),
                ('custodian', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='imprest_custodies', to=settings.AUTH_USER_MODEL)),
                ('finance_approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('funding_gl_account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='imprest_funding_sources', to='accounting.account')),
                ('imprest_gl_account', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='imprest_receivables', to='accounting.account')),
                ('issue_voucher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='imprest_issues', to='accounting.voucher')),
                ('manager_approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='projects.project')),
                ('site', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='projects.site')),
            ],
            options={
                'ordering': ['-request_date', '-created_at'],
                'unique_together': {('company', 'imprest_no')},
            },
        ),
        migrations.CreateModel(
            name='ImprestSettlement',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('settlement_date', models.DateField()),
                ('expense_lines', models.JSONField(blank=True, default=list)),
                ('verified_expense_total', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('unused_cash_returned', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('replenish_requested', models.BooleanField(default=False)),
                ('replenished_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('status', models.CharField(choices=[('SUBMITTED', 'Submitted Bills'), ('APPROVED', 'Verified & Settled'), ('REJECTED', 'Rejected')], default='SUBMITTED', max_length=16)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tenancy.company')),
                ('imprest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='settlements', to='banking.imprestadvance')),
                ('replenishment_voucher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='imprest_replenishment_vouchers', to='accounting.voucher')),
                ('return_to_gl_account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='accounting.account')),
                ('return_voucher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='imprest_return_vouchers', to='accounting.voucher')),
                ('settlement_voucher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='imprest_settlement_vouchers', to='accounting.voucher')),
                ('submitted_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-settlement_date', '-created_at'],
            },
        ),
    ]
