diff --git a/.gitignore b/.gitignore index a434b5a..3f3eb5e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,4 @@ credenciales.conf *.sqlite *.sql rfc.db -configpac.py - diff --git a/source/app/conf.py.example b/source/app/conf.py.example index 70d42ef..2cdf172 100644 --- a/source/app/conf.py.example +++ b/source/app/conf.py.example @@ -2,3 +2,6 @@ DEBUG = True + +#~ Establece una ruta accesible para el servidor web +LOG_PATH = '/srv/empresa/logs/empresalibre.log' diff --git a/source/app/controllers/conf.py.example b/source/app/controllers/conf.py.example new file mode 100644 index 0000000..d400ea7 --- /dev/null +++ b/source/app/controllers/conf.py.example @@ -0,0 +1,13 @@ +#!/usr/bin/env python + + +DEBUG = True + +#~ Ecodex +ID_INTEGRADOR = '' + +#~ Finkok +FINKOK= { + 'USER': '', + 'PASS': '', +} diff --git a/source/app/controllers/configpac.py b/source/app/controllers/configpac.py new file mode 100644 index 0000000..513832f --- /dev/null +++ b/source/app/controllers/configpac.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python + + +from conf import DEBUG, ID_INTEGRADOR, FINKOK + +DEBUG = DEBUG +TIMEOUT = 10 + +#~ PACs que han proporcionado un entorno de pruebas libre y abierto +#~ ecodex, finkok +PAC = 'finkok' + + +def ecodex(debug): + NEW_SERVER = True + auth = {'ID': ID_INTEGRADOR} + if debug: + #~ No cambies este ID de pruebas + auth = {'ID': '2b3a8764-d586-4543-9b7e-82834443f219'} + + base_url = 'https://servicios.ecodex.com.mx:4043/Servicio{}.svc?wsdl' + if NEW_SERVER: + base_url = 'https://serviciosnominas.ecodex.com.mx:4043/Servicio{}.svc?wsdl' + base_api = 'https://api.ecodex.com.mx/{}' + if debug: + base_url = 'https://wsdev.ecodex.com.mx:2045/Servicio{}.svc?wsdl' + base_api = 'https://pruebasapi.ecodex.com.mx/{}' + url = { + 'seguridad': base_url.format('Seguridad'), + 'clients': base_url.format('Clientes'), + 'timbra': base_url.format('Timbrado'), + 'token': base_api.format('token?version=2'), + 'docs': base_api.format('api/documentos'), + 'hash': base_api.format('api/Documentos/{}'), + 'codes': { + 'HASH': 'DUPLICIDAD EN HASH', + } + } + return auth, url + + +#~ IMPORTANTE: Si quieres hacer pruebas, con tu propio correo de usuario y +#~ contraseña, ponte en contacto con Finkok para que te asignen tus datos de +#~ acceso, consulta su documentación para ver las diferentes opciones de acceso. +#~ Si solo estas haciendo pruebas de timbrado y ancelación, con estos datos debería +#~ ser suficiente. +def finkok(debug): + USER = FINKOK['USER'] + PASS = FINKOK['PASS'] + TOKEN = '' + auth = { + 'USER': '', + 'PASS': TOKEN or PASS, + 'RESELLER': {'USER': USER, 'PASS': PASS} + } + if debug: + USER = 'pruebas-finkok@correolibre.net' + PASS = '' + TOKEN = '5c9a88da105bff9a8c430cb713f6d35269f51674bdc5963c1501b7316366' + auth = { + 'USER': USER, + 'PASS': TOKEN or PASS, + 'RESELLER': { + 'USER': '', + 'PASS': '' + } + } + + base_url = 'https://facturacion.finkok.com/servicios/soap/{}.wsdl' + if debug: + base_url = 'http://demo-facturacion.finkok.com/servicios/soap/{}.wsdl' + url = { + 'timbra': base_url.format('stamp'), + 'quick_stamp': False, + 'cancel': base_url.format('cancel'), + 'client': base_url.format('registration'), + 'util': base_url.format('utilities'), + 'codes': { + '200': 'Comprobante timbrado satisfactoriamente', + '307': 'Comprobante timbrado previamente', + '205': 'No Encontrado', + } + } + return auth, url + + +AUTH, URL = globals()[PAC](DEBUG) + diff --git a/source/app/settings.py b/source/app/settings.py index b968e87..a69cd1f 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -7,7 +7,7 @@ from mako.lookup import TemplateLookup from logbook import Logger, StreamHandler, RotatingFileHandler logbook.set_datetime_format('local') -from conf import DEBUG +from conf import DEBUG, LOG_PATH DEBUG = DEBUG @@ -52,8 +52,6 @@ if DEBUG: level=LOG_LEVEL, format_string=format_string).push_application() else: - #~ Establece una ruta con acceso para nginx o el servidor web que uses - LOG_PATH = '/srv/log/empresalibre.log' RotatingFileHandler( LOG_PATH, backup_count=10,