forked from elmau/empresa-libre
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)
|
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):
|
class SATUsoCfdi(BaseModel):
|
||||||
key = TextField(index=True, unique=True)
|
key = TextField(index=True, unique=True)
|
||||||
name = TextField(default='', index=True)
|
name = TextField(default='', index=True)
|
||||||
|
@ -1563,17 +1579,18 @@ def _init_values():
|
||||||
{'key': 'version', 'value': VERSION},
|
{'key': 'version', 'value': VERSION},
|
||||||
{'key': 'rfc_publico', 'value': 'XAXX010101000'},
|
{'key': 'rfc_publico', 'value': 'XAXX010101000'},
|
||||||
{'key': 'rfc_extranjero', 'value': 'XEXX010101000'},
|
{'key': 'rfc_extranjero', 'value': 'XEXX010101000'},
|
||||||
|
{'key': 'decimales', 'value': '2'},
|
||||||
)
|
)
|
||||||
for row in data:
|
for row in data:
|
||||||
try:
|
try:
|
||||||
Configuration.create(**row)
|
Configuracion.create(**row)
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
pass
|
pass
|
||||||
log.info('Valores iniciales insertados...')
|
log.info('Valores iniciales insertados...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def _crear_tablas():
|
def _crear_tablas(rfc):
|
||||||
tablas = [Addendas, Categorias, Certificado, CondicionesPago, Configuracion,
|
tablas = [Addendas, Categorias, Certificado, CondicionesPago, Configuracion,
|
||||||
Emisor, Facturas, FacturasDetalle, FacturasImpuestos, Folios,
|
Emisor, Facturas, FacturasDetalle, FacturasImpuestos, Folios,
|
||||||
FacturasRelacionadas, Productos,
|
FacturasRelacionadas, Productos,
|
||||||
|
@ -1592,12 +1609,15 @@ def _crear_tablas():
|
||||||
contraseña = 'blades3.3'
|
contraseña = 'blades3.3'
|
||||||
obj = Usuarios.create(
|
obj = Usuarios.create(
|
||||||
usuario=usuario, contraseña=contraseña, es_superusuario=True)
|
usuario=usuario, contraseña=contraseña, es_superusuario=True)
|
||||||
|
log.info('SuperUsuario creado correctamente...')
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
msg = 'El usuario ya existe'
|
msg = 'El usuario ya existe'
|
||||||
log.error(msg)
|
log.error(msg)
|
||||||
return False
|
pass
|
||||||
|
|
||||||
|
_init_values()
|
||||||
|
_importar_valores('', rfc)
|
||||||
|
|
||||||
log.info('SuperUsuario creado correctamente...')
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1695,7 +1715,7 @@ def _iniciar_bd():
|
||||||
return
|
return
|
||||||
|
|
||||||
conectar(args)
|
conectar(args)
|
||||||
if _crear_tablas():
|
if _crear_tablas(rfc):
|
||||||
return
|
return
|
||||||
|
|
||||||
log.error('No se pudieron crear las tablas')
|
log.error('No se pudieron crear las tablas')
|
||||||
|
@ -1722,7 +1742,7 @@ def _agregar_rfc():
|
||||||
|
|
||||||
args = opt.copy()
|
args = opt.copy()
|
||||||
if conectar(args):
|
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...')
|
log.info('RFC agregado correctamente...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1738,26 +1758,28 @@ def _listar_rfc():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def _importar_valores(archivo):
|
def _importar_valores(archivo='', rfc=''):
|
||||||
rfc = input('Introduce el RFC: ').strip().upper()
|
|
||||||
if not rfc:
|
if not rfc:
|
||||||
msg = 'El RFC es requerido'
|
rfc = input('Introduce el RFC: ').strip().upper()
|
||||||
log.error(msg)
|
if not rfc:
|
||||||
return
|
msg = 'El RFC es requerido'
|
||||||
|
log.error(msg)
|
||||||
|
return
|
||||||
|
|
||||||
args = util.get_con(rfc)
|
args = util.get_con(rfc)
|
||||||
if not args:
|
if not args:
|
||||||
return
|
return
|
||||||
|
|
||||||
conectar(args)
|
conectar(args)
|
||||||
|
|
||||||
|
if not archivo:
|
||||||
|
archivo = 'valores_iniciales.json'
|
||||||
|
|
||||||
log.info('Importando datos...')
|
log.info('Importando datos...')
|
||||||
regimen = ''
|
regimen = ''
|
||||||
rows = util.loads(open(archivo, 'r').read())
|
rows = util.loads(open(archivo, 'r').read())
|
||||||
for row in rows:
|
for row in rows:
|
||||||
log.info('\tImportando tabla: {}'.format(row['tabla']))
|
log.info('\tImportando tabla: {}'.format(row['tabla']))
|
||||||
if row['tabla'] == 'Emisor' and 'regimen' in row:
|
|
||||||
regimen = row['regimen']
|
|
||||||
table = globals()[row['tabla']]
|
table = globals()[row['tabla']]
|
||||||
for r in row['datos']:
|
for r in row['datos']:
|
||||||
try:
|
try:
|
||||||
|
@ -1765,12 +1787,6 @@ def _importar_valores(archivo):
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
pass
|
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...')
|
log.info('Importación terminada...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,20 @@
|
||||||
{"key": "HUR", "name": "Hora", "activo": true},
|
{"key": "HUR", "name": "Hora", "activo": true},
|
||||||
{"key": "H87", "name": "Pieza", "activo": true},
|
{"key": "H87", "name": "Pieza", "activo": true},
|
||||||
{"key": "E48", "name": "Servicio", "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