From 92e6a317ad231f3508b92ecba17ecb87f64c89ea Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Wed, 22 Jan 2020 22:30:11 -0600 Subject: [PATCH 1/2] Get folios by Pac --- source/app/controllers/utils.py | 13 +++++++++++++ source/app/models/main.py | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/app/controllers/utils.py b/source/app/controllers/utils.py index c955291..fbd64ab 100644 --- a/source/app/controllers/utils.py +++ b/source/app/controllers/utils.py @@ -591,3 +591,16 @@ def xml_stamp(xml, auth, name): result['uuid'] = pac.cfdi_uuid result['fecha'] = pac.date_stamped return result + + +def get_client_balance(auth, name): + if DEBUG: + return '-d' + + pac = PACS[name]() + auth = {'usr': auth['USER'], 'pwd': auth['PASS']} + balance = pac.client_balance(auth) + if pac.error: + balance = '-e' + + return balance diff --git a/source/app/models/main.py b/source/app/models/main.py index 7555088..cc5b047 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -1025,7 +1025,12 @@ class Emisor(BaseModel): if not auth: return 'c/e' - return util.get_timbres(auth) + pac = Configuracion.get_('lst_pac').lower() + if pac: + result = utils.get_client_balance(auth, pac) + else: + result = util.get_timbres(auth) + return result @classmethod def get_regimenes(cls): From f102cb7c01dc4caafc105777b5b269efd794a861 Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Fri, 24 Jan 2020 10:01:55 -0600 Subject: [PATCH 2/2] Fix import conf.py --- VERSION | 2 +- source/app/controllers/comercio/comercio.py | 10 +++++++--- source/app/controllers/comercio/conf.py.example | 2 +- source/app/settings.py | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 7aa332e..02261be 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.33.0 +1.33.1 diff --git a/source/app/controllers/comercio/comercio.py b/source/app/controllers/comercio/comercio.py index a6e625b..21292a9 100644 --- a/source/app/controllers/comercio/comercio.py +++ b/source/app/controllers/comercio/comercio.py @@ -23,8 +23,6 @@ import lxml.etree as ET import requests from requests.exceptions import ConnectionError -from .conf import DEBUG, AUTH - LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s' LOG_DATE = '%d/%m/%Y %H:%M:%S' @@ -33,10 +31,16 @@ logging.addLevelName(logging.DEBUG, '\x1b[33mDEBUG\033[1;0m') logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m') logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE) log = logging.getLogger(__name__) - logging.getLogger('requests').setLevel(logging.ERROR) +try: + from .conf import DEBUG, AUTH +except ImportError: + DEBUG = False + log.error('Need make conf.py') + + TIMEOUT = 10 diff --git a/source/app/controllers/comercio/conf.py.example b/source/app/controllers/comercio/conf.py.example index 4e89d68..de81efb 100644 --- a/source/app/controllers/comercio/conf.py.example +++ b/source/app/controllers/comercio/conf.py.example @@ -24,7 +24,7 @@ # ~ con una cuenta de reseller -DEBUG = True +DEBUG = False AUTH = { diff --git a/source/app/settings.py b/source/app/settings.py index 91ae2c8..c77b7c4 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -47,7 +47,7 @@ except ImportError: DEBUG = DEBUG -VERSION = '1.33.0' +VERSION = '1.33.1' EMAIL_SUPPORT = ('soporte@empresalibre.mx',) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)