Merge branch 'develop'

Cambio en consulta de timbres
This commit is contained in:
Mauricio Baeza 2018-07-25 16:28:22 -05:00
commit 3163fef0d5
8 changed files with 70 additions and 28 deletions

View File

@ -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.

View File

@ -1 +1 @@
1.10.0
1.11.0

View File

@ -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

View File

@ -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()="{}"]/@{})'

View File

@ -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):

View File

@ -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)

View File

@ -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 = '{} - <b><font color="#610B0B">{}</font></b>'
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', '')

View File

@ -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)