PDF de donativo
This commit is contained in:
parent
010ea37542
commit
8d878e3731
|
@ -822,6 +822,14 @@ class LIBO(object):
|
|||
image.Anchor = self._set_cell('{timbre.cbb}')
|
||||
return
|
||||
|
||||
def _donataria(self, data):
|
||||
if not data:
|
||||
return
|
||||
|
||||
for k, v in data.items():
|
||||
self._set_cell('{donataria.%s}' % k, v)
|
||||
return
|
||||
|
||||
def _render(self, data):
|
||||
self._set_search()
|
||||
self._es_pre = data.pop('es_pre', False)
|
||||
|
@ -831,6 +839,7 @@ class LIBO(object):
|
|||
self._conceptos(data['conceptos'])
|
||||
self._totales(data['totales'])
|
||||
self._timbre(data['timbre'])
|
||||
self._donataria(data['donataria'])
|
||||
self._cancelado(data['cancelada'])
|
||||
self._clean()
|
||||
return
|
||||
|
@ -856,14 +865,19 @@ class LIBO(object):
|
|||
return self._read(path)
|
||||
|
||||
|
||||
def to_pdf(data):
|
||||
def to_pdf(data, emisor_rfc):
|
||||
rfc = data['emisor']['rfc']
|
||||
if DEBUG:
|
||||
rfc = emisor_rfc
|
||||
version = data['comprobante']['version']
|
||||
|
||||
if APP_LIBO:
|
||||
app = LIBO()
|
||||
if app.is_running:
|
||||
name = '{}_{}.ods'.format(rfc, version)
|
||||
donativo = ''
|
||||
if data['donativo']:
|
||||
donativo = '_donativo'
|
||||
name = '{}_{}{}.ods'.format(rfc.lower(), version, donativo)
|
||||
path = get_template_ods(name)
|
||||
if path:
|
||||
return app.pdf(path, data)
|
||||
|
@ -1099,8 +1113,18 @@ def _timbre(doc, version, values):
|
|||
return data
|
||||
|
||||
|
||||
def _donataria(doc, version):
|
||||
node = doc.find('{}Complemento/{}Donatarias'.format(
|
||||
PRE[version], PRE['DONATARIA']))
|
||||
if node is None:
|
||||
return {}
|
||||
|
||||
data = CaseInsensitiveDict(node.attrib.copy())
|
||||
return data
|
||||
|
||||
|
||||
def get_data_from_xml(invoice, values):
|
||||
data = {'cancelada': invoice.cancelada}
|
||||
data = {'cancelada': invoice.cancelada, 'donativo': invoice.donativo}
|
||||
doc = parse_xml(invoice.xml)
|
||||
data['comprobante'] = _comprobante(doc, values)
|
||||
version = data['comprobante']['version']
|
||||
|
@ -1108,6 +1132,7 @@ def get_data_from_xml(invoice, values):
|
|||
data['receptor'] = _receptor(doc, version, values)
|
||||
data['conceptos'] = _conceptos(doc, version)
|
||||
data['totales'] = _totales(doc, data['comprobante'], version)
|
||||
data['donataria'] = _donataria(doc, version)
|
||||
|
||||
options = {
|
||||
'rfc_emisor': data['emisor']['rfc'],
|
||||
|
@ -1217,7 +1242,7 @@ def upload_file(rfc, opt, file_obj):
|
|||
msg = 'Extensión de archivo incorrecta, selecciona un archivo ODS'
|
||||
return {'status': 'server', 'name': msg, 'ok': False}
|
||||
|
||||
name = '{}_3.3_donataria.ods'.format(rfc.lower())
|
||||
name = '{}_3.3_donativo.ods'.format(rfc.lower())
|
||||
path = _join(PATH_MEDIA, 'templates', name)
|
||||
|
||||
if save_file(path, file_obj.file.read()):
|
||||
|
|
|
@ -153,7 +153,8 @@ class Configuracion(BaseModel):
|
|||
fields = (
|
||||
'txt_plantilla_factura_32',
|
||||
'txt_plantilla_factura_33',
|
||||
'txt_plantilla_factura_33j'
|
||||
'txt_plantilla_factura_33j',
|
||||
'txt_plantilla_donataria',
|
||||
)
|
||||
data = (Configuracion
|
||||
.select()
|
||||
|
@ -1928,6 +1929,7 @@ class Facturas(BaseModel):
|
|||
|
||||
@classmethod
|
||||
def get_pdf(cls, id, rfc):
|
||||
emisor = Emisor.select()[0]
|
||||
obj = Facturas.get(Facturas.id==id)
|
||||
name = '{}{}_{}.pdf'.format(obj.serie, obj.folio, obj.cliente.rfc)
|
||||
if obj.uuid is None:
|
||||
|
@ -1935,7 +1937,7 @@ class Facturas(BaseModel):
|
|||
|
||||
values = cls._get_not_in_xml(cls, obj)
|
||||
data = util.get_data_from_xml(obj, values)
|
||||
doc = util.to_pdf(data)
|
||||
doc = util.to_pdf(data, emisor.rfc)
|
||||
return doc, name
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -84,6 +84,7 @@ PRE = {
|
|||
'3.2': '{http://www.sat.gob.mx/cfd/3}',
|
||||
'3.3': '{http://www.sat.gob.mx/cfd/3}',
|
||||
'TIMBRE': '{http://www.sat.gob.mx/TimbreFiscalDigital}',
|
||||
'DONATARIA': '{http://www.sat.gob.mx/donat}',
|
||||
'NOMINA': {
|
||||
'1.1': '{http://www.sat.gob.mx/nomina}',
|
||||
'1.2': '{http://www.sat.gob.mx/nomina12}',
|
||||
|
|
|
@ -56,6 +56,14 @@
|
|||
|
||||
.webix_success div {
|
||||
background-color: #00a65a !important;
|
||||
font-size: 1vw;
|
||||
font-weight: bold;
|
||||
font-size: 1.5vw;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.webix_error div {
|
||||
background-color: #DF0101 !important;
|
||||
font-weight: bold;
|
||||
font-size: 1.5vw;
|
||||
color: white;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ function cmd_save_emisor_click(){
|
|||
success:function(text, data, XmlHttpRequest){
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
msg_sucess('Emisor guardado correctamente')
|
||||
msg_ok('Emisor guardado correctamente')
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ function up_cert_upload_complete(response){
|
|||
}
|
||||
|
||||
msg = 'Archivos subidos correctamente. Esperando validación'
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
|
||||
var values = $$('form_upload').getValues()
|
||||
$$('form_upload').setValues({})
|
||||
|
@ -507,7 +507,7 @@ function up_cert_upload_complete(response){
|
|||
var values = data.json()
|
||||
if(values.ok){
|
||||
$$('form_cert').setValues(values.data)
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ function cmd_agregar_serie_click(){
|
|||
{folio_serie: '', folio_inicio: 1, folio_usarcon: 'S'})
|
||||
grid.add(values.row)
|
||||
msg = 'Serie agregada correctamente'
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ function grid_folios_click(id, e, node){
|
|||
msg = 'Serie eliminada correctamente'
|
||||
if(xhr.status == 200){
|
||||
$$('grid_folios').remove(id.row)
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg = 'No se pudo eliminar'
|
||||
msg_error(msg)
|
||||
|
@ -658,7 +658,7 @@ function cmd_probar_correo_click(){
|
|||
if (values.ok){
|
||||
msg = 'Correo de prueba enviado correctamente. Ya puedes \
|
||||
guardar esta configuración'
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ function save_config_mail(values){
|
|||
var values = data.json();
|
||||
if (values.ok){
|
||||
msg = 'Configuración guardada correctamente'
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ function emisor_logo_click(id, e){
|
|||
|
||||
$$('up_emisor_logo').attachEvent('onUploadComplete', function(response){
|
||||
$$('emisor_logo').setValue(response.name)
|
||||
msg_sucess('Logotipo cargado correctamente')
|
||||
msg_ok('Logotipo cargado correctamente')
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ function txt_plantilla_factura_33_click(e){
|
|||
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||
if(response.ok){
|
||||
$$('txt_plantilla_factura_33').setValue(response.name)
|
||||
msg_sucess('Plantilla cargada correctamente')
|
||||
msg_ok('Plantilla cargada correctamente')
|
||||
}else{
|
||||
msg_error(response.name)
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ function txt_plantilla_factura_32_click(e){
|
|||
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||
if(response.ok){
|
||||
$$('txt_plantilla_factura_32').setValue(response.name)
|
||||
msg_sucess('Plantilla cargada correctamente')
|
||||
msg_ok('Plantilla cargada correctamente')
|
||||
}else{
|
||||
msg_error(response.name)
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ function txt_plantilla_factura_33j_click(e){
|
|||
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||
if(response.ok){
|
||||
$$('txt_plantilla_factura_33j').setValue(response.name)
|
||||
msg_sucess('Plantilla cargada correctamente')
|
||||
msg_ok('Plantilla cargada correctamente')
|
||||
}else{
|
||||
msg_error(response.name)
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ function txt_plantilla_donataria_click(e){
|
|||
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||
if(response.ok){
|
||||
$$('txt_plantilla_donataria').setValue(response.name)
|
||||
msg_sucess('Plantilla cargada correctamente')
|
||||
msg_ok('Plantilla cargada correctamente')
|
||||
}else{
|
||||
msg_error(response.name)
|
||||
}
|
||||
|
@ -1188,10 +1188,10 @@ function borrar_impuesto(row){
|
|||
msg = 'Impuesto eliminado correctamente'
|
||||
if(xhr.status == 200){
|
||||
grid.remove(row)
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg = 'Impuesto en uso, no se pudo eliminar.'
|
||||
msg_sucess(msg)
|
||||
msg_error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1226,7 +1226,7 @@ function eliminar_cuenta_banco(id){
|
|||
msg = 'Cuenta eliminada correctamente'
|
||||
if(xhr.status == 200){
|
||||
grid.remove(id)
|
||||
msg_sucess(msg)
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg = 'No se pudo eliminar'
|
||||
msg_error(msg)
|
||||
|
|
|
@ -566,7 +566,7 @@ function cancelar_movimiento(id){
|
|||
if(xhr.status == 200){
|
||||
get_estado_cuenta()
|
||||
get_saldo_cuenta()
|
||||
msg_sucess('Movimiento cancelado correctamente')
|
||||
msg_ok('Movimiento cancelado correctamente')
|
||||
}else{
|
||||
msg_error('No se pudo eliminar')
|
||||
}
|
||||
|
@ -590,12 +590,12 @@ function cmd_cancelar_movimiento_click(){
|
|||
var msg = '¿Estás seguro de cancelar el movimiento seleccionado?'
|
||||
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER<BR><BR>'
|
||||
webix.confirm({
|
||||
title:'Cancelar Movimiento',
|
||||
ok:'Si',
|
||||
cancel:'No',
|
||||
type:'confirm-error',
|
||||
text:msg,
|
||||
callback:function(result){
|
||||
title: 'Cancelar Movimiento',
|
||||
ok: 'Si',
|
||||
cancel: 'No',
|
||||
type: 'confirm-error',
|
||||
text: msg,
|
||||
callback: function(result){
|
||||
if (result){
|
||||
cancelar_movimiento(row['id'])
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ function delete_invoice(id){
|
|||
webix.ajax().del('/invoices', {id: id}, function(text, xml, xhr){
|
||||
if(xhr.status == 200){
|
||||
gi.remove(id)
|
||||
msg_sucess('Factura eliminada correctamente')
|
||||
msg_ok('Factura eliminada correctamente')
|
||||
}else{
|
||||
msg_error('No se pudo eliminar')
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ function send_anticipo_egreso(id){
|
|||
webix.ajax().get('/values/anticipoegreso', {id: id}, function(text, data){
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
gi.add(values.row)
|
||||
}else{
|
||||
webix.alert({
|
||||
|
@ -377,7 +377,7 @@ function send_timbrar(id){
|
|||
webix.ajax().get('/values/timbrar', {id: id}, function(text, data){
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
gi.updateItem(id, values.row)
|
||||
if(values.anticipo){
|
||||
//~ generar_anticipo_egreso(id)
|
||||
|
@ -407,7 +407,7 @@ function save_invoice(data){
|
|||
success:function(text, data, XmlHttpRequest){
|
||||
values = data.json();
|
||||
if(values.ok){
|
||||
msg_sucess('Factura guardada correctamente. Enviando a timbrar')
|
||||
msg_ok('Factura guardada correctamente. Enviando a timbrar')
|
||||
update_grid_invoices(values)
|
||||
gi.select(values.row['id'], false)
|
||||
send_timbrar(values.row['id'])
|
||||
|
@ -442,7 +442,7 @@ function save_preinvoice(data){
|
|||
success:function(text, data, XmlHttpRequest){
|
||||
values = data.json();
|
||||
if(values.ok){
|
||||
msg_sucess('Pre Factura generada correctamente')
|
||||
msg_ok('Pre Factura generada correctamente')
|
||||
result = true
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
|
@ -530,7 +530,7 @@ function cmd_timbrar_click(id, e, node){
|
|||
var form = this.getFormView();
|
||||
|
||||
if(!form.validate()) {
|
||||
webix.message({type:'error', text:'Valores inválidos'})
|
||||
msg_error('Valores inválidos')
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ function search_client_by_id(id){
|
|||
var msg = ''
|
||||
webix.ajax().get('/values/client', {'id': id}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr){
|
||||
var values = data.json()
|
||||
|
@ -581,7 +581,7 @@ function search_client_by_id(id){
|
|||
set_client(values.row)
|
||||
}else{
|
||||
msg = 'No se encontró un cliente con la clave: ' + id
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -612,7 +612,7 @@ function search_client_id_key_press(code, e){
|
|||
if(code == 13 && value.length > 0){
|
||||
var id = parseInt(value, 10)
|
||||
if (isNaN(id)){
|
||||
webix.message({type:'error', text:'Captura una clave válida'});
|
||||
msg_error('Captura una clave válida')
|
||||
}else{
|
||||
search_client_by_id(id)
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ function search_product_by_id(id){
|
|||
|
||||
webix.ajax().get('/values/product', {'id': id}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr){
|
||||
var values = data.json()
|
||||
|
@ -738,7 +738,7 @@ function search_product_by_id(id){
|
|||
set_product(values)
|
||||
} else {
|
||||
msg = 'No se encontró un producto con la clave: ' + id
|
||||
webix.message({type: 'error', text: msg})
|
||||
msg_error(msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -751,7 +751,7 @@ function search_product_id_key_press(code, e){
|
|||
if(code == 13 && value.length > 0){
|
||||
var id = parseInt(value, 10)
|
||||
if (isNaN(id)){
|
||||
webix.message({type: 'error', text: 'Captura una clave válida'});
|
||||
msg_error('Captura una clave válida')
|
||||
}else{
|
||||
search_product_by_id(id)
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ function grid_details_before_edit_stop(state, editor){
|
|||
if(editor.column == 'descripcion'){
|
||||
if(!state.value.trim()){
|
||||
msg = 'La descripción no puede estar vacía'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
|
@ -788,7 +788,7 @@ function grid_details_before_edit_stop(state, editor){
|
|||
var cantidad = parseFloat(state.value)
|
||||
if(isNaN(cantidad)){
|
||||
msg = 'La cantidad debe ser un número'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
|
@ -803,7 +803,7 @@ function grid_details_before_edit_stop(state, editor){
|
|||
var valor_unitario = parseFloat(state.value)
|
||||
if(isNaN(valor_unitario)){
|
||||
msg = 'El valor unitario debe ser un número'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
|
@ -818,7 +818,7 @@ function grid_details_before_edit_stop(state, editor){
|
|||
var descuento = parseFloat(state.value)
|
||||
if(isNaN(descuento)){
|
||||
msg = 'El descuento debe ser un número'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
|
@ -928,7 +928,7 @@ function enviar_correo(row){
|
|||
success:function(text, data, XmlHttpRequest){
|
||||
values = data.json();
|
||||
if(values.ok){
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ function send_cancel(id){
|
|||
webix.ajax().get('/values/cancelinvoice', {id: id}, function(text, data){
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
gi.updateItem(id, values.row)
|
||||
}else{
|
||||
webix.alert({
|
||||
|
@ -1026,7 +1026,7 @@ function get_invoices(rango){
|
|||
|
||||
webix.ajax().get('/invoices', rango, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
@ -1163,7 +1163,7 @@ function get_prefacturas(){
|
|||
var grid = $$('grid_preinvoices')
|
||||
webix.ajax().get('/preinvoices', rango, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
@ -1197,7 +1197,7 @@ function delete_preinvoice(id){
|
|||
webix.ajax().del('/preinvoices', {id: id}, function(text, xml, xhr){
|
||||
if(xhr.status == 200){
|
||||
$$('grid_preinvoices').remove(id)
|
||||
msg_sucess('PreFactura eliminada correctamente')
|
||||
msg_ok('PreFactura eliminada correctamente')
|
||||
}else{
|
||||
msg_error('No se pudo eliminar')
|
||||
}
|
||||
|
@ -1330,7 +1330,7 @@ function enviar_prefactura(id){
|
|||
success:function(text, data, XmlHttpRequest){
|
||||
values = data.json();
|
||||
if(values.ok){
|
||||
msg_sucess(values.msg)
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
|
@ -1382,7 +1382,7 @@ function get_facturas_por_cliente(){
|
|||
|
||||
webix.ajax().get('/invoices', filters, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
@ -1449,7 +1449,7 @@ function cmd_limpiar_relacionados_click(){
|
|||
$$('grid_relacionados').clearAll()
|
||||
table_relaciones.clear()
|
||||
tipo_relacion = ''
|
||||
msg_sucess('Las relaciones han sido eliminadas')
|
||||
msg_ok('Las relaciones han sido eliminadas')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -1474,7 +1474,7 @@ function cmd_guardar_relacionados_click(){
|
|||
table_relaciones.clear()
|
||||
table_relaciones.insert(data)
|
||||
tipo_relacion = value
|
||||
msg_sucess('Relaciones guardadas correctamente')
|
||||
msg_ok('Relaciones guardadas correctamente')
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ function get_uso_cfdi_to_table(){
|
|||
function get_partners(){
|
||||
webix.ajax().get('/partners', {}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'});
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
@ -115,7 +115,7 @@ function get_products(){
|
|||
var grid = $$('grid_products')
|
||||
webix.ajax().get('/products', {}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error('Error al consultar')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
@ -166,7 +166,6 @@ function current_dates(){
|
|||
|
||||
|
||||
function multi_change(prevID, nextID){
|
||||
//~ webix.message(nextID)
|
||||
if(nextID == 'app_partners'){
|
||||
active = $$('multi_partners').getActiveId()
|
||||
if(active == 'partners_home'){
|
||||
|
|
|
@ -40,14 +40,14 @@ function cmd_edit_partner_click(id, e, node){
|
|||
|
||||
if (row == undefined){
|
||||
msg = 'Selecciona un Socio de Negocio'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
get_condicion_pago()
|
||||
|
||||
webix.ajax().get("/partners", {id: row['id']}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type:"error", text: "Error al consultar"})
|
||||
msg_error()
|
||||
},
|
||||
success: function(text, data, xhr){
|
||||
var values = data.json()
|
||||
|
@ -83,7 +83,7 @@ function cmd_delete_partner_click(id, e, node){
|
|||
|
||||
if (row == undefined){
|
||||
msg = 'Selecciona un Cliente o Proveedor'
|
||||
webix.message({type:'error', text: msg})
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -112,10 +112,10 @@ function delete_partner(id){
|
|||
var msg = 'Socio eliminado correctamente'
|
||||
if (xhr.status == 200){
|
||||
$$('grid_partners').remove(id);
|
||||
webix.message({type: 'success', text: msg})
|
||||
msg_ok(msg)
|
||||
} else {
|
||||
msg = 'No se pudo eliminar. Asegurate de que no tenga documentos relacionados'
|
||||
webix.message({type: 'error', text: msg})
|
||||
msg_error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ function cmd_save_partner_click(id, e, node){
|
|||
var form = this.getFormView();
|
||||
|
||||
if (!form.validate()) {
|
||||
webix.message({type: 'error', text: msg})
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -148,14 +148,14 @@ function cmd_save_partner_click(id, e, node){
|
|||
webix.ajax().post('/partners', values, {
|
||||
error:function(text, data, XmlHttpRequest){
|
||||
msg = 'Ocurrio un error, consulta a soporte técnico';
|
||||
webix.message({type:'error', text:msg});
|
||||
msg_error(msg)
|
||||
},
|
||||
success:function(text, data, XmlHttpRequest){
|
||||
var values = data.json();
|
||||
if (values.ok) {
|
||||
update_grid_partner(values)
|
||||
} else {
|
||||
webix.message({type:'error', text:values.msg});
|
||||
msg_error(msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -173,7 +173,7 @@ function update_grid_partner(values){
|
|||
$$("grid_partners").updateItem(values.row['id'], values.row)
|
||||
}
|
||||
$$('multi_partners').setValue('partners_home')
|
||||
webix.message({type:'success', text: msg})
|
||||
msg_ok(msg)
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,13 +193,13 @@ function postal_code_key_up(){
|
|||
if( value.length == 5 ){
|
||||
webix.ajax().get('/values/cp', {cp: value}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type:'error', text:'Error al consultar el C.P.'})
|
||||
msg_error('Error al consultar el C.P.')
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
if (values.estado == undefined){
|
||||
msg = 'No se encontró el C.P., asegurate de que sea correcto'
|
||||
webix.message({type:'error', text:msg})
|
||||
msg_error(msg)
|
||||
} else {
|
||||
$$('form_partner').setValues({
|
||||
estado: values.estado,
|
||||
|
|
|
@ -25,7 +25,7 @@ function cmd_edit_product_click(id, e, node){
|
|||
var grid = $$('grid_products')
|
||||
var row = grid.getSelectedItem()
|
||||
if(row == undefined){
|
||||
webix.message({type: 'error', text: 'Selecciona un Producto'})
|
||||
msg_error('Selecciona un Producto')
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ function cmd_edit_product_click(id, e, node){
|
|||
|
||||
webix.ajax().get('/products', {id:row['id']}, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al consultar'})
|
||||
msg_error()
|
||||
},
|
||||
success: function(text, data, xhr){
|
||||
var values = data.json()
|
||||
|
@ -56,10 +56,10 @@ function delete_product(id){
|
|||
var msg = 'Producto eliminado correctamente'
|
||||
if(xhr.status == 200){
|
||||
$$('grid_products').remove(id)
|
||||
webix.message({type:'success', text:msg})
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg = 'No se pudo eliminar'
|
||||
webix.message({type:'error', text:msg})
|
||||
msg_error(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ function delete_product(id){
|
|||
function cmd_delete_product_click(id, e, node){
|
||||
var row = $$('grid_products').getSelectedItem()
|
||||
if (row == undefined){
|
||||
webix.message({type:'error', text: 'Selecciona un Producto'})
|
||||
msg_error('Selecciona un Producto')
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ function update_grid_products(values){
|
|||
$$("grid_products").updateItem(values.row['id'], values.row)
|
||||
}
|
||||
$$('multi_products').setValue('products_home')
|
||||
webix.message({type: 'success', text: msg})
|
||||
msg_ok(msg)
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,20 +126,20 @@ function cmd_save_product_click(id, e, node){
|
|||
var form = this.getFormView()
|
||||
|
||||
if(!form.validate()){
|
||||
webix.message({type: 'error', text: 'Valores inválidos'})
|
||||
msg_error('Valores inválidos')
|
||||
return
|
||||
}
|
||||
|
||||
var rows = $$('grid_product_taxes').getSelectedId(true, true)
|
||||
if (rows.length == 0){
|
||||
webix.message({type: 'error', text: 'Selecciona un impuesto'})
|
||||
msg_error('Selecciona un impuesto')
|
||||
return
|
||||
}
|
||||
|
||||
var values = form.getValues();
|
||||
|
||||
if (!validate_sat_key_product(values.clave_sat, false)){
|
||||
webix.message({ type:'error', text:'La clave SAT no existe' })
|
||||
msg_error('La clave SAT no existe')
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -147,14 +147,14 @@ function cmd_save_product_click(id, e, node){
|
|||
webix.ajax().sync().post('products', values, {
|
||||
error:function(text, data, XmlHttpRequest){
|
||||
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||
webix.message({type: 'error', text: msg})
|
||||
msg_error(msg)
|
||||
},
|
||||
success:function(text, data, XmlHttpRequest){
|
||||
var values = data.json();
|
||||
if (values.ok) {
|
||||
update_grid_products(values)
|
||||
}else{
|
||||
webix.message({type:'error', text:values.msg})
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -192,7 +192,7 @@ function chk_automatica_change(new_value, old_value){
|
|||
function get_new_key(){
|
||||
webix.ajax().get('/values/newkey', {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type:'error', text: text})
|
||||
msg_error(text)
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
|
|
|
@ -56,12 +56,15 @@ function show(nombre, value){
|
|||
|
||||
|
||||
function msg_error(msg){
|
||||
if(!msg){
|
||||
msg = 'Error al consultar'
|
||||
}
|
||||
webix.message({type: 'error', text: msg})
|
||||
}
|
||||
|
||||
|
||||
function msg_sucess(msg){
|
||||
webix.message({type: 'sucess', text: msg})
|
||||
function msg_ok(msg){
|
||||
webix.message({type: 'success', text: msg})
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,7 +122,7 @@ webix.ui.datafilter.rowCount = webix.extend({
|
|||
function validate_rfc(value){
|
||||
rfc = value.trim().toUpperCase();
|
||||
if ( rfc == ""){
|
||||
webix.message({ type:"error", text:"El RFC no puede estar vacío" });
|
||||
msg_error('El RFC no puede estar vacío')
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -131,41 +134,41 @@ function validate_rfc(value){
|
|||
start = 2
|
||||
}
|
||||
if (rfc.length != length){
|
||||
webix.message({ type:"error", text:"Longitud incorrecta del RFC" });
|
||||
msg_error('Longitud incorrecta del RFC')
|
||||
return false
|
||||
}
|
||||
if (tipo_persona < 3 && (rfc == RFC_PUBLICO || rfc == RFC_EXTRANJERO)){
|
||||
webix.message({ type:"error", text:"RFC incorrecto" });
|
||||
msg_error('RFC incorrecto')
|
||||
return false
|
||||
}
|
||||
|
||||
var part = rfc.slice(0, start);
|
||||
var re = new RegExp('[a-z&Ñ]{' + start + '}', 'i');
|
||||
if (!part.match(re)){
|
||||
webix.message({ type:"error", text: "El RFC tiene caractéres inválidos al inicio" });
|
||||
msg_error('El RFC tiene caractéres inválidos al inicio')
|
||||
return false
|
||||
}
|
||||
part = rfc.slice(-3);
|
||||
re = new RegExp('[a-z0-9]{3}', 'i');
|
||||
if (!part.match(re)){
|
||||
webix.message({ type:"error", text: "El RFC tiene caractéres inválidos al final" });
|
||||
msg_error('El RFC tiene caractéres inválidos al final')
|
||||
return false
|
||||
}
|
||||
|
||||
part = rfc.slice(-9, -3);
|
||||
re = new RegExp('[0-9]{6}', 'i');
|
||||
if (!part.match(re)){
|
||||
webix.message({ type:"error", text: "Fecha inválida" });
|
||||
msg_error('Fecha inválida')
|
||||
return false
|
||||
}
|
||||
var month = parseInt(part.slice(-4, -2))
|
||||
if (month == 0 || month > 12 ){
|
||||
webix.message({ type:"error", text: "Fecha inválida" });
|
||||
msg_error('Fecha inválida')
|
||||
return false
|
||||
}
|
||||
var day = parseInt(part.slice(-2))
|
||||
if (day == 0 || day > 31 ){
|
||||
webix.message({ type:"error", text: "Fecha inválida" });
|
||||
msg_error('Fecha inválida')
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -615,8 +615,3 @@ var app_invoices = {
|
|||
multi_invoices
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue