Crear BD de rfcs de acceso

This commit is contained in:
Mauricio Baeza 2017-10-26 13:09:47 -05:00
parent 54d925c8b1
commit c76418917e
6 changed files with 50 additions and 27 deletions

View File

@ -244,8 +244,8 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
args = {
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'xml': xml,
}
if URL['quick_stamp']:
@ -272,8 +272,8 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
args = {
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'uuid': uuid,
'taxpayer_id': self.rfc,
'invoice_type': 'I',
@ -323,7 +323,7 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
try:
result = client.service.query_pending(
self._auth['user'], self._auth['pass'], uuid)
self._auth['USER'], self._auth['PASS'], uuid)
#~ print (result.date)
#~ tree = parseString(unescape(result.xml))
#~ response = tree.toprettyxml(encoding='utf-8').decode('utf-8')
@ -347,8 +347,8 @@ class Finkok(object):
args = {
'UUIDS': uuid_type(uuids=sa(string=uuids)),
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'taxpayer_id': rfc,
'cer': cer,
'key': key,
@ -379,8 +379,8 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
args = {
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'xml': xml,
'store_pending': True,
}
@ -398,8 +398,8 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
args = {
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'taxpayer_id': rfc,
'uuid': '',
'type': type_acuse,
@ -426,8 +426,8 @@ class Finkok(object):
URL[method], transport=self._transport, plugins=self._plugins)
args = {
'username': self._auth['user'],
'password': self._auth['pass'],
'username': self._auth['USER'],
'password': self._auth['PASS'],
'uuid': '',
}
try:

View File

@ -95,7 +95,23 @@ def get_value(arg):
return value
def _valid_db_companies():
con = sqlite3.connect(COMPANIES)
sql = """
CREATE TABLE IF NOT EXISTS names(
rfc TEXT NOT NULL COLLATE NOCASE UNIQUE,
con TEXT NOT NULL
);
"""
cursor = con.cursor()
cursor.executescript(sql)
cursor.close()
con.close()
return
def _get_args(rfc):
_valid_db_companies()
con = sqlite3.connect(COMPANIES)
cursor = con.cursor()
sql = "SELECT con FROM names WHERE rfc=?"
@ -111,6 +127,18 @@ def _get_args(rfc):
return values[0]
def get_rfcs():
_valid_db_companies()
con = sqlite3.connect(COMPANIES)
cursor = con.cursor()
sql = "SELECT * FROM names"
cursor.execute(sql)
values = cursor.fetchall()
cursor.close()
con.close()
return values
def get_con(rfc=''):
if not rfc:
rfc = get_value('RFC').upper()
@ -123,17 +151,6 @@ def get_con(rfc=''):
return loads(args)
def get_rfcs():
con = sqlite3.connect(COMPANIES)
cursor = con.cursor()
sql = "SELECT * FROM names"
cursor.execute(sql)
values = cursor.fetchall()
cursor.close()
con.close()
return values
def get_sat_key(table, key):
con = sqlite3.connect(DB_SAT)
cursor = con.cursor()

View File

@ -14,7 +14,8 @@ if __name__ == '__main__':
from controllers import util
from settings import log, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI
from settings import log, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI, \
INIT_VALUES
FORMAT = '{0:.2f}'
@ -241,7 +242,7 @@ class Emisor(BaseModel):
def get_auth(cls):
try:
obj = Emisor.select()[0]
return {'user': obj.correo_timbrado, 'pass': obj.token_timbrado}
return {'USER': obj.correo_timbrado, 'PASS': obj.token_timbrado}
except:
return {}
@ -1708,6 +1709,7 @@ def _cambiar_contraseña():
def _add_emisor(rfc, args):
util._valid_db_companies()
con = sqlite3.connect(COMPANIES)
cursor = con.cursor()
sql = """
@ -1726,6 +1728,7 @@ def _add_emisor(rfc, args):
def _delete_emisor(rfc):
util._valid_db_companies()
con = sqlite3.connect(COMPANIES)
cursor = con.cursor()
sql = """
@ -1830,7 +1833,7 @@ def _importar_valores(archivo='', rfc=''):
conectar(args)
if not archivo:
archivo = 'valores_iniciales.json'
archivo = INIT_VALUES
log.info('Importando datos...')
regimen = ''

View File

@ -23,6 +23,9 @@ 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'))
DB_SAT = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'sat.db'))
IV = 'valores_iniciales.json'
INIT_VALUES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', IV))
PATH_XSLT = os.path.abspath(os.path.join(BASE_DIR, '..', 'xslt'))
PATH_BIN = os.path.abspath(os.path.join(BASE_DIR, '..', 'bin'))

Binary file not shown.