forked from elmau/empresa-libre
Crear BD de rfcs de acceso
This commit is contained in:
parent
54d925c8b1
commit
c76418917e
|
@ -244,8 +244,8 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'username': self._auth['user'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['pass'],
|
'password': self._auth['PASS'],
|
||||||
'xml': xml,
|
'xml': xml,
|
||||||
}
|
}
|
||||||
if URL['quick_stamp']:
|
if URL['quick_stamp']:
|
||||||
|
@ -272,8 +272,8 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'username': self._auth['user'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['pass'],
|
'password': self._auth['PASS'],
|
||||||
'uuid': uuid,
|
'uuid': uuid,
|
||||||
'taxpayer_id': self.rfc,
|
'taxpayer_id': self.rfc,
|
||||||
'invoice_type': 'I',
|
'invoice_type': 'I',
|
||||||
|
@ -323,7 +323,7 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
try:
|
try:
|
||||||
result = client.service.query_pending(
|
result = client.service.query_pending(
|
||||||
self._auth['user'], self._auth['pass'], uuid)
|
self._auth['USER'], self._auth['PASS'], uuid)
|
||||||
#~ print (result.date)
|
#~ print (result.date)
|
||||||
#~ tree = parseString(unescape(result.xml))
|
#~ tree = parseString(unescape(result.xml))
|
||||||
#~ response = tree.toprettyxml(encoding='utf-8').decode('utf-8')
|
#~ response = tree.toprettyxml(encoding='utf-8').decode('utf-8')
|
||||||
|
@ -347,8 +347,8 @@ class Finkok(object):
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'UUIDS': uuid_type(uuids=sa(string=uuids)),
|
'UUIDS': uuid_type(uuids=sa(string=uuids)),
|
||||||
'username': self._auth['user'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['pass'],
|
'password': self._auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'cer': cer,
|
'cer': cer,
|
||||||
'key': key,
|
'key': key,
|
||||||
|
@ -379,8 +379,8 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'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': True,
|
||||||
}
|
}
|
||||||
|
@ -398,8 +398,8 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'username': self._auth['user'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['pass'],
|
'password': self._auth['PASS'],
|
||||||
'taxpayer_id': rfc,
|
'taxpayer_id': rfc,
|
||||||
'uuid': '',
|
'uuid': '',
|
||||||
'type': type_acuse,
|
'type': type_acuse,
|
||||||
|
@ -426,8 +426,8 @@ class Finkok(object):
|
||||||
URL[method], transport=self._transport, plugins=self._plugins)
|
URL[method], transport=self._transport, plugins=self._plugins)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'username': self._auth['user'],
|
'username': self._auth['USER'],
|
||||||
'password': self._auth['pass'],
|
'password': self._auth['PASS'],
|
||||||
'uuid': '',
|
'uuid': '',
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -95,7 +95,23 @@ def get_value(arg):
|
||||||
return value
|
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):
|
def _get_args(rfc):
|
||||||
|
_valid_db_companies()
|
||||||
con = sqlite3.connect(COMPANIES)
|
con = sqlite3.connect(COMPANIES)
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
sql = "SELECT con FROM names WHERE rfc=?"
|
sql = "SELECT con FROM names WHERE rfc=?"
|
||||||
|
@ -111,6 +127,18 @@ def _get_args(rfc):
|
||||||
return values[0]
|
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=''):
|
def get_con(rfc=''):
|
||||||
if not rfc:
|
if not rfc:
|
||||||
rfc = get_value('RFC').upper()
|
rfc = get_value('RFC').upper()
|
||||||
|
@ -123,17 +151,6 @@ def get_con(rfc=''):
|
||||||
return loads(args)
|
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):
|
def get_sat_key(table, key):
|
||||||
con = sqlite3.connect(DB_SAT)
|
con = sqlite3.connect(DB_SAT)
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
|
|
|
@ -14,7 +14,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
from controllers import util
|
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}'
|
FORMAT = '{0:.2f}'
|
||||||
|
@ -241,7 +242,7 @@ class Emisor(BaseModel):
|
||||||
def get_auth(cls):
|
def get_auth(cls):
|
||||||
try:
|
try:
|
||||||
obj = Emisor.select()[0]
|
obj = Emisor.select()[0]
|
||||||
return {'user': obj.correo_timbrado, 'pass': obj.token_timbrado}
|
return {'USER': obj.correo_timbrado, 'PASS': obj.token_timbrado}
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -1708,6 +1709,7 @@ def _cambiar_contraseña():
|
||||||
|
|
||||||
|
|
||||||
def _add_emisor(rfc, args):
|
def _add_emisor(rfc, args):
|
||||||
|
util._valid_db_companies()
|
||||||
con = sqlite3.connect(COMPANIES)
|
con = sqlite3.connect(COMPANIES)
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
sql = """
|
sql = """
|
||||||
|
@ -1726,6 +1728,7 @@ def _add_emisor(rfc, args):
|
||||||
|
|
||||||
|
|
||||||
def _delete_emisor(rfc):
|
def _delete_emisor(rfc):
|
||||||
|
util._valid_db_companies()
|
||||||
con = sqlite3.connect(COMPANIES)
|
con = sqlite3.connect(COMPANIES)
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
sql = """
|
sql = """
|
||||||
|
@ -1830,7 +1833,7 @@ def _importar_valores(archivo='', rfc=''):
|
||||||
conectar(args)
|
conectar(args)
|
||||||
|
|
||||||
if not archivo:
|
if not archivo:
|
||||||
archivo = 'valores_iniciales.json'
|
archivo = INIT_VALUES
|
||||||
|
|
||||||
log.info('Importando datos...')
|
log.info('Importando datos...')
|
||||||
regimen = ''
|
regimen = ''
|
||||||
|
|
|
@ -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'))
|
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'))
|
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_XSLT = os.path.abspath(os.path.join(BASE_DIR, '..', 'xslt'))
|
||||||
PATH_BIN = os.path.abspath(os.path.join(BASE_DIR, '..', 'bin'))
|
PATH_BIN = os.path.abspath(os.path.join(BASE_DIR, '..', 'bin'))
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue