from django.db import models
from datetime import date

class Actividad(models.Model):
    nombre = models.CharField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=200, blank=True)
    programa = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'wk_actividad'
    def __unicode__(self):
        return self.nombre 

class Conexion(models.Model):
    nombre = models.CharField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=200, blank=True)
    dns = models.CharField(max_length=200, blank=True)
    usuario  = models.CharField(max_length=200, blank=True)
    contrasena  = models.CharField(max_length=200, blank=True)
    puerto  = models.CharField(max_length=200, blank=True)
    sid  = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'wk_conexion'
    def __unicode__(self):
        return self.nombre 

class Modulo(models.Model):
    Wk_Conexion = models.ForeignKey(Conexion)
    nombre = models.CharField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=2000, blank=True)    
    class Meta:
        db_table = u'wk_modulo'
    def __unicode__(self):
        return self.nombre

class Transaccion(models.Model):
    nombre = models.CharField(max_length=200, blank=True) 
    descripcion = models.CharField(max_length=200, blank=True)
    id_tipo_comprobante = models.IntegerField(max_length=200, blank=True)
    class Meta:
        db_table = u'wk_transaccion'
    def __unicode__(self):
        return self.nombre

class Workflow(models.Model):
    batch = models.IntegerField(max_length=2, blank=True)
    nombre = models.CharField(max_length=200, blank=True) 
    descripcion = models.CharField(max_length=200, blank=True) 
    json = models.CharField(max_length=2000, blank=True) 
    class Meta:
        db_table = u'wk_workflow'
    def __unicode__(self):
        return self.nombre

class Workflow_Transaccion(models.Model):
    Workflow = models.ForeignKey(Workflow)
    Transaccion = models.ForeignKey(Transaccion)
    class Meta:
        db_table = u'wk_workflow_transaccion'


class Tabla(models.Model):
    nombre = models.CharField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=200, blank=True) 
    class Meta:
        db_table = u'wk_tabla'

    def __unicode__(self):
        return self.nombre

class Campo_Valor(models.Model):
    Tabla = models.ForeignKey(Tabla)
    nombre = models.CharField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'wk_campo'

    def __unicode__(self):
        return self.nombre

class Grupo(models.Model):
    tabla = models.CharField(max_length=200, blank=True)
    campo = models.CharField(max_length=200, blank=True) 
    class Meta:
        db_table = u'wk_grupo'

    def __unicode__(self):
        return self.tabla

class Campo_Cuenta(models.Model):
    Grupo = models.ForeignKey(Grupo)
    catalogo = models.CharField(max_length=200, blank=True)
    auxiliar = models.CharField(max_length=200, blank=True) 
    valor = models.CharField(max_length=2000, blank=True) 
    class Meta:
        db_table = u'wk_campo_cuenta'


class Concepto(models.Model):
    Transaccion = models.ForeignKey(Transaccion)
    Campo_Valor = models.ForeignKey(Campo_Valor,null='True',blank=True)
    Grupo = models.ForeignKey(Grupo,null='True',blank=True)
    nombre = models.CharField(max_length=200, blank=True)
    id_tipo_documento = models.IntegerField(max_length=200, blank=True)
    descripcion = models.CharField(max_length=200, blank=True)
    catalogo = models.CharField(max_length=200, blank=True)
    auxiliar = models.CharField(max_length=200, blank=True)
    naturaleza = models.CharField(max_length=200, blank=True)
    usa_grupo = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'wk_concepto'

    def __unicode__(self):
        return self.nombre