from django.db import models
from django.conf import settings
from credit_scoring.models import CreditApplication

class SectorApplication(models.Model):
    SECTOR_CHOICES = [
        ('MINING', 'Mining'),
        ('ENGINEERING', 'Engineering'),
        ('CONSTRUCTION', 'Construction & Maintenance'),
        ('TRANSPORT', 'Transport & Logistics'),
        ('MEDICAL', 'Medical Supplies'),
        ('GOVERNMENT', 'Government Services'),
        ('RENEWABLE_ENERGY', 'Renewable Energy'),
        ('LIQUOR', 'Liquor & Beverages'),
        ('MANUFACTURING', 'Manufacturing'),
        ('IT', 'IT Services'),
        ('LEGAL', 'Legal Services'),
        ('MARITIME', 'Maritime Industry'),
    ]
    
    credit_application = models.OneToOneField(
        CreditApplication, 
        on_delete=models.CASCADE, 
        related_name='sector_details'
    )
    sector = models.CharField(max_length=50, choices=SECTOR_CHOICES)
    monthly_turnover = models.DecimalField(max_digits=15, decimal_places=2)
    years_in_operation = models.IntegerField()
    employees_count = models.IntegerField()
    banking_details_verified = models.BooleanField(default=False)
    
    class Meta:
        db_table = 'sector_applications'
    
    def __str__(self):
        return f"{self.credit_application.application_number} - {self.get_sector_display()}"