forked from elmau/empresa-libre
Obtener estatus SAT
This commit is contained in:
parent
63c7b4e458
commit
f958227f56
|
@ -648,7 +648,7 @@ def _get_data_sat(path):
|
|||
if os.path.isfile(path):
|
||||
tree = etree.parse(path).getroot()
|
||||
else:
|
||||
tree = etree.fromstring(path)
|
||||
tree = etree.fromstring(path.encode())
|
||||
|
||||
data = {}
|
||||
emisor = escape(
|
||||
|
@ -673,7 +673,7 @@ def _get_data_sat(path):
|
|||
def get_status_sat(xml):
|
||||
data = _get_data_sat(xml)
|
||||
if not data:
|
||||
return
|
||||
return 'XML inválido'
|
||||
|
||||
URL = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl'
|
||||
client = Client(URL, transport=Transport(cache=SqliteCache()))
|
||||
|
|
|
@ -473,6 +473,11 @@ def timbra_xml(xml, auth):
|
|||
return result
|
||||
|
||||
|
||||
def get_sat(xml):
|
||||
from .pac import get_status_sat
|
||||
return get_status_sat(xml)
|
||||
|
||||
|
||||
class LIBO(object):
|
||||
HOST = 'localhost'
|
||||
PORT = '8100'
|
||||
|
|
|
@ -32,6 +32,9 @@ class StorageEngine(object):
|
|||
def send_email(self, values, session):
|
||||
return main.Facturas.send(values['id'], session['rfc'])
|
||||
|
||||
def _get_statussat(self, values):
|
||||
return main.Facturas.get_status_sat(values['id'])
|
||||
|
||||
def _get_filteryears(self, values):
|
||||
return main.Facturas.filter_years()
|
||||
|
||||
|
|
|
@ -1004,6 +1004,7 @@ class Facturas(BaseModel):
|
|||
xml = TextField(default='')
|
||||
uuid = UUIDField(null=True)
|
||||
estatus = TextField(default='Guardada')
|
||||
estatus_sat = TextField(default='Vigente')
|
||||
regimen_fiscal = TextField(default='')
|
||||
notas = TextField(default='')
|
||||
pagada = BooleanField(default=False)
|
||||
|
@ -1472,6 +1473,13 @@ class Facturas(BaseModel):
|
|||
}
|
||||
return util.make_xml(data, certificado)
|
||||
|
||||
@classmethod
|
||||
def get_status_sat(cls, id):
|
||||
obj = Facturas.get(Facturas.id == id)
|
||||
obj.estatus_sat = util.get_sat(obj.xml)
|
||||
obj.save()
|
||||
return obj.estatus_sat
|
||||
|
||||
@classmethod
|
||||
def timbrar(cls, id):
|
||||
obj = Facturas.get(Facturas.id == id)
|
||||
|
|
|
@ -27,9 +27,7 @@ function get_series(){
|
|||
function get_forma_pago(){
|
||||
webix.ajax().get('/values/formapago', {key: true}, function(text, data){
|
||||
var values = data.json()
|
||||
//~ pre = values[0]
|
||||
$$('lst_forma_pago').getList().parse(values)
|
||||
//~ $$('lst_forma_pago').setValue(pre.id)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -775,3 +773,28 @@ function filter_dates_change(range){
|
|||
get_invoices(range)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function cmd_invoice_sat_click(){
|
||||
if(gi.count() == 0){
|
||||
return
|
||||
}
|
||||
|
||||
var row = gi.getSelectedItem()
|
||||
if (row == undefined){
|
||||
msg_error('Selecciona una factura')
|
||||
return
|
||||
}
|
||||
|
||||
if(!row.uuid){
|
||||
msg_error('La factura no esta timbrada, solo es posible consultar \
|
||||
el estatus en el SAT de facturas timbradas')
|
||||
return
|
||||
}
|
||||
|
||||
webix.ajax().get('/values/statussat', {id: row.id}, function(text, data){
|
||||
var values = data.json()
|
||||
show(values)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ var controllers = {
|
|||
$$('grid_details').attachEvent('onBeforeEditStart', grid_details_before_edit_start)
|
||||
$$('grid_details').attachEvent('onBeforeEditStop', grid_details_before_edit_stop)
|
||||
$$('cmd_invoice_timbrar').attachEvent('onItemClick', cmd_invoice_timbrar_click)
|
||||
$$('cmd_invoice_sat').attachEvent('onItemClick', cmd_invoice_sat_click)
|
||||
$$('cmd_invoice_cancelar').attachEvent('onItemClick', cmd_invoice_cancelar_click)
|
||||
$$('grid_invoices').attachEvent('onItemClick', grid_invoices_click)
|
||||
$$('filter_year').attachEvent('onChange', filter_year_change)
|
||||
|
|
|
@ -14,6 +14,8 @@ var toolbar_invoices = [
|
|||
var toolbar_invoices_util = [
|
||||
{view: 'button', id: 'cmd_invoice_timbrar', label: 'Timbrar',
|
||||
type: 'iconButton', autowidth: true, icon: 'ticket'},
|
||||
{view: 'button', id: 'cmd_invoice_sat', label: 'SAT',
|
||||
type: 'iconButton', autowidth: true, icon: 'check-circle'},
|
||||
{},
|
||||
{view: 'button', id: 'cmd_invoice_cancelar', label: 'Cancelar',
|
||||
type: 'iconButton', autowidth: true, icon: 'ban'},
|
||||
|
|
Loading…
Reference in New Issue