from django.db import models

from Consultas.models import Banco


# Create your models here.
class Plantilla(models.Model):
    numero_especie_matricula=models.IntegerField(default=0)
    numero_especie_rtv = models.IntegerField(default=0)
    creacion=models.DateTimeField(auto_now_add=True,null=True)
    edicion=models.DateTimeField(auto_now=True,null=True)
    duplicado_sin_costo=models.CharField(max_length=60,null=True,blank=True)
    fecha=models.DateField(null=True,blank=True)
    tipo=models.CharField(max_length=60,null=True,blank=True)
    placa=models.CharField(max_length=60)
    servicio=models.DecimalField(max_digits=9,decimal_places=2,default=0)
    duplicado=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    rodaje=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    estiker=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    recargos=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    modificacion=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    tonelaje=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    cuv=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    dominio=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    bloqueo = models.DecimalField(max_digits=9, decimal_places=2, default=0)
    total=models.DecimalField(max_digits=9,decimal_places=2, default=0)
    publico=models.BooleanField(default=False)
    usuario=models.CharField(max_length=150,null=True,blank=True)
    ingresado_por=models.CharField(max_length=70, default='')
    modificado_por=models.CharField(max_length=70,null=True,blank=True)

    def save(
        self, force_insert=False, force_update=False, using=None, update_fields=None
    ):
        self.placa=str.upper(self.placa)

        super(Plantilla,self).save()


class Especies(models.Model):
    fecha_generacion=models.DateField()
    placa=models.CharField(max_length=10)
    tipo_vehiculo=models.CharField(max_length=20)
    tipo_tramite=models.CharField(max_length=20)
    numero_especie=models.CharField(default=0, max_length=13)
    usuario=models.CharField(max_length=20)
    motivo=models.TextField(default="Ninguna")

    def save(
        self, force_insert=False, force_update=False, using=None, update_fields=None
    ):
        self.placa=str.upper(self.placa)
        super(Especies,self).save()

class CambioServicio(models.Model):
    numero_tramite=models.CharField(max_length=30, null=True,blank=True)
    fecha_tramite=models.DateField()
    tipo_proceso=models.CharField(max_length=30, default="CAMBIO DE SERVICIO")
    centro_atencion=models.CharField(max_length=40, default="GAD MUNICIPAL DEL CANTÓN EL GUABO")
    cedula=models.CharField(max_length=13)
    propietario=models.CharField(max_length=60)
    numero_placa= models.CharField(max_length=10)
    banco=models.ForeignKey(Banco,on_delete=models.CASCADE,null=True,blank=True)
    numero_comprobante=models.CharField(max_length=30)
    fecha_pago=models.DateField()
    valor=models.DecimalField(max_digits=9, decimal_places=2)
    cambio=models.CharField(max_length=60,default="PRIVADO")
    estado=models.BooleanField(default=False)
