Obtener timbres disponibles
This commit is contained in:
parent
cb7b7b0a1c
commit
9f6e9e36fe
|
@ -8,6 +8,7 @@ import locale
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import requests
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -41,7 +42,7 @@ from settings import DEBUG, MV, log, template_lookup, COMPANIES, DB_SAT, \
|
||||||
PATH_XSLT, PATH_XSLTPROC, PATH_OPENSSL, PATH_TEMPLATES, PATH_MEDIA, PRE, \
|
PATH_XSLT, PATH_XSLTPROC, PATH_OPENSSL, PATH_TEMPLATES, PATH_MEDIA, PRE, \
|
||||||
PATH_XMLSEC, TEMPLATE_CANCEL, DEFAULT_SAT_PRODUCTO, DECIMALES, DIR_FACTURAS
|
PATH_XMLSEC, TEMPLATE_CANCEL, DEFAULT_SAT_PRODUCTO, DECIMALES, DIR_FACTURAS
|
||||||
|
|
||||||
from settings import SEAFILE_SERVER, USAR_TOKEN
|
from settings import SEAFILE_SERVER, USAR_TOKEN, API
|
||||||
from .configpac import AUTH
|
from .configpac import AUTH
|
||||||
|
|
||||||
|
|
||||||
|
@ -3269,3 +3270,14 @@ def get_log(name):
|
||||||
return data, name
|
return data, name
|
||||||
|
|
||||||
|
|
||||||
|
def get_timbres(rfc, token):
|
||||||
|
if DEBUG:
|
||||||
|
return '-1'
|
||||||
|
|
||||||
|
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 ''
|
||||||
|
|
|
@ -36,6 +36,9 @@ class StorageEngine(object):
|
||||||
return getattr(self, '_get_{}'.format(table))(values, session)
|
return getattr(self, '_get_{}'.format(table))(values, session)
|
||||||
return getattr(self, '_get_{}'.format(table))(values)
|
return getattr(self, '_get_{}'.format(table))(values)
|
||||||
|
|
||||||
|
def _get_timbres(self, values):
|
||||||
|
return main.get_timbres()
|
||||||
|
|
||||||
def _get_schoolgroups(self, values):
|
def _get_schoolgroups(self, values):
|
||||||
return main.Grupos.get_by(values)
|
return main.Grupos.get_by(values)
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,15 @@ 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]
|
||||||
|
@ -206,11 +215,13 @@ def config_main():
|
||||||
'punto_de_venta': punto_de_venta,
|
'punto_de_venta': punto_de_venta,
|
||||||
'escuela': False,
|
'escuela': False,
|
||||||
'nomina': nomina,
|
'nomina': nomina,
|
||||||
|
'timbres': 0,
|
||||||
}
|
}
|
||||||
if not obj is None:
|
if not obj is None:
|
||||||
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)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -149,3 +149,7 @@ DEFAULT_SAT_NOMINA = {
|
||||||
'UNIDAD': 'ACT',
|
'UNIDAD': 'ACT',
|
||||||
'DESCRIPCION': 'Pago de nómina',
|
'DESCRIPCION': 'Pago de nómina',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API = 'http://139.162.255.71:4043{}'
|
||||||
|
if DEBUG:
|
||||||
|
API = 'http://127.0.0.1:8080{}'
|
|
@ -460,6 +460,7 @@ function send_timbrar(id){
|
||||||
webix.ajax().get('/values/timbrar', {id: id}, function(text, data){
|
webix.ajax().get('/values/timbrar', {id: id}, function(text, data){
|
||||||
var values = data.json()
|
var values = data.json()
|
||||||
if(values.ok){
|
if(values.ok){
|
||||||
|
cmd_update_timbres_click()
|
||||||
msg_ok(values.msg)
|
msg_ok(values.msg)
|
||||||
gi.updateItem(id, values.row)
|
gi.updateItem(id, values.row)
|
||||||
if(values.anticipo){
|
if(values.anticipo){
|
||||||
|
|
|
@ -33,6 +33,9 @@ function configuracion_inicial(){
|
||||||
value: 'Punto de venta'}
|
value: 'Punto de venta'}
|
||||||
$$('main_sidebar').add(node, pos)
|
$$('main_sidebar').add(node, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$$('cmd_update_timbres').define('badge', values.timbres)
|
||||||
|
$$('cmd_update_timbres').refresh()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +58,7 @@ var controllers = {
|
||||||
$$('prefilter_month').attachEvent('onChange', prefilter_month_change)
|
$$('prefilter_month').attachEvent('onChange', prefilter_month_change)
|
||||||
$$('cmd_delete_preinvoice').attachEvent('onItemClick', cmd_delete_preinvoice_click)
|
$$('cmd_delete_preinvoice').attachEvent('onItemClick', cmd_delete_preinvoice_click)
|
||||||
$$('cmd_facturar_preinvoice').attachEvent('onItemClick', cmd_facturar_preinvoice_click)
|
$$('cmd_facturar_preinvoice').attachEvent('onItemClick', cmd_facturar_preinvoice_click)
|
||||||
|
$$('cmd_update_timbres').attachEvent('onItemClick', cmd_update_timbres_click)
|
||||||
$$('grid_preinvoices').attachEvent('onItemClick', grid_preinvoices_click)
|
$$('grid_preinvoices').attachEvent('onItemClick', grid_preinvoices_click)
|
||||||
|
|
||||||
partners_controllers.init()
|
partners_controllers.init()
|
||||||
|
@ -203,3 +207,12 @@ function get_taxes(){
|
||||||
$$("grid_product_taxes").parse(values, 'json')
|
$$("grid_product_taxes").parse(values, 'json')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmd_update_timbres_click(){
|
||||||
|
webix.ajax().get('/values/timbres', function(text, data){
|
||||||
|
var value = data.json()
|
||||||
|
$$('cmd_update_timbres').define('badge', value)
|
||||||
|
$$('cmd_update_timbres').refresh()
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,210 +0,0 @@
|
||||||
var gi = null
|
|
||||||
|
|
||||||
|
|
||||||
function configuracion_inicial(){
|
|
||||||
webix.ajax().get('/values/admin', function(text, data){
|
|
||||||
var values = data.json()
|
|
||||||
show('cmd_ir_al_admin', values)
|
|
||||||
})
|
|
||||||
webix.ajax().get('/values/main', function(text, data){
|
|
||||||
var values = data.json()
|
|
||||||
$$('lbl_title_main').setValue(values.empresa)
|
|
||||||
<<<<<<< HEAD
|
|
||||||
//~ showvar()
|
|
||||||
var pos = 4
|
|
||||||
if(values.escuela){
|
|
||||||
var node = {
|
|
||||||
id: 'app_school',
|
|
||||||
icon: 'graduation-cap',
|
|
||||||
value: 'Escuela'}
|
|
||||||
=======
|
|
||||||
var pos = 4
|
|
||||||
if(values.nomina){
|
|
||||||
var node = {
|
|
||||||
id: 'app_nomina',
|
|
||||||
icon: 'users',
|
|
||||||
value: 'Nómina'}
|
|
||||||
>>>>>>> nomina
|
|
||||||
$$('main_sidebar').add(node, pos)
|
|
||||||
pos += 1
|
|
||||||
}
|
|
||||||
if(values.punto_de_venta){
|
|
||||||
var node = {
|
|
||||||
id: 'app_tickets',
|
|
||||||
icon: 'money',
|
|
||||||
value: 'Punto de venta'}
|
|
||||||
$$('main_sidebar').add(node, pos)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function cmd_ir_al_admin_click(){
|
|
||||||
window.location = '/admin'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var controllers = {
|
|
||||||
init: function(){
|
|
||||||
//~ Main
|
|
||||||
$$('menu_user').attachEvent('onMenuItemClick', menu_user_click);
|
|
||||||
configuracion_inicial()
|
|
||||||
|
|
||||||
var tb_invoice = $$('tv_invoice').getTabbar()
|
|
||||||
tb_invoice.attachEvent('onChange', tb_invoice_change)
|
|
||||||
$$('prefilter_year').attachEvent('onChange', prefilter_year_change)
|
|
||||||
$$('prefilter_month').attachEvent('onChange', prefilter_month_change)
|
|
||||||
$$('cmd_delete_preinvoice').attachEvent('onItemClick', cmd_delete_preinvoice_click)
|
|
||||||
$$('cmd_facturar_preinvoice').attachEvent('onItemClick', cmd_facturar_preinvoice_click)
|
|
||||||
$$('grid_preinvoices').attachEvent('onItemClick', grid_preinvoices_click)
|
|
||||||
|
|
||||||
partners_controllers.init()
|
|
||||||
products_controllers.init()
|
|
||||||
bancos_controllers.init()
|
|
||||||
invoices_controllers.init()
|
|
||||||
<<<<<<< HEAD
|
|
||||||
controllers_school.init()
|
|
||||||
=======
|
|
||||||
nomina_controllers.init()
|
|
||||||
>>>>>>> nomina
|
|
||||||
tickets_controllers.init()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_uso_cfdi_to_table(){
|
|
||||||
webix.ajax().sync().get('/values/usocfdi', function(text, data){
|
|
||||||
var values = data.json()
|
|
||||||
table_usocfdi.clear()
|
|
||||||
table_usocfdi.insert(values)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_partners(){
|
|
||||||
webix.ajax().get('/partners', {}, {
|
|
||||||
error: function(text, data, xhr) {
|
|
||||||
msg_error('Error al consultar')
|
|
||||||
},
|
|
||||||
success: function(text, data, xhr) {
|
|
||||||
var values = data.json();
|
|
||||||
$$('grid_partners').clearAll();
|
|
||||||
if (values.data){
|
|
||||||
$$('grid_partners').parse(values.data, 'json');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function menu_user_click(id, e, node){
|
|
||||||
if (id == 1){
|
|
||||||
window.location = '/logout';
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function current_dates(){
|
|
||||||
var fy = $$('filter_year')
|
|
||||||
var fm = $$('filter_month')
|
|
||||||
var pfy = $$('prefilter_year')
|
|
||||||
var pfm = $$('prefilter_month')
|
|
||||||
var d = new Date()
|
|
||||||
|
|
||||||
fy.blockEvent()
|
|
||||||
fm.blockEvent()
|
|
||||||
pfy.blockEvent()
|
|
||||||
pfm.blockEvent()
|
|
||||||
|
|
||||||
fm.setValue(d.getMonth() + 1)
|
|
||||||
pfm.setValue(d.getMonth() + 1)
|
|
||||||
webix.ajax().sync().get('/values/filteryears', function(text, data){
|
|
||||||
var values = data.json()
|
|
||||||
fy.getList().parse(values[0])
|
|
||||||
pfy.getList().parse(values[1])
|
|
||||||
fy.setValue(d.getFullYear())
|
|
||||||
pfy.setValue(d.getFullYear())
|
|
||||||
})
|
|
||||||
|
|
||||||
fy.unblockEvent()
|
|
||||||
fm.unblockEvent()
|
|
||||||
pfy.unblockEvent()
|
|
||||||
pfm.unblockEvent()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function multi_change(prevID, nextID){
|
|
||||||
|
|
||||||
if(nextID == 'app_partners'){
|
|
||||||
active = $$('multi_partners').getActiveId()
|
|
||||||
if(active == 'partners_home'){
|
|
||||||
get_partners()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_products'){
|
|
||||||
active = $$('multi_products').getActiveId()
|
|
||||||
if(active == 'products_home'){
|
|
||||||
get_products()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_bancos'){
|
|
||||||
active = $$('multi_bancos').getActiveId()
|
|
||||||
if(active == 'banco_home'){
|
|
||||||
get_cuentas_banco()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_school'){
|
|
||||||
active = $$('multi_school').getActiveId()
|
|
||||||
if(active == 'school_home'){
|
|
||||||
init_config_school()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_tickets'){
|
|
||||||
active = $$('multi_tickets').getActiveId()
|
|
||||||
if(active == 'tickets_home'){
|
|
||||||
configuracion_inicial_ticket()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_nomina'){
|
|
||||||
active = $$('multi_nomina').getActiveId()
|
|
||||||
if(active == 'nomina_home'){
|
|
||||||
default_config_nomina()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextID == 'app_invoices'){
|
|
||||||
active = $$('multi_invoices').getActiveId()
|
|
||||||
if(active == 'invoices_home'){
|
|
||||||
current_dates()
|
|
||||||
get_invoices()
|
|
||||||
validar_timbrar()
|
|
||||||
}
|
|
||||||
gi = $$('grid_invoices')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_taxes(){
|
|
||||||
webix.ajax().sync().get('/values/taxes', function(text, data){
|
|
||||||
var values = data.json()
|
|
||||||
table_taxes.clear()
|
|
||||||
table_taxes.insert(values)
|
|
||||||
$$("grid_product_taxes").clearAll()
|
|
||||||
$$("grid_product_taxes").parse(values, 'json')
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -373,6 +373,7 @@ function timbrar_nomina(){
|
||||||
success: function(text, data, xhr) {
|
success: function(text, data, xhr) {
|
||||||
var values = data.json();
|
var values = data.json();
|
||||||
if(values.ok){
|
if(values.ok){
|
||||||
|
cmd_update_timbres_click()
|
||||||
get_nomina()
|
get_nomina()
|
||||||
msg_ok(values.msg_ok)
|
msg_ok(values.msg_ok)
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ var ui_main = {
|
||||||
{view: 'label', id: 'lbl_title_main', label: '<b>Empresa Libre</b>'},
|
{view: 'label', id: 'lbl_title_main', label: '<b>Empresa Libre</b>'},
|
||||||
{},
|
{},
|
||||||
menu_user,
|
menu_user,
|
||||||
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
{view: 'button', id: 'cmd_update_timbres', type: 'icon', width: 45,
|
||||||
icon: 'bell-o', badge: 0},
|
css: 'app_button', icon: 'bell-o', badge: 0},
|
||||||
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
||||||
icon: 'cogs', id: 'cmd_ir_al_admin', hidden: true,
|
icon: 'cogs', id: 'cmd_ir_al_admin', hidden: true,
|
||||||
click: 'cmd_ir_al_admin_click'}
|
click: 'cmd_ir_al_admin_click'}
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
var menu_data = [
|
|
||||||
{id: 'app_home', icon: 'dashboard', value: 'Inicio'},
|
|
||||||
{id: 'app_partners', icon: 'address-book-o', value: 'Clientes y Proveedores'},
|
|
||||||
{id: 'app_products', icon: 'server', value: 'Productos y Servicios'},
|
|
||||||
{id: 'app_bancos', icon: 'university', value: 'Bancos'},
|
|
||||||
{id: 'app_invoices', icon: 'file-code-o', value: 'Facturas'},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
var sidebar = {
|
|
||||||
view: 'sidebar',
|
|
||||||
id: 'main_sidebar',
|
|
||||||
data: menu_data,
|
|
||||||
ready: function(){
|
|
||||||
this.select('app_home');
|
|
||||||
this.open(this.getParentId('app_home'));
|
|
||||||
},
|
|
||||||
on:{
|
|
||||||
onAfterSelect: function(id){
|
|
||||||
$$('multi').setValue(id)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var multi_main = {
|
|
||||||
id: 'multi',
|
|
||||||
animate: true,
|
|
||||||
cells:[
|
|
||||||
{
|
|
||||||
id: 'app_home',
|
|
||||||
view: 'template',
|
|
||||||
template: 'HOME'
|
|
||||||
},
|
|
||||||
app_partners,
|
|
||||||
app_products,
|
|
||||||
app_bancos,
|
|
||||||
<<<<<<< HEAD
|
|
||||||
app_school,
|
|
||||||
=======
|
|
||||||
app_nomina,
|
|
||||||
>>>>>>> nomina
|
|
||||||
app_tickets,
|
|
||||||
app_invoices,
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var menu_user = {
|
|
||||||
view: 'menu',
|
|
||||||
id: 'menu_user',
|
|
||||||
width: 150,
|
|
||||||
autowidth: true,
|
|
||||||
data: [
|
|
||||||
{id: '0', value: 'User...', submenu:[{id:1, value:'Cerrar Sesión'}]},
|
|
||||||
],
|
|
||||||
type: {
|
|
||||||
subsign: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var ui_main = {
|
|
||||||
rows: [
|
|
||||||
{view: 'toolbar', padding: 3, elements: [
|
|
||||||
{view: 'button', type: 'icon', icon: 'bars',
|
|
||||||
width: 37, align: 'left', css: 'app_button', click: function(){
|
|
||||||
$$('main_sidebar').toggle()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{view: 'label', id: 'lbl_title_main', label: '<b>Empresa Libre</b>'},
|
|
||||||
{},
|
|
||||||
menu_user,
|
|
||||||
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
|
||||||
icon: 'bell-o', badge: 0},
|
|
||||||
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
|
||||||
icon: 'cogs', id: 'cmd_ir_al_admin', hidden: true,
|
|
||||||
click: 'cmd_ir_al_admin_click'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols:[
|
|
||||||
sidebar,
|
|
||||||
multi_main,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
Loading…
Reference in New Issue