2018-08-24 23:04:10 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# ~ Empresa Libre
|
|
|
|
# ~ Copyright (C) 2016-2018 Mauricio Baeza Servin (web@correolibre.net)
|
|
|
|
# ~
|
|
|
|
# ~ This program is free software: you can redistribute it and/or modify
|
|
|
|
# ~ it under the terms of the GNU General Public License as published by
|
|
|
|
# ~ the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# ~ (at your option) any later version.
|
|
|
|
# ~
|
|
|
|
# ~ This program is distributed in the hope that it will be useful,
|
|
|
|
# ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# ~ GNU General Public License for more details.
|
|
|
|
# ~
|
|
|
|
# ~ You should have received a copy of the GNU General Public License
|
|
|
|
# ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
import logbook
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from mako.lookup import TemplateLookup
|
|
|
|
from logbook import Logger, StreamHandler, RotatingFileHandler
|
2017-09-21 23:24:18 -05:00
|
|
|
logbook.set_datetime_format('local')
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-11-30 00:37:13 -06:00
|
|
|
from conf import DEBUG, MV, LOG_PATH
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-12-05 22:39:46 -06:00
|
|
|
try:
|
|
|
|
from conf import DEFAULT_PASSWORD
|
|
|
|
except ImportError:
|
2018-01-30 23:40:33 -06:00
|
|
|
DEFAULT_PASSWORD = 'salgueiro3.3'
|
2017-12-05 22:39:46 -06:00
|
|
|
|
2017-12-10 12:12:06 -06:00
|
|
|
try:
|
|
|
|
from conf import SEAFILE_SERVER
|
|
|
|
except ImportError:
|
|
|
|
SEAFILE_SERVER = {}
|
|
|
|
|
2018-01-25 23:06:03 -06:00
|
|
|
try:
|
|
|
|
from conf import TITLE_APP
|
|
|
|
except ImportError:
|
|
|
|
TITLE_APP = 'Empresa Libre'
|
|
|
|
|
2018-01-30 23:40:33 -06:00
|
|
|
try:
|
|
|
|
from conf import NO_HTTPS
|
|
|
|
except ImportError:
|
|
|
|
NO_HTTPS = True
|
|
|
|
|
2017-10-22 14:53:07 -05:00
|
|
|
|
|
|
|
DEBUG = DEBUG
|
2018-09-12 22:19:51 -05:00
|
|
|
VERSION = '1.15.0'
|
2017-09-30 00:22:55 -05:00
|
|
|
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
2018-06-03 00:00:04 -05:00
|
|
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
2018-01-11 10:20:55 -06:00
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
PATH_STATIC = os.path.abspath(os.path.join(BASE_DIR, '..'))
|
|
|
|
PATH_TEMPLATES = os.path.abspath(os.path.join(BASE_DIR, '..', 'templates'))
|
2017-10-24 00:03:07 -05:00
|
|
|
PATH_MEDIA = os.path.abspath(os.path.join(BASE_DIR, '..', 'docs'))
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-09-30 00:22:55 -05:00
|
|
|
PATH_CP = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'cp.db'))
|
|
|
|
COMPANIES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'rfc.db'))
|
2017-10-04 00:11:49 -05:00
|
|
|
DB_SAT = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'sat.db'))
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2018-01-11 10:20:55 -06:00
|
|
|
PATH_SESSIONS = {
|
|
|
|
'data': os.path.abspath(os.path.join(BASE_DIR, '..', 'cache', 'data')),
|
|
|
|
'lock': os.path.abspath(os.path.join(BASE_DIR, '..', 'cache', 'lock')),
|
|
|
|
}
|
|
|
|
|
2017-10-26 13:09:47 -05:00
|
|
|
IV = 'valores_iniciales.json'
|
|
|
|
INIT_VALUES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', IV))
|
2017-10-29 16:53:10 -06:00
|
|
|
CT = 'cancel_template.xml'
|
|
|
|
TEMPLATE_CANCEL = os.path.abspath(os.path.join(PATH_TEMPLATES, CT))
|
2017-10-26 13:09:47 -05:00
|
|
|
|
2017-10-10 18:49:05 -05:00
|
|
|
PATH_XSLT = os.path.abspath(os.path.join(BASE_DIR, '..', 'xslt'))
|
|
|
|
PATH_BIN = os.path.abspath(os.path.join(BASE_DIR, '..', 'bin'))
|
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
template_lookup = TemplateLookup(directories=[PATH_TEMPLATES],
|
|
|
|
input_encoding='utf-8',
|
|
|
|
output_encoding='utf-8')
|
|
|
|
|
|
|
|
LOG_NAME = 'API'
|
|
|
|
LOG_LEVEL = 'INFO'
|
|
|
|
|
|
|
|
format_string = '[{record.time:%d-%b-%Y %H:%M:%S}] ' \
|
|
|
|
'{record.level_name}: ' \
|
|
|
|
'{record.channel}: ' \
|
|
|
|
'{record.message}'
|
|
|
|
|
2017-10-22 15:13:35 -05:00
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
if DEBUG:
|
|
|
|
LOG_LEVEL = 'DEBUG'
|
|
|
|
StreamHandler(
|
|
|
|
sys.stdout,
|
|
|
|
level=LOG_LEVEL,
|
|
|
|
format_string=format_string).push_application()
|
|
|
|
else:
|
|
|
|
RotatingFileHandler(
|
|
|
|
LOG_PATH,
|
|
|
|
backup_count=10,
|
|
|
|
max_size=1073741824,
|
|
|
|
level=LOG_LEVEL,
|
|
|
|
format_string=format_string).push_application()
|
|
|
|
|
2017-10-22 15:13:35 -05:00
|
|
|
StreamHandler(
|
|
|
|
sys.stdout,
|
|
|
|
level=LOG_LEVEL,
|
|
|
|
format_string=format_string).push_application()
|
|
|
|
|
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
log = Logger(LOG_NAME)
|
|
|
|
|
2017-10-10 18:49:05 -05:00
|
|
|
|
|
|
|
PATH_XSLTPROC = 'xsltproc'
|
|
|
|
PATH_OPENSSL = 'openssl'
|
2017-10-29 16:53:10 -06:00
|
|
|
PATH_XMLSEC = 'xmlsec1'
|
2017-10-10 18:49:05 -05:00
|
|
|
if 'win' in sys.platform:
|
|
|
|
PATH_XSLTPROC = os.path.join(PATH_BIN, 'xsltproc.exe')
|
|
|
|
PATH_OPENSSL = os.path.join(PATH_BIN, 'openssl.exe')
|
2017-10-29 16:53:10 -06:00
|
|
|
PATH_XMLSEC = os.path.join(PATH_BIN, 'xmlsec.exe')
|
2017-10-15 02:30:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
PRE = {
|
|
|
|
'2.0': '{http://www.sat.gob.mx/cfd/2}',
|
|
|
|
'2.2': '{http://www.sat.gob.mx/cfd/2}',
|
|
|
|
'3.0': '{http://www.sat.gob.mx/cfd/3}',
|
|
|
|
'3.2': '{http://www.sat.gob.mx/cfd/3}',
|
|
|
|
'3.3': '{http://www.sat.gob.mx/cfd/3}',
|
|
|
|
'TIMBRE': '{http://www.sat.gob.mx/TimbreFiscalDigital}',
|
2017-11-25 20:26:15 -06:00
|
|
|
'DONATARIA': '{http://www.sat.gob.mx/donat}',
|
2017-11-26 00:15:14 -06:00
|
|
|
'INE': '{http://www.sat.gob.mx/ine}',
|
2017-11-29 23:57:31 -06:00
|
|
|
'LOCALES': '{http://www.sat.gob.mx/implocal}',
|
2017-10-15 02:30:55 -05:00
|
|
|
'NOMINA': {
|
|
|
|
'1.1': '{http://www.sat.gob.mx/nomina}',
|
|
|
|
'1.2': '{http://www.sat.gob.mx/nomina12}',
|
2018-08-30 19:24:33 -05:00
|
|
|
},
|
|
|
|
'pagos': '{http://www.sat.gob.mx/Pagos}',
|
2017-10-15 02:30:55 -05:00
|
|
|
}
|
2017-10-25 19:46:13 -05:00
|
|
|
|
|
|
|
CURRENT_CFDI = '3.3'
|
2018-01-14 20:28:19 -06:00
|
|
|
CURRENT_CFDI_NOMINA = '1.2'
|
2017-11-14 20:04:01 -06:00
|
|
|
DECIMALES = 2
|
2018-01-21 21:38:29 -06:00
|
|
|
DECIMALES_TAX = 4
|
2018-07-10 23:34:32 -05:00
|
|
|
DECIMALES_PRECIOS = 4
|
2017-11-15 00:12:55 -06:00
|
|
|
IMPUESTOS = {
|
|
|
|
'ISR': '001',
|
|
|
|
'IVA': '002',
|
|
|
|
'IEPS': '003',
|
2018-01-04 21:20:14 -06:00
|
|
|
'EXENTO': '000',
|
2017-11-15 00:12:55 -06:00
|
|
|
'ISH': '000',
|
|
|
|
'INSPECCION DE OBRA': '000',
|
|
|
|
'ICIC': '000',
|
|
|
|
'CEDULAR': '000',
|
2018-01-16 13:26:06 -06:00
|
|
|
'CMIC': '000',
|
|
|
|
'SUPERVISION': '000',
|
2017-11-15 00:12:55 -06:00
|
|
|
}
|
2017-11-15 19:29:51 -06:00
|
|
|
DEFAULT_SAT_PRODUCTO = '01010101'
|
2018-01-02 01:37:52 -06:00
|
|
|
DEFAULT_SERIE_TICKET = 'T'
|
2018-08-30 20:49:45 -05:00
|
|
|
DEFAULT_CFDIPAY = {
|
|
|
|
'SERIE': 'FP',
|
|
|
|
'TYPE': 'P',
|
|
|
|
'WAYPAY': 'PPD',
|
|
|
|
'CURRENCY': 'XXX',
|
|
|
|
'USED': 'P01',
|
|
|
|
'KEYSAT': '84111506',
|
|
|
|
'UNITKEY': 'ACT',
|
|
|
|
'DESCRIPTION': 'Pago',
|
2018-09-07 00:08:16 -05:00
|
|
|
'TYPE_RELATION': '04',
|
2018-08-30 20:49:45 -05:00
|
|
|
}
|
2017-12-23 22:21:35 -06:00
|
|
|
DIR_FACTURAS = 'facturas'
|
|
|
|
USAR_TOKEN = False
|
2018-01-01 02:14:30 -06:00
|
|
|
CANCEL_SIGNATURE = False
|
2018-01-14 20:28:19 -06:00
|
|
|
PUBLIC = 'Público en general'
|
|
|
|
DEFAULT_SAT_NOMINA = {
|
2018-01-28 03:12:35 -06:00
|
|
|
'SERIE': 'N',
|
|
|
|
'FORMA_PAGO': '99',
|
|
|
|
'USO_CFDI': 'P01',
|
2018-01-14 20:28:19 -06:00
|
|
|
'CLAVE': '84111505',
|
|
|
|
'UNIDAD': 'ACT',
|
|
|
|
'DESCRIPCION': 'Pago de nómina',
|
2018-02-13 23:12:21 -06:00
|
|
|
}
|
|
|
|
|
2018-06-14 22:20:55 -05:00
|
|
|
API = 'https://api.empresalibre.net{}'
|
|
|
|
|