from django.db import models
from Models.Provincia import Provincia
from Models.Localidad import Localidad
from Models.Estado_Empresa import EstadoEmpresa
from Models.Usuario import Usuario
from Models.empresa_tipo import EmpresaTipo

class Empresa(models.Model):
    nombre = models.CharField(max_length=255)
    nombre_comercial = models.CharField(max_length=255, blank=True, null=True) # <-- nuevo campo
    cuit = models.CharField(max_length=20, blank=True, null=True)
    estado_empresa = models.ForeignKey('EstadoEmpresa', on_delete=models.CASCADE)
    fecha_creacion = models.DateTimeField(auto_now_add=True)
    deleted_at = models.DateTimeField(null=True, blank=True)
    provincia = models.ForeignKey(Provincia, on_delete=models.CASCADE, null=False, db_column='provincia_id')
    localidad = models.ForeignKey(Localidad, on_delete=models.CASCADE, null=False, db_column='localidad_id')
    direccion = models.CharField(max_length=255, blank=True, null=True)
    tipo_empresa = models.ForeignKey(EmpresaTipo, on_delete=models.SET_NULL, null=True, db_column='tipo_empresa_id')
    origen_id = models.IntegerField(null=False, blank=True)
    codigo_postal = models.CharField(max_length=10, blank=True, null=True)
    usuario_responsable = models.ForeignKey(Usuario, on_delete=models.SET_NULL, null=True, blank=True, db_column='usuario_responsable_id')
    class Meta:
        db_table = 'empresa'
    