Validado el timbrado con postgres
This commit is contained in:
parent
6f2cd1facd
commit
82edc2a75a
|
@ -1,10 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from peewee import SqliteDatabase
|
|
||||||
|
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
ID_SUPPORT = ''
|
|
||||||
|
|
||||||
DATABASE = None
|
|
||||||
if DEBUG:
|
|
||||||
DATABASE = SqliteDatabase('empresalibre.sqlite')
|
|
||||||
|
|
|
@ -443,21 +443,41 @@ class Finkok(object):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def add_token(self, rfc, email):
|
def add_token(self, rfc, email):
|
||||||
"""
|
"""Agrega un nuevo token al cliente para timbrado.
|
||||||
Se requiere cuenta de reseller para usar este método
|
Se requiere cuenta de reseller para usar este método
|
||||||
|
|
||||||
|
Args:
|
||||||
|
rfc (str): El RFC del cliente, ya debe existir
|
||||||
|
email (str): El correo del cliente, funciona como USER al timbrar
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict
|
||||||
|
'username': 'username',
|
||||||
|
'status': True or False
|
||||||
|
'name': 'name',
|
||||||
|
'success': True or False
|
||||||
|
'token': 'Token de timbrado',
|
||||||
|
'message': None
|
||||||
"""
|
"""
|
||||||
|
auth = AUTH['RESELLER']
|
||||||
|
|
||||||
method = 'util'
|
method = 'util'
|
||||||
client = Client(
|
client = Client(
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
args = {
|
args = {
|
||||||
'username': AUTH['USER'],
|
'username': auth['USER'],
|
||||||
'password': AUTH['PASS'],
|
'password': auth['PASS'],
|
||||||
'name': rfc,
|
'name': rfc,
|
||||||
'token_username': email,
|
'token_username': email,
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'status': True,
|
'status': True,
|
||||||
}
|
}
|
||||||
result = client.service.add_token(**args)
|
try:
|
||||||
|
result = client.service.add_token(**args)
|
||||||
|
except Fault as e:
|
||||||
|
self.error = str(e)
|
||||||
|
return ''
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_date(self):
|
def get_date(self):
|
||||||
|
@ -477,17 +497,31 @@ class Finkok(object):
|
||||||
return result.datetime
|
return result.datetime
|
||||||
|
|
||||||
def add_client(self, rfc, type_user=False):
|
def add_client(self, rfc, type_user=False):
|
||||||
"""
|
"""Agrega un nuevo cliente para timbrado.
|
||||||
Se requiere cuenta de reseller para usar este método
|
Se requiere cuenta de reseller para usar este método
|
||||||
type_user: False == 'P' == Prepago or True == 'O' == On demand
|
|
||||||
|
Args:
|
||||||
|
rfc (str): El RFC del nuevo cliente
|
||||||
|
|
||||||
|
Kwargs:
|
||||||
|
type_user (bool): False == 'P' == Prepago or True == 'O' == On demand
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict
|
||||||
|
'message':
|
||||||
|
'Account Created successfully'
|
||||||
|
'Account Already exists'
|
||||||
|
'success': True or False
|
||||||
"""
|
"""
|
||||||
|
auth = AUTH['RESELLER']
|
||||||
|
|
||||||
tu = {False: 'P', True: 'O'}
|
tu = {False: 'P', True: 'O'}
|
||||||
method = 'client'
|
method = 'client'
|
||||||
client = Client(
|
client = Client(
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
args = {
|
args = {
|
||||||
'reseller_username': AUTH['USER'],
|
'reseller_username': auth['USER'],
|
||||||
'reseller_password': AUTH['PASS'],
|
'reseller_password': auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'type_user': tu[type_user],
|
'type_user': tu[type_user],
|
||||||
'added': datetime.datetime.now().isoformat()[:19],
|
'added': datetime.datetime.now().isoformat()[:19],
|
||||||
|
@ -505,13 +539,15 @@ class Finkok(object):
|
||||||
Se requiere cuenta de reseller para usar este método
|
Se requiere cuenta de reseller para usar este método
|
||||||
status = 'A' or 'S'
|
status = 'A' or 'S'
|
||||||
"""
|
"""
|
||||||
|
auth = AUTH['RESELLER']
|
||||||
|
|
||||||
sv = {False: 'S', True: 'A'}
|
sv = {False: 'S', True: 'A'}
|
||||||
method = 'client'
|
method = 'client'
|
||||||
client = Client(
|
client = Client(
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
args = {
|
args = {
|
||||||
'reseller_username': AUTH['USER'],
|
'reseller_username': auth['USER'],
|
||||||
'reseller_password': AUTH['PASS'],
|
'reseller_password': auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'status': sv[status],
|
'status': sv[status],
|
||||||
}
|
}
|
||||||
|
@ -524,15 +560,35 @@ class Finkok(object):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_client(self, rfc):
|
def get_client(self, rfc):
|
||||||
"""
|
"""Regresa el estatus del cliente
|
||||||
|
.
|
||||||
Se requiere cuenta de reseller para usar este método
|
Se requiere cuenta de reseller para usar este método
|
||||||
|
|
||||||
|
Args:
|
||||||
|
rfc (str): El RFC del emisor
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict
|
||||||
|
'message': None,
|
||||||
|
'users': {
|
||||||
|
'ResellerUser': [
|
||||||
|
{
|
||||||
|
'status': 'A',
|
||||||
|
'counter': 0,
|
||||||
|
'taxpayer_id': '',
|
||||||
|
'credit': 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} or None si no existe
|
||||||
"""
|
"""
|
||||||
|
auth = AUTH['RESELLER']
|
||||||
|
|
||||||
method = 'client'
|
method = 'client'
|
||||||
client = Client(
|
client = Client(
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
args = {
|
args = {
|
||||||
'reseller_username': AUTH['USER'],
|
'reseller_username': auth['USER'],
|
||||||
'reseller_password': AUTH['PASS'],
|
'reseller_password': auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,15 +604,30 @@ class Finkok(object):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def assign_client(self, rfc, credit):
|
def assign_client(self, rfc, credit):
|
||||||
"""
|
"""Agregar credito a un emisor
|
||||||
|
|
||||||
Se requiere cuenta de reseller para usar este método
|
Se requiere cuenta de reseller para usar este método
|
||||||
|
|
||||||
|
Args:
|
||||||
|
rfc (str): El RFC del emisor, debe existir
|
||||||
|
credit (int): Cantidad de folios a agregar
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict
|
||||||
|
'success': True or False,
|
||||||
|
'credit': nuevo credito despues de agregar or None
|
||||||
|
'message':
|
||||||
|
'Success, added {credit} of credit to {RFC}'
|
||||||
|
'RFC no encontrado'
|
||||||
"""
|
"""
|
||||||
|
auth = AUTH['RESELLER']
|
||||||
|
|
||||||
method = 'client'
|
method = 'client'
|
||||||
client = Client(
|
client = Client(
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
args = {
|
args = {
|
||||||
'username': AUTH['USER'],
|
'username': auth['USER'],
|
||||||
'password': AUTH['PASS'],
|
'password': auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'credit': credit,
|
'credit': credit,
|
||||||
}
|
}
|
||||||
|
|
|
@ -818,7 +818,11 @@ class Productos(BaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_key(cls):
|
def next_key(cls):
|
||||||
value = Productos.select(fn.Max(Productos.id)).scalar()
|
value = (Productos
|
||||||
|
.select(fn.Max(Productos.id))
|
||||||
|
.group_by(Productos.id)
|
||||||
|
.order_by(Productos.id)
|
||||||
|
.scalar())
|
||||||
if value is None:
|
if value is None:
|
||||||
value = 1
|
value = 1
|
||||||
else:
|
else:
|
||||||
|
@ -1198,6 +1202,8 @@ class Facturas(BaseModel):
|
||||||
inicio = (Facturas
|
inicio = (Facturas
|
||||||
.select(fn.Max(Facturas.folio))
|
.select(fn.Max(Facturas.folio))
|
||||||
.where(Facturas.serie==serie)
|
.where(Facturas.serie==serie)
|
||||||
|
.group_by(Facturas.folio)
|
||||||
|
.order_by(Facturas.folio)
|
||||||
.scalar())
|
.scalar())
|
||||||
if inicio is None:
|
if inicio is None:
|
||||||
inicio = inicio_serie
|
inicio = inicio_serie
|
||||||
|
|
Loading…
Reference in New Issue