diff --git a/CHANGELOG.md b/CHANGELOG.md index c111d85..63c718b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +v 1.11.0 [25-jul-2018] +---------------------- + - Se cambia la forma de consultar los folios restantes. Es indispensable actualizar a esta versión para ver tus timbres restantes. + v 1.10.0 [10-jul-2018] ---------------------- - Ahora se pueden manejar precios con cuatro decimales. diff --git a/VERSION b/VERSION index 81c871d..1cac385 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.10.0 +1.11.0 diff --git a/source/app/conf.py.example b/source/app/conf.py.example index 36133c0..b8257e8 100644 --- a/source/app/conf.py.example +++ b/source/app/conf.py.example @@ -2,7 +2,7 @@ DEBUG = False -MV = True +MV = False # ~ Es la contraseña predeterminada de los usuarios admin y superadmin al crear # ~ una nueva base de datos, personaliza por la que quieras. @@ -11,7 +11,7 @@ DEFAULT_PASSWORD = 'salgueiro3.3' TITLE_APP = 'Empresa Libre' #~ Establece una ruta accesible para el servidor web -LOG_PATH = '/home/empresa/.opt/empresa-libre.log' +LOG_PATH = '/var/log/empresalibre/empresa-libre.log' # ~ Establece los valores para sincronizar los backups de la base de datos # ~ por ejemplo diff --git a/source/app/controllers/pac.py b/source/app/controllers/pac.py index a0a4f36..248c351 100644 --- a/source/app/controllers/pac.py +++ b/source/app/controllers/pac.py @@ -361,7 +361,7 @@ class Finkok(object): 'taxpayer_id': rfc, 'cer': cer, 'key': key, - 'store_pending': True, + 'store_pending': False, } try: result = client.service.cancel(**args) @@ -391,7 +391,7 @@ class Finkok(object): 'username': self._auth['USER'], 'password': self._auth['PASS'], 'xml': xml, - 'store_pending': True, + 'store_pending': False, } try: @@ -652,6 +652,35 @@ class Finkok(object): return result + def client_get_timbres(self, rfc): + method = 'client' + client = Client( + URL[method], transport=self._transport, plugins=self._plugins) + args = { + 'reseller_username': self._auth['USER'], + 'reseller_password': self._auth['PASS'], + 'taxpayer_id': rfc, + } + + try: + self.result = client.service.get(**args) + except Fault as e: + self.error = str(e) + return 0 + except TransportError as e: + self.error = str(e) + return 0 + except ConnectionError: + self.error = 'Verifica la conexión a internet' + return 0 + + success = bool(self.result.users) + if not success: + self.error = self.result.message or 'RFC no existe' + return 0 + + return self.result.users.ResellerUser[0].credit + def _get_data_sat(path): BF = 'string(//*[local-name()="{}"]/@{})' diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 0385eae..2077d34 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -2378,7 +2378,7 @@ def sync_cfdi(auth, files): if DEBUG: return - if not auth['REPO']: + if not auth['REPO'] or not SEAFILE_SERVER: return seafile = SeaFileAPI(SEAFILE_SERVER['URL'], auth['USER'], auth['PASS']) @@ -3416,17 +3416,18 @@ def get_log(name): return data, name -def get_timbres(rfc, token): - if DEBUG: - return '-1' +def get_timbres(auth): + from .pac import Finkok as PAC - url = API.format('/timbres/{}'.format(rfc)) - headers = {'Auth-Token': token} - try: - result = requests.get(url, headers=headers, timeout=10) - return result.json() - except Exception as e: - return 'n/e' + if DEBUG: + return '-d' + + pac = PAC(auth) + timbres = pac.client_get_timbres(auth['RFC']) + if pac.error: + return '-e' + + return timbres def truncate(value): diff --git a/source/app/models/db.py b/source/app/models/db.py index 18ac62a..41ff929 100644 --- a/source/app/models/db.py +++ b/source/app/models/db.py @@ -40,7 +40,7 @@ class StorageEngine(object): return getattr(self, '_get_{}'.format(table))(values) def _get_timbres(self, values): - return main.get_timbres() + return main.Emisor.get_timbres() def _get_schoolgroups(self, values): return main.Grupos.get_by(values) diff --git a/source/app/models/main.py b/source/app/models/main.py index b182053..9510a49 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -159,6 +159,11 @@ def import_invoice(): try: obj = Productos.get(Productos.clave==row[0]) vu = round(row[2], 2) + + if isinstance(row[3], str): + msg = 'El descuento debe ser un número, debe ser 0.00, si no tiene' + return {'ok': False, 'msg': msg} + descuento = round(row[3], 2) cant = round(row[4], 2) pf = vu - descuento @@ -177,6 +182,7 @@ def import_invoice(): products.append(p) except Productos.DoesNotExist: pass + log.info('Factura importada...') return {'ok': True, 'rows': tuple(products)} @@ -211,15 +217,6 @@ def get_doc(type_doc, id, rfc): return data, file_name, content_type -def get_timbres(): - try: - obj = Emisor.select()[0] - except IndexError: - return 0 - - return util.get_timbres(obj.rfc, obj.token_timbrado) - - def config_main(): try: obj = Emisor.select()[0] @@ -244,7 +241,7 @@ def config_main(): titulo = '{} - {}' data['empresa'] = titulo.format(data['empresa'], obj.nombre) data['escuela'] = obj.es_escuela - data['timbres'] = util.get_timbres(obj.rfc, obj.token_timbrado) + data['timbres'] = Emisor.get_timbres() return data @@ -822,6 +819,14 @@ class Emisor(BaseModel): except: return {} + @classmethod + def get_timbres(cls): + auth = cls.get_auth() + if not auth: + return 'c/e' + + return util.get_timbres(auth) + @classmethod def get_regimenes(cls): try: @@ -856,6 +861,9 @@ class Emisor(BaseModel): fields['autorizacion'] = fields.pop('ong_autorizacion', '') fields['fecha_autorizacion'] = fields.pop('ong_fecha', None) fields['fecha_dof'] = fields.pop('ong_fecha_dof', None) + fields['correo_timbrado'] = fields.pop('correo_timbrado', '') + fields['token_timbrado'] = fields.pop('token_timbrado', '') + fields['token_soporte'] = fields.pop('token_soporte', '') if len(fields['rfc']) == 12: fields['es_moral'] = True fields['registro_patronal'] = fields.pop('emisor_registro_patronal', '') diff --git a/source/app/settings.py b/source/app/settings.py index 5ec59cc..1ef36d4 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -31,7 +31,7 @@ except ImportError: DEBUG = DEBUG -VERSION = '1.10.0' +VERSION = '1.11.0' EMAIL_SUPPORT = ('soporte@empresalibre.net',) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)