forked from elmau/empresa-libre
Cambio en consulta de timbres
This commit is contained in:
parent
c85af83275
commit
cb6e4e21cf
|
@ -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]
|
v 1.10.0 [10-jul-2018]
|
||||||
----------------------
|
----------------------
|
||||||
- Ahora se pueden manejar precios con cuatro decimales.
|
- Ahora se pueden manejar precios con cuatro decimales.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
MV = True
|
MV = False
|
||||||
|
|
||||||
# ~ Es la contraseña predeterminada de los usuarios admin y superadmin al crear
|
# ~ Es la contraseña predeterminada de los usuarios admin y superadmin al crear
|
||||||
# ~ una nueva base de datos, personaliza por la que quieras.
|
# ~ una nueva base de datos, personaliza por la que quieras.
|
||||||
|
@ -11,7 +11,7 @@ DEFAULT_PASSWORD = 'salgueiro3.3'
|
||||||
TITLE_APP = 'Empresa Libre'
|
TITLE_APP = 'Empresa Libre'
|
||||||
|
|
||||||
#~ Establece una ruta accesible para el servidor web
|
#~ 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
|
# ~ Establece los valores para sincronizar los backups de la base de datos
|
||||||
# ~ por ejemplo
|
# ~ por ejemplo
|
||||||
|
|
|
@ -361,7 +361,7 @@ class Finkok(object):
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'cer': cer,
|
'cer': cer,
|
||||||
'key': key,
|
'key': key,
|
||||||
'store_pending': True,
|
'store_pending': False,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
result = client.service.cancel(**args)
|
result = client.service.cancel(**args)
|
||||||
|
@ -391,7 +391,7 @@ class Finkok(object):
|
||||||
'username': self._auth['USER'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['PASS'],
|
'password': self._auth['PASS'],
|
||||||
'xml': xml,
|
'xml': xml,
|
||||||
'store_pending': True,
|
'store_pending': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -652,6 +652,35 @@ class Finkok(object):
|
||||||
|
|
||||||
return result
|
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):
|
def _get_data_sat(path):
|
||||||
BF = 'string(//*[local-name()="{}"]/@{})'
|
BF = 'string(//*[local-name()="{}"]/@{})'
|
||||||
|
|
|
@ -2378,7 +2378,7 @@ def sync_cfdi(auth, files):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not auth['REPO']:
|
if not auth['REPO'] or not SEAFILE_SERVER:
|
||||||
return
|
return
|
||||||
|
|
||||||
seafile = SeaFileAPI(SEAFILE_SERVER['URL'], auth['USER'], auth['PASS'])
|
seafile = SeaFileAPI(SEAFILE_SERVER['URL'], auth['USER'], auth['PASS'])
|
||||||
|
@ -3416,17 +3416,18 @@ def get_log(name):
|
||||||
return data, name
|
return data, name
|
||||||
|
|
||||||
|
|
||||||
def get_timbres(rfc, token):
|
def get_timbres(auth):
|
||||||
if DEBUG:
|
from .pac import Finkok as PAC
|
||||||
return '-1'
|
|
||||||
|
|
||||||
url = API.format('/timbres/{}'.format(rfc))
|
if DEBUG:
|
||||||
headers = {'Auth-Token': token}
|
return '-d'
|
||||||
try:
|
|
||||||
result = requests.get(url, headers=headers, timeout=10)
|
pac = PAC(auth)
|
||||||
return result.json()
|
timbres = pac.client_get_timbres(auth['RFC'])
|
||||||
except Exception as e:
|
if pac.error:
|
||||||
return 'n/e'
|
return '-e'
|
||||||
|
|
||||||
|
return timbres
|
||||||
|
|
||||||
|
|
||||||
def truncate(value):
|
def truncate(value):
|
||||||
|
|
|
@ -40,7 +40,7 @@ class StorageEngine(object):
|
||||||
return getattr(self, '_get_{}'.format(table))(values)
|
return getattr(self, '_get_{}'.format(table))(values)
|
||||||
|
|
||||||
def _get_timbres(self, values):
|
def _get_timbres(self, values):
|
||||||
return main.get_timbres()
|
return main.Emisor.get_timbres()
|
||||||
|
|
||||||
def _get_schoolgroups(self, values):
|
def _get_schoolgroups(self, values):
|
||||||
return main.Grupos.get_by(values)
|
return main.Grupos.get_by(values)
|
||||||
|
|
|
@ -159,6 +159,11 @@ def import_invoice():
|
||||||
try:
|
try:
|
||||||
obj = Productos.get(Productos.clave==row[0])
|
obj = Productos.get(Productos.clave==row[0])
|
||||||
vu = round(row[2], 2)
|
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)
|
descuento = round(row[3], 2)
|
||||||
cant = round(row[4], 2)
|
cant = round(row[4], 2)
|
||||||
pf = vu - descuento
|
pf = vu - descuento
|
||||||
|
@ -177,6 +182,7 @@ def import_invoice():
|
||||||
products.append(p)
|
products.append(p)
|
||||||
except Productos.DoesNotExist:
|
except Productos.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
log.info('Factura importada...')
|
log.info('Factura importada...')
|
||||||
return {'ok': True, 'rows': tuple(products)}
|
return {'ok': True, 'rows': tuple(products)}
|
||||||
|
|
||||||
|
@ -211,15 +217,6 @@ def get_doc(type_doc, id, rfc):
|
||||||
return data, file_name, content_type
|
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():
|
def config_main():
|
||||||
try:
|
try:
|
||||||
obj = Emisor.select()[0]
|
obj = Emisor.select()[0]
|
||||||
|
@ -244,7 +241,7 @@ def config_main():
|
||||||
titulo = '{} - <b><font color="#610B0B">{}</font></b>'
|
titulo = '{} - <b><font color="#610B0B">{}</font></b>'
|
||||||
data['empresa'] = titulo.format(data['empresa'], obj.nombre)
|
data['empresa'] = titulo.format(data['empresa'], obj.nombre)
|
||||||
data['escuela'] = obj.es_escuela
|
data['escuela'] = obj.es_escuela
|
||||||
data['timbres'] = util.get_timbres(obj.rfc, obj.token_timbrado)
|
data['timbres'] = Emisor.get_timbres()
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -822,6 +819,14 @@ class Emisor(BaseModel):
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_timbres(cls):
|
||||||
|
auth = cls.get_auth()
|
||||||
|
if not auth:
|
||||||
|
return 'c/e'
|
||||||
|
|
||||||
|
return util.get_timbres(auth)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_regimenes(cls):
|
def get_regimenes(cls):
|
||||||
try:
|
try:
|
||||||
|
@ -856,6 +861,9 @@ class Emisor(BaseModel):
|
||||||
fields['autorizacion'] = fields.pop('ong_autorizacion', '')
|
fields['autorizacion'] = fields.pop('ong_autorizacion', '')
|
||||||
fields['fecha_autorizacion'] = fields.pop('ong_fecha', None)
|
fields['fecha_autorizacion'] = fields.pop('ong_fecha', None)
|
||||||
fields['fecha_dof'] = fields.pop('ong_fecha_dof', 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:
|
if len(fields['rfc']) == 12:
|
||||||
fields['es_moral'] = True
|
fields['es_moral'] = True
|
||||||
fields['registro_patronal'] = fields.pop('emisor_registro_patronal', '')
|
fields['registro_patronal'] = fields.pop('emisor_registro_patronal', '')
|
||||||
|
|
|
@ -31,7 +31,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.10.0'
|
VERSION = '1.11.0'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue