Verificar XML en el SAT
This commit is contained in:
parent
a1a17732e8
commit
cb7b7b0a1c
|
@ -110,6 +110,9 @@ class StorageEngine(object):
|
|||
def _get_statussat(self, values):
|
||||
return main.Facturas.get_status_sat(values['id'])
|
||||
|
||||
def _get_verifysat(self, values):
|
||||
return main.Facturas.get_verify_sat(values['id'])
|
||||
|
||||
def _get_filteryears(self, values):
|
||||
years1 = main.Facturas.filter_years()
|
||||
years2 = main.PreFacturas.filter_years()
|
||||
|
|
|
@ -3979,9 +3979,30 @@ class Facturas(BaseModel):
|
|||
@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
|
||||
estatus_sat = util.get_sat(obj.xml)
|
||||
if obj.estatus_sat != estatus_sat:
|
||||
obj.estatus_sat = estatus_sat
|
||||
obj.save()
|
||||
return estatus_sat
|
||||
|
||||
@classmethod
|
||||
def get_verify_sat(cls, id):
|
||||
emisor = Emisor.select()[0].rfc
|
||||
obj = Facturas.get(Facturas.id == id)
|
||||
xml = util.parse_xml(obj.xml)
|
||||
sello = xml.attrib.get('sello', xml.attrib.get('Sello'))[-8:]
|
||||
data = {
|
||||
'url': 'https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?',
|
||||
'uuid': '&id={}'.format(obj.uuid),
|
||||
'emisor': '&re={}'.format(emisor),
|
||||
'receptor': '&rr={}'.format(obj.cliente.rfc),
|
||||
'total': '&tt={}'.format(str(obj.total)),
|
||||
'sello': '&fe={}'.format(sello),
|
||||
}
|
||||
result = {
|
||||
'url': '{url}{uuid}{emisor}{receptor}{total}{sello}'.format(**data)
|
||||
}
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def anticipo_egreso(cls, id):
|
||||
|
|
|
@ -29,6 +29,7 @@ var invoices_controllers = {
|
|||
$$('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_verify_sat').attachEvent('onItemClick', cmd_invoice_verify_sat_click)
|
||||
$$('cmd_invoice_cancelar').attachEvent('onItemClick', cmd_invoice_cancelar_click)
|
||||
$$('grid_invoices').attachEvent('onItemClick', grid_invoices_click)
|
||||
$$('grid_invoices').attachEvent('onSelectChange', grid_invoices_on_select_change)
|
||||
|
@ -2022,3 +2023,28 @@ function up_invoice_upload_complete(response){
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
function cmd_invoice_verify_sat_click(){
|
||||
var rows = gi.getSelectedItem(true)
|
||||
|
||||
if (rows.length == 0){
|
||||
msg_error('Selecciona una factura')
|
||||
return
|
||||
}
|
||||
|
||||
if (rows.length > 1){
|
||||
msg_error('Selecciona solo una factura')
|
||||
return
|
||||
}
|
||||
|
||||
if(!rows[0].uuid){
|
||||
msg_error('La factura no esta timbrada, solo es posible verificar \
|
||||
en el SAT, facturas timbradas')
|
||||
return
|
||||
}
|
||||
|
||||
webix.ajax().get('/values/verifysat', {id: rows[0].id}, function(text, data){
|
||||
var values = data.json()
|
||||
window.open(values.url, '_blank')
|
||||
})
|
||||
}
|
|
@ -190,6 +190,8 @@ var toolbar_invoices_util = [
|
|||
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_verify_sat', label: 'SAT',
|
||||
type: 'iconButton', autowidth: true, icon: 'firefox'},
|
||||
{},
|
||||
{view: 'button', id: 'cmd_invoice_cancelar', label: 'Cancelar',
|
||||
type: 'iconButton', autowidth: true, icon: 'ban'},
|
||||
|
|
Loading…
Reference in New Issue