# Generated by Django 5.2.19 on 2026-11-28 16:08

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('projects', '0001_initial'),
        ('tenancy', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Voucher',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('voucher_no', models.CharField(blank=True, db_index=True, max_length=40)),
                ('voucher_type', models.CharField(choices=[('JOURNAL', 'Journal Voucher'), ('PAYMENT', 'Payment Voucher'), ('RECEIPT', 'Receipt Voucher'), ('CONTRA', 'Contra Voucher'), ('PURCHASE', 'Purchase Voucher'), ('SALES', 'Sales Voucher'), ('CREDIT_NOTE', 'Credit Note'), ('DEBIT_NOTE', 'Debit Note')], max_length=16)),
                ('voucher_date', models.DateField(db_index=True)),
                ('bs_date', models.CharField(blank=True, max_length=16)),
                ('currency', models.CharField(default='NPR', max_length=3)),
                ('exchange_rate', models.DecimalField(decimal_places=6, default=Decimal('1.000000'), max_digits=14)),
                ('party_name', models.CharField(blank=True, max_length=200)),
                ('party_pan', models.CharField(blank=True, max_length=20)),
                ('reference_no', models.CharField(blank=True, max_length=64)),
                ('narration', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('SUBMITTED', 'Submitted'), ('APPROVED', 'Approved'), ('POSTED', 'Posted'), ('REJECTED', 'Rejected'), ('REVERSED', 'Reversed')], db_index=True, default='DRAFT', max_length=16)),
                ('version', models.PositiveIntegerField(default=1)),
                ('idempotency_key', models.CharField(blank=True, max_length=128, null=True)),
                ('posted_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['-voucher_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='VoucherLine',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('line_no', models.PositiveSmallIntegerField(default=1)),
                ('debit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('credit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('description', models.CharField(blank=True, max_length=255)),
            ],
            options={
                'ordering': ['line_no'],
            },
        ),
        migrations.CreateModel(
            name='VoucherSequence',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('voucher_type', models.CharField(max_length=16)),
                ('last_number', models.PositiveIntegerField(default=0)),
            ],
        ),
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(max_length=32)),
                ('name', models.CharField(max_length=200)),
                ('account_type', models.CharField(choices=[('ASSET', 'Asset'), ('LIABILITY', 'Liability'), ('EQUITY', 'Equity'), ('INCOME', 'Income'), ('EXPENSE', 'Expense')], max_length=16)),
                ('nfrs_mapping', models.CharField(blank=True, max_length=64)),
                ('is_group', models.BooleanField(default=False)),
                ('is_control_account', models.BooleanField(default=False)),
                ('opening_debit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('opening_credit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('is_active', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accounts', to='tenancy.company')),
                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='children', to='accounting.account')),
            ],
            options={
                'ordering': ['code'],
            },
        ),
        migrations.CreateModel(
            name='LedgerEntry',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('posting_date', models.DateField(db_index=True)),
                ('bs_date', models.CharField(blank=True, max_length=16)),
                ('transaction_currency', models.CharField(default='NPR', max_length=3)),
                ('exchange_rate', models.DecimalField(decimal_places=6, default=Decimal('1.000000'), max_digits=14)),
                ('debit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('credit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('base_debit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('base_credit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('narration', models.TextField(blank=True)),
                ('posted_at', models.DateTimeField(db_index=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='ledger_entries', to='accounting.account')),
                ('branch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='tenancy.branch')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='ledger_entries', to='tenancy.company')),
                ('cost_code', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='projects.costcode')),
                ('fiscal_period', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='tenancy.fiscalperiod')),
                ('fiscal_year', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='tenancy.fiscalyear')),
                ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='ledger_entries', to='projects.project')),
                ('site', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='projects.site')),
            ],
            options={
                'ordering': ['posting_date', 'posted_at', 'id'],
            },
        ),
    ]
