2018-09-16 00:34:35 -05:00
|
|
|
//~ Empresa Libre
|
|
|
|
//~ Copyright (C) 2016-2018 Mauricio Baeza Servin (web@correolibre.net)
|
|
|
|
//~
|
|
|
|
//~ This program is free software: you can redistribute it and/or modify
|
|
|
|
//~ it under the terms of the GNU General Public License as published by
|
|
|
|
//~ the Free Software Foundation, either version 3 of the License, or
|
|
|
|
//~ (at your option) any later version.
|
|
|
|
//~
|
|
|
|
//~ This program is distributed in the hope that it will be useful,
|
|
|
|
//~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
//~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
//~ GNU General Public License for more details.
|
|
|
|
//~
|
|
|
|
//~ You should have received a copy of the GNU General Public License
|
|
|
|
//~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
var cfg_partners = new Object()
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
|
2017-12-30 17:15:08 -06:00
|
|
|
var partners_controllers = {
|
|
|
|
init: function(){
|
|
|
|
$$('cmd_new_partner').attachEvent('onItemClick', cmd_new_partner_click);
|
2018-10-08 01:13:46 -05:00
|
|
|
//~ $$('cmd_new_contact').attachEvent('onItemClick', cmd_new_contact_click);
|
2017-12-30 17:15:08 -06:00
|
|
|
$$('cmd_edit_partner').attachEvent('onItemClick', cmd_edit_partner_click);
|
|
|
|
$$('cmd_delete_partner').attachEvent('onItemClick', cmd_delete_partner_click);
|
|
|
|
$$('cmd_save_partner').attachEvent('onItemClick', cmd_save_partner_click);
|
|
|
|
$$('cmd_cancel_partner').attachEvent('onItemClick', cmd_cancel_partner_click);
|
2018-10-08 01:13:46 -05:00
|
|
|
//~ $$('cmd_cancel_contact').attachEvent('onItemClick', cmd_cancel_contact_click);
|
2018-09-16 00:34:35 -05:00
|
|
|
//~ $$('cmd_partner_zero').attachEvent('onItemClick', cmd_partner_zero_click);
|
2017-12-30 17:15:08 -06:00
|
|
|
$$('codigo_postal').attachEvent('onKeyPress', postal_code_key_press);
|
|
|
|
$$('codigo_postal').attachEvent('onTimedKeyPress', postal_code_key_up);
|
|
|
|
$$('colonia').attachEvent('onFocus', colonia_on_focus)
|
|
|
|
$$("tipo_persona").attachEvent( "onChange", opt_tipo_change)
|
|
|
|
$$("es_cliente").attachEvent( "onChange", is_client_change)
|
|
|
|
$$("es_proveedor").attachEvent( "onChange", is_supplier_change)
|
|
|
|
$$("rfc").attachEvent( "onBlur", rfc_lost_focus)
|
|
|
|
$$('multi').attachEvent('onViewChange', multi_change)
|
2018-09-16 00:34:35 -05:00
|
|
|
$$('grid_partners').attachEvent('onItemDblClick', grid_partners_double_click)
|
|
|
|
//~ $$('grid_partners').attachEvent('onSelectChange', grid_partners_on_select_change)
|
|
|
|
|
|
|
|
$$('partner_balance').attachEvent('onChange', partner_balance_on_change)
|
2018-10-08 01:13:46 -05:00
|
|
|
$$('cmd_partner_add_account_bank').attachEvent('onItemClick', cmd_partner_add_account_bank_click)
|
|
|
|
$$('grid_partner_account_bank').attachEvent('onItemClick', grid_partner_account_bank_click)
|
2018-09-16 00:34:35 -05:00
|
|
|
default_config_partners()
|
2017-12-30 17:15:08 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-16 00:34:35 -05:00
|
|
|
function default_config_partners(){
|
|
|
|
webix.ajax().get('/config', {'fields': 'partners'}, {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
msg = 'Error al consultar'
|
|
|
|
msg_error(msg)
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json()
|
|
|
|
cfg_partners = values
|
|
|
|
//~ show('cmd_partner_zero', cfg_partners['chk_config_change_balance_partner'])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-02 23:24:31 -06:00
|
|
|
function get_condicion_pago(){
|
|
|
|
webix.ajax().get('/values/condicionespago', {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json();
|
|
|
|
$$('condicion_pago').define('suggest', values)
|
|
|
|
$$('condicion_pago').refresh()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
function cmd_new_partner_click(id, e, node){
|
2018-09-16 00:34:35 -05:00
|
|
|
$$('form_partner').clearValidation()
|
2018-10-08 14:13:16 -05:00
|
|
|
$$('form_partner_account_bank').clearValidation()
|
|
|
|
|
2017-06-27 23:58:03 -05:00
|
|
|
$$('form_partner').setValues({
|
2018-09-16 00:34:35 -05:00
|
|
|
id: 0, pais: 'México', tipo_persona: 1, es_activo: true,
|
|
|
|
partner_balance: 0.00})
|
2017-10-02 00:12:22 -05:00
|
|
|
$$('forma_pago').getList().load('/values/formapago')
|
2017-11-02 23:24:31 -06:00
|
|
|
get_condicion_pago()
|
2017-06-27 23:58:03 -05:00
|
|
|
$$('grid_partners').clearSelection()
|
|
|
|
$$('multi_partners').setValue('partners_new')
|
2017-10-02 20:34:30 -05:00
|
|
|
$$('tab_partner').setValue('Datos Fiscales')
|
2017-10-06 00:10:27 -05:00
|
|
|
|
2017-11-12 21:56:45 -06:00
|
|
|
get_uso_cfdi_to_table()
|
2017-10-06 00:10:27 -05:00
|
|
|
query = table_usocfdi.chain().find({fisica: true}).data()
|
|
|
|
$$('lst_uso_cfdi_socio').getList().parse(query)
|
2018-09-16 00:34:35 -05:00
|
|
|
$$('partner_balance').define('readonly', !cfg_partners['chk_config_change_balance_partner'])
|
2018-10-08 01:13:46 -05:00
|
|
|
get_partner_banks()
|
|
|
|
get_partner_accounts_bank(0)
|
2022-03-10 20:29:50 -06:00
|
|
|
get_sat_regimenes()
|
2017-10-06 00:10:27 -05:00
|
|
|
}
|
2017-06-27 23:58:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
function cmd_new_contact_click(id, e, node){
|
|
|
|
$$('grid_contacts').clearSelection()
|
|
|
|
$$('multi_contacts').setValue('contacts_new')
|
2017-10-06 00:10:27 -05:00
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
|
2017-12-30 17:15:08 -06:00
|
|
|
function cmd_edit_partner_click(){
|
2017-10-02 20:34:30 -05:00
|
|
|
var msg = ''
|
|
|
|
var row = $$('grid_partners').getSelectedItem()
|
|
|
|
|
2022-03-10 20:29:50 -06:00
|
|
|
get_sat_regimenes()
|
|
|
|
|
2018-10-08 14:13:16 -05:00
|
|
|
$$('form_partner_account_bank').clearValidation()
|
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
if (row == undefined){
|
2017-10-02 20:34:30 -05:00
|
|
|
msg = 'Selecciona un Socio de Negocio'
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
return
|
2017-10-02 20:34:30 -05:00
|
|
|
}
|
2017-11-02 23:24:31 -06:00
|
|
|
get_condicion_pago()
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-10-07 00:16:58 -05:00
|
|
|
webix.ajax().get("/partners", {id: row['id']}, {
|
2017-06-27 15:43:02 -05:00
|
|
|
error: function(text, data, xhr) {
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error()
|
2017-06-27 15:43:02 -05:00
|
|
|
},
|
|
|
|
success: function(text, data, xhr){
|
2017-10-07 00:16:58 -05:00
|
|
|
var values = data.json()
|
2018-09-16 00:34:35 -05:00
|
|
|
$$('form_partner').clearValidation()
|
2017-10-02 20:34:30 -05:00
|
|
|
$$('form_partner').setValues(values)
|
|
|
|
$$('forma_pago').getList().load('/values/formapago')
|
2017-10-07 00:16:58 -05:00
|
|
|
|
2018-09-16 00:34:35 -05:00
|
|
|
$$('partner_balance').define('readonly', !cfg_partners['chk_config_change_balance_partner'])
|
2017-11-12 21:56:45 -06:00
|
|
|
get_uso_cfdi_to_table()
|
2018-09-16 00:34:35 -05:00
|
|
|
|
2017-10-07 00:16:58 -05:00
|
|
|
if(values.tipo_persona == 1){
|
|
|
|
query = table_usocfdi.chain().find({fisica: true}).data()
|
|
|
|
}else if(values.tipo_persona == 2){
|
|
|
|
query = table_usocfdi.chain().find({moral: true}).data()
|
|
|
|
}else{
|
|
|
|
query = [{id: 'P01', value: 'Por definir'}]
|
|
|
|
}
|
|
|
|
$$('lst_uso_cfdi_socio').getList().parse(query)
|
2017-10-07 23:52:11 -05:00
|
|
|
if(values.es_cliente){
|
|
|
|
$$('cuenta_cliente').enable()
|
|
|
|
}
|
|
|
|
if(values.es_proveedor){
|
|
|
|
$$('cuenta_proveedor').enable()
|
|
|
|
}
|
2018-10-08 01:13:46 -05:00
|
|
|
get_partner_accounts_bank(row['id'])
|
2022-03-10 20:29:50 -06:00
|
|
|
$$('lst_receptor_regimenes_fiscales').select(values.regimenes)
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
2017-10-02 20:34:30 -05:00
|
|
|
})
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-10-02 20:34:30 -05:00
|
|
|
$$('multi_partners').setValue('partners_new')
|
|
|
|
$$('tab_partner').setValue('Datos Fiscales')
|
2018-10-08 01:13:46 -05:00
|
|
|
get_partner_banks()
|
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
function cmd_delete_partner_click(id, e, node){
|
2017-10-02 20:34:30 -05:00
|
|
|
var msg = ''
|
|
|
|
var row = $$('grid_partners').getSelectedItem()
|
|
|
|
|
2017-06-27 15:43:02 -05:00
|
|
|
if (row == undefined){
|
2017-10-02 20:34:30 -05:00
|
|
|
msg = 'Selecciona un Cliente o Proveedor'
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
return
|
2017-10-02 20:34:30 -05:00
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-10-02 20:34:30 -05:00
|
|
|
msg = '¿Estás seguro de eliminar al cliente?<BR><BR>'
|
|
|
|
msg += row['nombre'] + ' (' + row['rfc'] + ')'
|
|
|
|
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER<BR><BR>'
|
|
|
|
msg += 'Solo se pueden eliminar clientes o proveedores sin documentos '
|
|
|
|
msg += 'relacionados. Se recomienda solo desactivar en vez de eliminar'
|
2017-06-27 15:43:02 -05:00
|
|
|
webix.confirm({
|
|
|
|
title:'Eliminar Cliente',
|
|
|
|
ok:'Si',
|
|
|
|
cancel:'No',
|
|
|
|
type:'confirm-error',
|
|
|
|
text:msg,
|
|
|
|
callback:function(result){
|
|
|
|
if (result){
|
|
|
|
delete_partner(row['id'])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function delete_partner(id){
|
2017-10-02 20:34:30 -05:00
|
|
|
webix.ajax().del('/partners', {id: id}, function(text, xml, xhr){
|
|
|
|
var msg = 'Socio eliminado correctamente'
|
2017-06-27 15:43:02 -05:00
|
|
|
if (xhr.status == 200){
|
|
|
|
$$('grid_partners').remove(id);
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_ok(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
} else {
|
2017-10-02 20:34:30 -05:00
|
|
|
msg = 'No se pudo eliminar. Asegurate de que no tenga documentos relacionados'
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
2017-10-02 20:34:30 -05:00
|
|
|
})
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cmd_save_partner_click(id, e, node){
|
2017-10-02 20:34:30 -05:00
|
|
|
var msg = 'Valores inválidos'
|
2017-06-27 15:43:02 -05:00
|
|
|
var form = this.getFormView();
|
|
|
|
|
|
|
|
if (!form.validate()) {
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var values = form.getValues();
|
2017-10-02 20:34:30 -05:00
|
|
|
|
2018-09-16 00:34:35 -05:00
|
|
|
if(!values.rfc){
|
|
|
|
msg = 'Captura el RFC'
|
|
|
|
msg_error(msg)
|
|
|
|
$$('tab_partner').setValue('Datos Fiscales')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-03-20 22:51:08 -06:00
|
|
|
if(values.tipo_persona != 4){
|
|
|
|
if(values.codigo_postal && values.codigo_postal.length != 5){
|
|
|
|
msg = 'Longitud inválida del C.P.'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
2017-10-07 23:52:11 -05:00
|
|
|
}
|
|
|
|
|
2017-10-02 20:34:30 -05:00
|
|
|
if (!values.es_cliente && !values.es_proveedor){
|
|
|
|
msg = 'Selecciona si es cliente, proveedor o ambos'
|
2017-10-07 23:52:11 -05:00
|
|
|
msg_error(msg)
|
2017-10-02 20:34:30 -05:00
|
|
|
$$('tab_partner').setValue('Otros Datos')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-02-17 21:33:02 -06:00
|
|
|
if(values.tipo_persona == 4){
|
|
|
|
if(values.pais && values.pais.length != 3){
|
|
|
|
msg = 'Longitud de país inválida'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-10 20:29:50 -06:00
|
|
|
var ids_regimenes = $$('lst_receptor_regimenes_fiscales').getSelectedId()
|
|
|
|
if(values.tipo_persona < 3){
|
|
|
|
if(!ids_regimenes){
|
|
|
|
msg = 'Selecciona al menos un Regimen Fiscal'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-08 14:13:16 -05:00
|
|
|
values['accounts'] = $$('grid_partner_account_bank').data.getRange()
|
2022-03-10 20:29:50 -06:00
|
|
|
values['regimenes'] = ids_regimenes
|
2018-10-08 14:13:16 -05:00
|
|
|
|
2017-06-28 23:55:53 -05:00
|
|
|
webix.ajax().post('/partners', values, {
|
2017-06-27 15:43:02 -05:00
|
|
|
error:function(text, data, XmlHttpRequest){
|
|
|
|
msg = 'Ocurrio un error, consulta a soporte técnico';
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
},
|
|
|
|
success:function(text, data, XmlHttpRequest){
|
|
|
|
var values = data.json();
|
|
|
|
if (values.ok) {
|
|
|
|
update_grid_partner(values)
|
|
|
|
} else {
|
2017-12-25 23:30:34 -06:00
|
|
|
msg_error(values.msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
|
|
|
}
|
2017-10-02 20:34:30 -05:00
|
|
|
})
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-10-02 20:34:30 -05:00
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
function update_grid_partner(values){
|
2017-10-02 22:21:51 -05:00
|
|
|
var msg = 'Socio de negocio agregado correctamente'
|
2017-06-27 15:43:02 -05:00
|
|
|
if (values.new){
|
|
|
|
$$('form_partner').clear()
|
|
|
|
$$('grid_partners').add(values.row)
|
|
|
|
}else{
|
2017-10-02 22:21:51 -05:00
|
|
|
msg = 'Socio de negocio actualizado correctamente'
|
2017-06-27 15:43:02 -05:00
|
|
|
$$("grid_partners").updateItem(values.row['id'], values.row)
|
|
|
|
}
|
|
|
|
$$('multi_partners').setValue('partners_home')
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_ok(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cmd_cancel_partner_click(id, e, node){
|
|
|
|
$$('multi_partners').setValue('partners_home')
|
2017-06-27 23:58:03 -05:00
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
2017-06-27 23:58:03 -05:00
|
|
|
|
|
|
|
function cmd_cancel_contact_click(id, e, node){
|
|
|
|
$$('multi_contacts').setValue('contacts_home')
|
|
|
|
}
|
2017-06-27 15:43:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
function postal_code_key_up(){
|
|
|
|
var value = this.getValue()
|
|
|
|
var msg = ''
|
|
|
|
if( value.length == 5 ){
|
2017-10-02 00:12:22 -05:00
|
|
|
webix.ajax().get('/values/cp', {cp: value}, {
|
2017-06-27 15:43:02 -05:00
|
|
|
error: function(text, data, xhr) {
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error('Error al consultar el C.P.')
|
2017-06-27 15:43:02 -05:00
|
|
|
},
|
|
|
|
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'
|
2017-11-25 20:26:15 -06:00
|
|
|
msg_error(msg)
|
2017-06-27 15:43:02 -05:00
|
|
|
} else {
|
|
|
|
$$('form_partner').setValues({
|
2017-10-02 00:12:22 -05:00
|
|
|
estado: values.estado,
|
2017-06-27 15:43:02 -05:00
|
|
|
municipio: values.municipio,
|
2017-10-02 00:12:22 -05:00
|
|
|
colonia: ''}, true)
|
2017-06-27 15:43:02 -05:00
|
|
|
$$('colonia').define('suggest', [])
|
|
|
|
if (webix.isArray(values.colonia)){
|
|
|
|
$$('colonia').define('suggest', values.colonia)
|
|
|
|
}else{
|
2017-10-02 00:12:22 -05:00
|
|
|
$$('form_partner').setValues({colonia: values.colonia}, true)
|
2017-06-27 15:43:02 -05:00
|
|
|
}
|
|
|
|
$$('colonia').refresh()
|
|
|
|
$$('form_partner').focus('colonia')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function postal_code_key_press(code, e){
|
|
|
|
var data = [8, 9, 37, 39, 46]
|
|
|
|
if ( data.indexOf(code) >= 0 ){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( code < 48 || code > 57){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function colonia_on_focus(){
|
|
|
|
if ($$(this.config.suggest).getList().config.height > 2){
|
|
|
|
$$(this.config.suggest).show(this.getInputNode())
|
|
|
|
}
|
|
|
|
}
|
2017-10-02 00:12:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
function opt_tipo_change(new_value, old_value){
|
|
|
|
|
|
|
|
$$("nombre").define("value", "")
|
|
|
|
$$("pais").define("readonly", true)
|
|
|
|
$$("pais").define("value", PAIS)
|
2018-02-17 21:33:02 -06:00
|
|
|
$$('id_fiscal').define('value', '')
|
|
|
|
show('id_fiscal', new_value == 4)
|
2017-10-06 00:10:27 -05:00
|
|
|
|
2022-03-10 20:29:50 -06:00
|
|
|
$$('lst_receptor_regimenes_fiscales').clearAll()
|
2022-04-05 22:05:16 -05:00
|
|
|
var regimen_616 = {id: 11, value: 'Sin obligaciones fiscales'}
|
2022-03-10 20:29:50 -06:00
|
|
|
|
2017-10-02 00:12:22 -05:00
|
|
|
if (new_value == 1 || new_value == 2){
|
2018-02-17 21:33:02 -06:00
|
|
|
$$("rfc").define("value", "")
|
|
|
|
$$("rfc").define("readonly", false)
|
2022-03-10 20:29:50 -06:00
|
|
|
moral = false
|
|
|
|
if(new_value == 2){
|
|
|
|
moral = true
|
|
|
|
}
|
|
|
|
get_sat_regimenes(moral)
|
2017-10-02 00:12:22 -05:00
|
|
|
} else if (new_value == 3) {
|
2018-02-17 21:33:02 -06:00
|
|
|
$$("rfc").define("value", RFC_PUBLICO)
|
|
|
|
$$("nombre").define("value", PUBLICO)
|
|
|
|
$$("rfc").define("readonly", true)
|
2022-04-05 22:05:16 -05:00
|
|
|
$$('lst_receptor_regimenes_fiscales').parse(regimen_616)
|
2017-10-02 00:12:22 -05:00
|
|
|
} else if (new_value == 4) {
|
2018-02-17 21:33:02 -06:00
|
|
|
$$("rfc").define("value", RFC_EXTRANJERO)
|
|
|
|
$$("rfc").define("readonly", true)
|
|
|
|
$$("pais").define("readonly", false)
|
|
|
|
$$("pais").define("value", "")
|
2022-04-05 22:05:16 -05:00
|
|
|
$$('lst_receptor_regimenes_fiscales').parse(regimen_616)
|
2017-10-02 00:12:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$$("nombre").refresh();
|
|
|
|
$$("rfc").refresh();
|
|
|
|
$$("pais").refresh();
|
|
|
|
if (new_value == 3) {
|
|
|
|
$$("calle").focus();
|
|
|
|
} else {
|
|
|
|
$$("rfc").focus();
|
|
|
|
}
|
2017-10-06 00:10:27 -05:00
|
|
|
|
|
|
|
$$('lst_uso_cfdi_socio').define('suggest', [])
|
|
|
|
if (new_value == 1){
|
|
|
|
query = table_usocfdi.chain().find({fisica: true}).data()
|
|
|
|
}else if (new_value == 2){
|
|
|
|
query = table_usocfdi.chain().find({moral: true}).data()
|
|
|
|
}else{
|
|
|
|
query = [{id: 'P01', value: 'Por definir'}]
|
|
|
|
}
|
|
|
|
$$('lst_uso_cfdi_socio').getList().parse(query)
|
|
|
|
$$('lst_uso_cfdi_socio').refresh()
|
2022-03-10 20:29:50 -06:00
|
|
|
|
|
|
|
|
2017-10-02 00:12:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function is_client_change(new_value, old_value){
|
|
|
|
var value = Boolean(new_value)
|
|
|
|
if (value){
|
|
|
|
$$("cuenta_cliente").enable();
|
|
|
|
} else {
|
|
|
|
$$("cuenta_cliente").disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function is_supplier_change(new_value, old_value){
|
|
|
|
var value = Boolean(new_value)
|
|
|
|
if (value){
|
2018-02-12 16:01:46 -06:00
|
|
|
$$("cuenta_proveedor").enable()
|
2017-10-02 00:12:22 -05:00
|
|
|
} else {
|
2018-02-12 16:01:46 -06:00
|
|
|
$$("cuenta_proveedor").disable()
|
2017-10-02 00:12:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function rfc_lost_focus(prev_view){
|
|
|
|
//~ var form = this.getFormView()
|
|
|
|
//~ var values = form.getValues()
|
|
|
|
|
|
|
|
//~ if (values.rfc.trim() == ""){
|
|
|
|
//~ return
|
|
|
|
//~ }
|
|
|
|
|
|
|
|
//~ if (values.id == undefined){
|
|
|
|
//~ exclude = ''
|
|
|
|
//~ } else {
|
|
|
|
//~ exclude = {'id': values.id}
|
|
|
|
//~ }
|
|
|
|
|
|
|
|
//~ values = {
|
|
|
|
//~ 'table': 'partner',
|
|
|
|
//~ 'filter': {'rfc': values.rfc.trim().toUpperCase()},
|
|
|
|
//~ 'exclude': exclude,
|
|
|
|
//~ }
|
|
|
|
//~ webix.message(values)
|
|
|
|
//~ webix.ajax().get("/values/validate", values, {
|
|
|
|
//~ error:function(text, data, XmlHttpRequest){
|
|
|
|
//~ msg = "No se pudo validar el RFC"
|
|
|
|
//~ webix.message({ type:"error", text: msg });
|
|
|
|
//~ },
|
|
|
|
//~ success:function(text, data, XmlHttpRequest){
|
|
|
|
//~ var values = data.json();
|
|
|
|
//~ if (values.exists) {
|
|
|
|
//~ msg = "El RFC ya existe"
|
|
|
|
//~ webix.message({ type:"error", text: msg });
|
|
|
|
//~ }
|
|
|
|
//~ }
|
|
|
|
//~ })
|
|
|
|
}
|
2017-10-02 20:34:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
function multi_partners_change(prevID, nextID){
|
2017-11-12 21:56:45 -06:00
|
|
|
//~ webix.message(prevID)
|
|
|
|
//~ webix.message(nextID)
|
2017-10-02 20:34:30 -05:00
|
|
|
}
|
2018-02-12 16:01:46 -06:00
|
|
|
|
|
|
|
|
2018-09-16 00:34:35 -05:00
|
|
|
function grid_partners_double_click(id, e, node){
|
|
|
|
//~ if(id.column!='saldo_cliente'){
|
|
|
|
cmd_edit_partner_click()
|
|
|
|
//~ }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function partner_balance_on_change(new_value, old_value){
|
|
|
|
if(!isFinite(new_value)){
|
|
|
|
this.config.value = old_value
|
|
|
|
this.refresh()
|
|
|
|
}
|
|
|
|
}
|
2018-10-08 01:13:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
function cmd_partner_add_account_bank_click(){
|
|
|
|
var form = $$('form_partner_account_bank')
|
|
|
|
|
|
|
|
if (!form.validate()){
|
|
|
|
msg = 'Valores inválidos'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var values = form.getValues()
|
|
|
|
var id_partner = $$('form_partner').getValues().id
|
|
|
|
|
|
|
|
var account = {
|
|
|
|
id_partner: id_partner,
|
|
|
|
delete: '-',
|
|
|
|
banco: $$('lst_partner_bank').getText(),
|
|
|
|
cuenta: values.partner_account.trim(),
|
|
|
|
clabe: values.partner_clabe.trim(),
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!account.cuenta){
|
|
|
|
msg = 'La cuenta es requerida'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!account.cuenta.is_number()){
|
|
|
|
msg = 'Solo digitos en la cuenta'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-12 01:14:01 -05:00
|
|
|
if(account.cuenta.length < 10){
|
2018-10-08 01:13:46 -05:00
|
|
|
msg = 'Longitud incorrecta de la cuenta'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!account.clabe){
|
|
|
|
msg = 'La CLABE es requerida'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(account.clabe.length != 18){
|
|
|
|
msg = 'La CLABE debe ser de 18 digitos'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!account.clabe.is_number()){
|
|
|
|
msg = 'Solo digitos en la CLABE'
|
|
|
|
msg_error(msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var grid = $$('grid_partner_account_bank')
|
|
|
|
|
|
|
|
if(id_partner){
|
|
|
|
partner_new_account_bank(account, grid)
|
|
|
|
}else{
|
|
|
|
grid.add(account)
|
|
|
|
}
|
|
|
|
|
|
|
|
form.setValues({})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_partner_banks(){
|
|
|
|
webix.ajax().get('/satbancos', {opt: 'active'}, function(text, data){
|
|
|
|
var values = data.json()
|
|
|
|
$$('lst_partner_bank').getList().parse(values)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function partner_new_account_bank(account, grid){
|
|
|
|
webix.ajax().post('/socioscb', {opt: 'new', values: account}, {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
msg = 'Error al guardar'
|
|
|
|
msg_error(msg)
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json()
|
|
|
|
if(values.ok){
|
|
|
|
account['id'] = values.id
|
|
|
|
grid.add(account)
|
|
|
|
msg_ok(values.msg)
|
|
|
|
}else{
|
|
|
|
msg_error(values.msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_partner_accounts_bank(id_partner){
|
|
|
|
var grid = $$('grid_partner_account_bank')
|
|
|
|
grid.clearAll()
|
|
|
|
|
|
|
|
if(id_partner){
|
|
|
|
var data = {opt: 'by_partner', id_partner: id_partner}
|
|
|
|
webix.ajax().get('/socioscb', data, {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
msg = 'Error al consultar'
|
|
|
|
msg_error(msg)
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json()
|
|
|
|
grid.parse(values)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function grid_partner_account_bank_click(id, e, node){
|
|
|
|
if(id.column != 'delete'){
|
|
|
|
return
|
|
|
|
}
|
2018-10-08 14:13:16 -05:00
|
|
|
var id_partner = $$('form_partner').getValues().id
|
|
|
|
var grid = $$('grid_partner_account_bank')
|
2018-10-08 01:13:46 -05:00
|
|
|
|
|
|
|
var msg = '¿Estás seguro de eliminar la cuenta de banco seleccionada?<BR><BR>'
|
|
|
|
msg += 'ESTA ACCION NO SE PUEDE DESHACER'
|
|
|
|
webix.confirm({
|
|
|
|
title: 'Eliminar cuenta de banco',
|
|
|
|
ok: 'Si',
|
|
|
|
cancel: 'No',
|
|
|
|
type: 'confirm-error',
|
|
|
|
text: msg,
|
|
|
|
callback:function(result){
|
|
|
|
if (result){
|
2018-10-08 14:13:16 -05:00
|
|
|
if(id_partner){
|
|
|
|
partner_delete_account_bank(id.row)
|
|
|
|
}else{
|
|
|
|
grid.remove(id.row)
|
|
|
|
}
|
2018-10-08 01:13:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function partner_delete_account_bank(row){
|
|
|
|
var grid = $$('grid_partner_account_bank')
|
|
|
|
|
|
|
|
webix.ajax().post('/socioscb', {opt: 'delete', values: {id: row}}, {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
msg = 'Error al eliminar'
|
|
|
|
msg_error(msg)
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json()
|
|
|
|
if(values.ok){
|
|
|
|
grid.remove(row)
|
|
|
|
msg_ok(values.msg)
|
|
|
|
}else{
|
|
|
|
msg_error(values.msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-03-10 20:29:50 -06:00
|
|
|
|
|
|
|
|
|
|
|
function get_sat_regimenes(morales=false){
|
|
|
|
var data = {opt: 'actives', morales: morales}
|
|
|
|
webix.ajax().get('/satregimenes', data, {
|
|
|
|
error: function(text, data, xhr) {
|
|
|
|
msg = 'Error al consultar'
|
|
|
|
msg_error(msg)
|
|
|
|
},
|
|
|
|
success: function(text, data, xhr) {
|
|
|
|
var values = data.json()
|
|
|
|
$$('lst_receptor_regimenes_fiscales').clearAll()
|
|
|
|
$$('lst_receptor_regimenes_fiscales').parse(values)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|