# Generated by Django 4.2.11 on 2026-05-21 08:46

from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('credit_scoring', '0001_initial'),
        ('documents', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='PurchaseOrder',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('po_number', models.CharField(max_length=100, unique=True)),
                ('supplier_name', models.CharField(max_length=200)),
                ('supplier_contact', models.CharField(max_length=200)),
                ('order_date', models.DateField()),
                ('delivery_date', models.DateField()),
                ('total_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('funded_amount', models.DecimalField(decimal_places=2, default=0, max_digits=15)),
                ('remaining_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('interest_rate', models.DecimalField(decimal_places=2, default=5.68, max_digits=5)),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('SUBMITTED', 'Submitted'), ('VERIFIED', 'PO Verified'), ('SUPPLIER_ORDERED', 'Supplies Ordered'), ('GOODS_RECEIVED', 'Goods Received'), ('INVOICE_SUBMITTED', 'Invoice Submitted'), ('FULLY_FUNDED', 'Fully Funded'), ('REPAID', 'Repaid'), ('DECLINED', 'Declined')], default='DRAFT', max_length=20)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('credit_application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchase_orders', to='credit_scoring.creditapplication')),
                ('invoice_document', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='po_invoices', to='documents.document')),
                ('po_document', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='po_documents', to='documents.document')),
            ],
            options={
                'db_table': 'purchase_orders',
                'ordering': ['-order_date'],
            },
        ),
        migrations.CreateModel(
            name='FundingDisbursement',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('disbursement_date', models.DateField(auto_now_add=True)),
                ('transaction_reference', models.CharField(max_length=100, unique=True)),
                ('paid_to_supplier', models.BooleanField(default=False)),
                ('supplier_payment_reference', models.CharField(blank=True, max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('purchase_order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='disbursements', to='purchase_order.purchaseorder')),
            ],
            options={
                'db_table': 'funding_disbursements',
            },
        ),
    ]
