Agregar tabla SAT tipo de relaciones
This commit is contained in:
parent
08318165f7
commit
d074f5078d
|
@ -565,6 +565,22 @@ class SATImpuestos(BaseModel):
|
|||
return tuple(rows)
|
||||
|
||||
|
||||
class SATTipoRelacion(BaseModel):
|
||||
key = TextField(index=True, unique=True)
|
||||
name = TextField(default='', index=True)
|
||||
activo = BooleanField(default=False)
|
||||
default = BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
order_by = ('-default', 'name',)
|
||||
indexes = (
|
||||
(('key', 'name'), True),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return 'Tipo de relación: ({}) {}'.format(self.key, self.name)
|
||||
|
||||
|
||||
class SATUsoCfdi(BaseModel):
|
||||
key = TextField(index=True, unique=True)
|
||||
name = TextField(default='', index=True)
|
||||
|
@ -1563,17 +1579,18 @@ def _init_values():
|
|||
{'key': 'version', 'value': VERSION},
|
||||
{'key': 'rfc_publico', 'value': 'XAXX010101000'},
|
||||
{'key': 'rfc_extranjero', 'value': 'XEXX010101000'},
|
||||
{'key': 'decimales', 'value': '2'},
|
||||
)
|
||||
for row in data:
|
||||
try:
|
||||
Configuration.create(**row)
|
||||
Configuracion.create(**row)
|
||||
except IntegrityError:
|
||||
pass
|
||||
log.info('Valores iniciales insertados...')
|
||||
return
|
||||
|
||||
|
||||
def _crear_tablas():
|
||||
def _crear_tablas(rfc):
|
||||
tablas = [Addendas, Categorias, Certificado, CondicionesPago, Configuracion,
|
||||
Emisor, Facturas, FacturasDetalle, FacturasImpuestos, Folios,
|
||||
FacturasRelacionadas, Productos,
|
||||
|
@ -1592,12 +1609,15 @@ def _crear_tablas():
|
|||
contraseña = 'blades3.3'
|
||||
obj = Usuarios.create(
|
||||
usuario=usuario, contraseña=contraseña, es_superusuario=True)
|
||||
log.info('SuperUsuario creado correctamente...')
|
||||
except IntegrityError:
|
||||
msg = 'El usuario ya existe'
|
||||
log.error(msg)
|
||||
return False
|
||||
pass
|
||||
|
||||
_init_values()
|
||||
_importar_valores('', rfc)
|
||||
|
||||
log.info('SuperUsuario creado correctamente...')
|
||||
return True
|
||||
|
||||
|
||||
|
@ -1695,7 +1715,7 @@ def _iniciar_bd():
|
|||
return
|
||||
|
||||
conectar(args)
|
||||
if _crear_tablas():
|
||||
if _crear_tablas(rfc):
|
||||
return
|
||||
|
||||
log.error('No se pudieron crear las tablas')
|
||||
|
@ -1722,7 +1742,7 @@ def _agregar_rfc():
|
|||
|
||||
args = opt.copy()
|
||||
if conectar(args):
|
||||
if _add_emisor(rfc, util.dumps(opt)) and _crear_tablas():
|
||||
if _add_emisor(rfc, util.dumps(opt)) and _crear_tablas(rfc):
|
||||
log.info('RFC agregado correctamente...')
|
||||
return
|
||||
|
||||
|
@ -1738,26 +1758,28 @@ def _listar_rfc():
|
|||
return
|
||||
|
||||
|
||||
def _importar_valores(archivo):
|
||||
rfc = input('Introduce el RFC: ').strip().upper()
|
||||
def _importar_valores(archivo='', rfc=''):
|
||||
if not rfc:
|
||||
msg = 'El RFC es requerido'
|
||||
log.error(msg)
|
||||
return
|
||||
rfc = input('Introduce el RFC: ').strip().upper()
|
||||
if not rfc:
|
||||
msg = 'El RFC es requerido'
|
||||
log.error(msg)
|
||||
return
|
||||
|
||||
args = util.get_con(rfc)
|
||||
if not args:
|
||||
return
|
||||
args = util.get_con(rfc)
|
||||
if not args:
|
||||
return
|
||||
|
||||
conectar(args)
|
||||
conectar(args)
|
||||
|
||||
if not archivo:
|
||||
archivo = 'valores_iniciales.json'
|
||||
|
||||
log.info('Importando datos...')
|
||||
regimen = ''
|
||||
rows = util.loads(open(archivo, 'r').read())
|
||||
for row in rows:
|
||||
log.info('\tImportando tabla: {}'.format(row['tabla']))
|
||||
if row['tabla'] == 'Emisor' and 'regimen' in row:
|
||||
regimen = row['regimen']
|
||||
table = globals()[row['tabla']]
|
||||
for r in row['datos']:
|
||||
try:
|
||||
|
@ -1765,12 +1787,6 @@ def _importar_valores(archivo):
|
|||
except IntegrityError:
|
||||
pass
|
||||
|
||||
if regimen:
|
||||
emisor = Emisor.select()[0]
|
||||
regimen = SATRegimenes.get(SATRegimenes.key == regimen)
|
||||
emisor.regimenes.clear()
|
||||
emisor.regimenes.add(regimen)
|
||||
|
||||
log.info('Importación terminada...')
|
||||
return
|
||||
|
||||
|
|
|
@ -23,7 +23,20 @@
|
|||
{"key": "HUR", "name": "Hora", "activo": true},
|
||||
{"key": "H87", "name": "Pieza", "activo": true},
|
||||
{"key": "E48", "name": "Servicio", "activo": true},
|
||||
{"key": "E51", "name": "Trabajo", "activo": false}
|
||||
{"key": "E51", "name": "Trabajo", "activo": false},
|
||||
{"key": "ACT", "name": "Actividad", "activo": false}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tabla": "SATTipoRelacion",
|
||||
"datos": [
|
||||
{"key": "01", "name": "Nota de crédito de los documentos relacionados", "activo": true},
|
||||
{"key": "02", "name": "Nota de débito de los documentos relacionados", "activo": true},
|
||||
{"key": "03", "name": "Devolución de mercancía sobre facturas o traslados previos", "activo": true},
|
||||
{"key": "04", "name": "Sustitución de los CFDI previos", "activo": true, "default": true},
|
||||
{"key": "05", "name": "Traslados de mercancias facturados previamente", "activo": true},
|
||||
{"key": "06", "name": "Factura generada por los traslados previos", "activo": true},
|
||||
{"key": "07", "name": "Actividad", "CFDI por aplicación de anticipo": true}
|
||||
]
|
||||
},
|
||||
{
|
Loading…
Reference in New Issue