diff --git a/source/app/models/main.py b/source/app/models/main.py index 1699698..5a9ef2d 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -194,10 +194,11 @@ def config_main(): obj = None punto_de_venta = util.get_bool(Configuracion.get_('chk_usar_punto_de_venta')) + nomina = util.get_bool(Configuracion.get_('chk_usar_nomina')) data = { 'empresa': get_title_app(3), 'punto_de_venta': punto_de_venta - + 'nomina': nomina, } if not obj is None: titulo = '{} - {}' @@ -322,6 +323,7 @@ class Configuracion(BaseModel): 'chk_ticket_direct_print', 'chk_ticket_edit_cant', 'chk_ticket_total_up', + 'chk_usar_nomina', ) data = (Configuracion .select() @@ -697,6 +699,7 @@ class Emisor(BaseModel): obj = obj[0] row['emisor'] = { 'emisor_rfc': obj.rfc, + 'emisor_curp': obj.curp, 'emisor_nombre': obj.nombre, 'emisor_cp': obj.codigo_postal, 'emisor_cp2': obj.cp_expedicion, @@ -720,6 +723,7 @@ class Emisor(BaseModel): 'correo_timbrado': obj.correo_timbrado, 'token_timbrado': obj.token_timbrado, 'token_soporte': obj.token_soporte, + 'emisor_registro_patronal': obj.registro_patronal, 'regimenes': [row.id for row in obj.regimenes] } else: @@ -754,6 +758,7 @@ class Emisor(BaseModel): def _clean(self, values): fields = util.clean(values) fields['rfc'] = fields.pop('emisor_rfc') + fields['curp'] = fields.pop('emisor_curp', '') fields['nombre'] = fields.pop('emisor_nombre') fields['codigo_postal'] = fields.pop('emisor_cp') fields['cp_expedicion'] = fields.pop('emisor_cp2', '') or fields['codigo_postal'] @@ -776,6 +781,7 @@ class Emisor(BaseModel): fields['fecha_dof'] = fields.pop('ong_fecha_dof', None) if len(fields['rfc']) == 12: fields['es_moral'] = True + fields['registro_patronal'] = fields.pop('emisor_registro_patronal', '') fields['regimenes'] = SATRegimenes.get_( util.loads(fields['regimenes'])) return fields @@ -5230,6 +5236,7 @@ class Empleados(BaseModel): estado = ForeignKeyField(SATEstados) codigo_postal = TextField(default='') notas = TextField(default='') + correo = TextField(default='') class Meta: order_by = ('nombre_completo',) @@ -5658,7 +5665,7 @@ def _migrate_tables(): CfdiNominaRelacionados, CfdiNominaSeparacion, CfdiNominaSubcontratos, CfdiNominaTotales, ] - log.info('Creando nuevas tablas...') + log.info('Creando tablas nuevas...') database_proxy.create_tables(tablas, True) log.info('Tablas creadas correctamente...') diff --git a/source/static/js/controller/admin.js b/source/static/js/controller/admin.js index b7a4ea5..0487030 100644 --- a/source/static/js/controller/admin.js +++ b/source/static/js/controller/admin.js @@ -74,6 +74,7 @@ var controllers = { $$('chk_ticket_edit_cant').attachEvent('onItemClick', chk_config_item_click) $$('chk_ticket_total_up').attachEvent('onItemClick', chk_config_item_click) $$('txt_ticket_printer').attachEvent('onKeyPress', txt_ticket_printer_key_press) + $$('chk_usar_nomina').attachEvent('onItemClick', chk_config_item_click) $$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click) $$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_upload_complete) @@ -197,6 +198,9 @@ function get_emisor(){ if(emisor.regimenes){ $$('lst_emisor_regimen').select(emisor.regimenes) } + if(emisor.emisor_rfc.length == 12){ + show('emisor_curp', false) + } }else{ msg_error(values.msg) } @@ -1013,8 +1017,8 @@ function txt_plantilla_donataria_click(e){ function tab_options_change(nv, ov){ var cv = { - Plantillas: 'templates', - Otros: 'configotros', + tab_admin_templates: 'templates', + tab_admin_otros: 'configotros', } get_config_values(cv[nv]) } diff --git a/source/static/js/controller/main.js b/source/static/js/controller/main.js index d2bbf9e..3456c98 100644 --- a/source/static/js/controller/main.js +++ b/source/static/js/controller/main.js @@ -9,13 +9,21 @@ function configuracion_inicial(){ webix.ajax().get('/values/main', function(text, data){ var values = data.json() $$('lbl_title_main').setValue(values.empresa) - //~ showvar() + var pos = 4 + if(values.nomina){ + var node = { + id: 'app_nomina', + icon: 'users', + value: 'Nómina'} + $$('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, 4) + $$('main_sidebar').add(node, pos) } }) @@ -45,6 +53,7 @@ var controllers = { products_controllers.init() bancos_controllers.init() invoices_controllers.init() + nomina_controllers.init() tickets_controllers.init() } } @@ -145,6 +154,14 @@ function multi_change(prevID, nextID){ 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'){ diff --git a/source/static/js/controller/nomina.js b/source/static/js/controller/nomina.js new file mode 100644 index 0000000..eee5bb0 --- /dev/null +++ b/source/static/js/controller/nomina.js @@ -0,0 +1,52 @@ +var query = [] +var cfg_nomina = new Object() + + +var nomina_controllers = { + init: function(){ + $$('cmd_empleados').attachEvent('onItemClick', cmd_empleados_click) + $$('cmd_close_empleados').attachEvent('onItemClick', cmd_close_empleados_click) + $$('cmd_import_empleados').attachEvent('onItemClick', cmd_import_empleados_click) + webix.extend($$('grid_nomina'), webix.ProgressBar) + } +} + + +function default_config_nomina(){ + +} + + +function current_dates_nomina(){ + var fy = $$('filter_year_nomina') + var fm = $$('filter_month_nomina') + var d = new Date() + + fy.blockEvent() + fm.blockEvent() + + fm.setValue(d.getMonth() + 1) + webix.ajax().sync().get('/values/filteryearsnomina', function(text, data){ + var values = data.json() + fy.getList().parse(values) + fy.setValue(d.getFullYear()) + }) + + fy.unblockEvent() + fm.unblockEvent() +} + + +function cmd_empleados_click(){ + $$('multi_nomina').setValue('nomina_empleados') +} + + +function cmd_close_empleados_click(){ + $$('multi_nomina').setValue('nomina_home') +} + + +function cmd_import_empleados_click(){ + showvar('Importar') +} \ No newline at end of file diff --git a/source/static/js/controller/util.js b/source/static/js/controller/util.js index 0081054..e1f280b 100644 --- a/source/static/js/controller/util.js +++ b/source/static/js/controller/util.js @@ -16,6 +16,7 @@ var table_series = db.addCollection('series') var table_usocfdi = db.addCollection('usocfdi') var table_relaciones = db.addCollection('relaciones') +var msg = '' var months = [ {id: -1, value: 'Todos'}, diff --git a/source/static/js/ui/admin.js b/source/static/js/ui/admin.js index e5d454f..d679c90 100644 --- a/source/static/js/ui/admin.js +++ b/source/static/js/ui/admin.js @@ -78,9 +78,14 @@ var sidebar_admin = { var emisor_datos_fiscales = [ {template: 'Datos SAT', type: 'section'}, - {cols: [{view: 'text', id: 'emisor_rfc', name: 'emisor_rfc', label: 'RFC: ', - width: 300, required: true, invalidMessage: 'RFC inválido', - readonly: true, attributes: {maxlength: 13}}, {}]}, + {cols: [ + {view: 'text', id: 'emisor_rfc', name: 'emisor_rfc', label: 'RFC: ', + width: 300, required: true, invalidMessage: 'RFC inválido', + readonly: true, attributes: {maxlength: 13}}, + {view: 'text', id: 'emisor_curp', name: 'emisor_curp', label: 'CURP: ', + width: 350, labelWidth: 100, attributes: {maxlength: 18}, + placeholder: 'Solo si timbran nómina'}, + {}]}, {view: 'text', id: 'emisor_nombre', name: 'emisor_nombre', label: 'Razón Social: ', required: true, invalidMessage: 'La Razón Social es requerida'}, @@ -116,16 +121,25 @@ var emisor_datos_fiscales = [ var emisor_otros_datos= [ {template: 'Generales', type: 'section'}, - {view: 'search', id: 'emisor_logo', icon: 'file-image-o', - name: 'emisor_logo', label: 'Logotipo: '}, - {view: 'text', id: 'emisor_nombre_comercial', - name: 'emisor_nombre_comercial', label: 'Nombre comercial: '}, - {view: 'text', id: 'emisor_telefono', name: 'emisor_telefono', - label: 'Teléfonos: '}, - {view: 'text', id: 'emisor_correo', name: 'emisor_correo', - label: 'Correos: '}, - {view: 'text', id: 'emisor_web', name: 'emisor_web', - label: 'Página Web: '}, + {cols: [ + {view: 'search', id: 'emisor_logo', icon: 'file-image-o', + name: 'emisor_logo', label: 'Logotipo: '}, + {view: 'text', id: 'emisor_nombre_comercial', + name: 'emisor_nombre_comercial', label: 'Nombre comercial: '}, + ]}, + {cols: [ + {view: 'text', id: 'emisor_telefono', name: 'emisor_telefono', + label: 'Teléfonos: '}, + {view: 'text', id: 'emisor_correo', name: 'emisor_correo', + label: 'Correos: '}, + ]}, + {cols: [ + {view: 'text', id: 'emisor_registro_patronal', attributes: {maxlength: 20}, + name: 'emisor_registro_patronal', label: 'Registro Patronal: ', + placeholder: 'Solo para timbrado de nómina'}, + {view: 'text', id: 'emisor_web', name: 'emisor_web', + label: 'Página Web: '}, + ]}, {template: 'Escuela', type: 'section'}, {cols: [{view: 'checkbox', id: 'chk_escuela', name: 'es_escuela', label: 'Es Escuela'}, @@ -407,7 +421,6 @@ var controls_folios = [ { view: 'tabview', id: 'tab_folios', - //~ tabbar: {options: ['Folios']}, animate: true, cells: [ {id: 'Folios', rows: emisor_folios}, @@ -431,7 +444,6 @@ var controls_correo = [ var form_folios = { type: 'space', - //~ responsive: true, cols: [{ view: 'form', id: 'form_folios', @@ -462,7 +474,6 @@ var form_correo = { labelWidth: 150, labelAlign: 'right' }, - //~ autoheight: true }], } @@ -563,23 +574,25 @@ var options_admin_otros = [ {view: 'checkbox', id: 'chk_ticket_total_up', labelWidth: 0, labelRight: 'Mostrar total arriba'}, {}]}, - + {maxHeight: 20}, + {template: 'Nómina', type: 'section'}, + {cols: [{maxWidth: 15}, + {view: 'checkbox', id: 'chk_usar_nomina', labelWidth: 0, + labelRight: 'Usar timbrado de Nómina'}, + {}]}, {}] - -var body_admin_otros = { - view: 'scrollview', body: {rows: options_admin_otros}, -} - var tab_options = { view: 'tabview', id: 'tab_options', animate: true, cells: [ - {id: 'Plantillas', rows: options_templates}, - {id: 'Otros', rows: options_admin_otros}, - ], + {header: 'Plantillas', body: {id: 'tab_admin_templates', + rows: options_templates}}, + {header: 'Otros', body: {id: 'tab_admin_otros', view: 'scrollview', + body: {rows: options_admin_otros}}}, + ] } @@ -659,7 +672,6 @@ var grid_admin_taxes = { view: 'datatable', id: 'grid_admin_taxes', select: 'cell', - //~ multiselect: true, adjust: true, autoheight: true, autowidth: true, diff --git a/source/static/js/ui/main.js b/source/static/js/ui/main.js index cd6bdaf..d83173f 100644 --- a/source/static/js/ui/main.js +++ b/source/static/js/ui/main.js @@ -2,7 +2,7 @@ var menu_data = [ {id: 'app_home', icon: 'dashboard', value: 'Inicio'}, - {id: 'app_partners', icon: 'users', value: 'Clientes y Proveedores'}, + {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'}, @@ -37,6 +37,7 @@ var multi_main = { app_partners, app_products, app_bancos, + app_nomina, app_tickets, app_invoices, ], diff --git a/source/static/js/ui/nomina.js b/source/static/js/ui/nomina.js new file mode 100644 index 0000000..d665305 --- /dev/null +++ b/source/static/js/ui/nomina.js @@ -0,0 +1,166 @@ + +var toolbar_nomina = [ + {view: 'button', id: 'cmd_empleados', label: 'Empleados', type: 'iconButton', + autowidth: true, icon: 'users'}, + {}, + {view: 'button', id: 'cmd_nomina_report', label: 'Reporte', type: 'iconButton', + autowidth: true, icon: 'table'}, + {}, + {view: 'button', id: 'cmd_nomina_delete', label: 'Eliminar', + type: 'iconButton', autowidth: true, icon: 'minus'}, +] + + +var toolbar_nomina_util = [ + {view: 'button', id: 'cmd_nomina_import', label: 'Importar', + type: 'iconButton', autowidth: true, icon: 'upload'}, + {view: 'button', id: 'cmd_nomina_timbrar', label: 'Timbrar', + type: 'iconButton', autowidth: true, icon: 'ticket'}, + {view: 'button', id: 'cmd_nomina_sat', label: 'SAT', + type: 'iconButton', autowidth: true, icon: 'check-circle'}, + {}, + {view: 'button', id: 'cmd_nomina_cancel', label: 'Cancelar', + type: 'iconButton', autowidth: true, icon: 'ban'}, +] + + +var toolbar_nomina_filter = [ + {view: 'richselect', id: 'filter_year_nomina', label: 'Año', + labelAlign: 'right', labelWidth: 50, width: 150, options: []}, + {view: 'richselect', id: 'filter_month_nomina', label: 'Mes', + labelAlign: 'right', labelWidth: 50, width: 200, options: months}, + {view: 'daterangepicker', id: 'filter_dates_nomina', label: 'Fechas', + labelAlign: 'right', width: 300}, +] + + +var grid_cols_nomina = [ + {id: 'index', header: '#', adjust: 'data', css: 'right', + footer: {content: 'countRows', colspan: 3, css: 'right'}}, + {id: "id", header:"ID", hidden:true}, + {id: "serie", header: ["Serie"], adjust: "header"}, + {id: 'folio', header: ['Folio', {content: 'numberFilter'}], adjust: 'header', + sort: 'int', css: 'right', footer: {text: 'Recibos', colspan: 3}}, + {id: "fecha", header: ["Fecha y Hora"], adjust: "data", sort: "string"}, + {id: "estatus", header: ["Estatus", {content: "selectFilter"}], + adjust: "data", sort:"string"}, + {id: "fecha_pago", header: ["Fecha de Pago"], adjust: "data", sort: "string"}, + {id: 'total', header: ['Total', {content: 'numberFilter'}], width: 150, + sort: 'int', format: webix.i18n.priceFormat, css: 'right', + footer: {content: 'summActive', css: 'right'}}, + {id: "empleado", header: ["Empleado", {content: "selectFilter"}], + fillspace:true, sort:"string"}, + {id: 'pdf', header: 'PDF', adjust: 'data', template: get_icon('pdf')}, +] + + +var grid_nomina = { + view: 'datatable', + id: 'grid_nomina', + select: 'row', + multiselect: true, + scrollY: true, + adjust: true, + footer: true, + resizeColumn: true, + headermenu: true, + columns: grid_cols_nomina, + scheme:{ + $change:function(item){ + if (item.estatus == 'Cancelado'){ + item.$css = 'cancel' + } + } + }, + on:{ + 'data->onStoreUpdated':function(){ + this.data.each(function(obj, i){ + obj.index = i + 1 + }) + } + }, +} + + +var rows_nomina_home = [ + {view: 'toolbar', elements: toolbar_nomina}, + {view: 'toolbar', elements: toolbar_nomina_util}, + {view: 'toolbar', elements: toolbar_nomina_filter}, + grid_nomina, +] + + +var toolbar_nomina_empleados = [ + {view: 'button', id: 'cmd_new_empleado', label: 'Nuevo', type: 'iconButton', + autowidth: true, icon: 'user-plus'}, + {view: 'button', id: 'cmd_edit_empleado', label: 'Editar', type: 'iconButton', + autowidth: true, icon: 'user'}, + {view: 'button', id: 'cmd_delete_empleado', label: 'Eliminar', type: 'iconButton', + autowidth: true, icon: 'user-times'}, + {}, + {view: 'button', id: 'cmd_import_empleados', label: 'Importar', + type: 'iconButton', autowidth: true, icon: 'upload'}, + {}, + {view: 'button', id: 'cmd_close_empleados', label: 'Cerrar', type: 'iconButton', + autowidth: true, icon: 'times-circle-o'}, +] + + +var grid_cols_empleados = [ + {id: 'index', header: '#', adjust: 'data', css: 'right', + footer: {content: 'countRows', colspan: 3, css: 'right'}}, + {id: "id", header:"ID", hidden:true}, + {id: "num_empleado", header: ["No Empleado"], adjust: "header"}, + {id: "rfc", header: ["RFC", {content: 'textFilter'}], adjust: "data"}, + {id: "curp", header: ["CURP"], adjust: "data", hidden:true}, + {id: "nombre_completo", header: ["Empleado", {content: 'textFilter'}], + adjust: "data", fillspace: true}, + {id: "fecha_ingreso", header: ["Fecha de Ingreso"], adjust: "data", + sort: "string"}, +] + + +var grid_empleados = { + view: 'datatable', + id: 'grid_empleados', + select: 'row', + scrollY: true, + adjust: true, + footer: true, + resizeColumn: true, + headermenu: true, + columns: grid_cols_empleados, + on:{ + 'data->onStoreUpdated':function(){ + this.data.each(function(obj, i){ + obj.index = i + 1 + }) + } + }, +} + + +var rows_nomina_empleados = [ + {view: 'toolbar', elements: toolbar_nomina_empleados}, + grid_empleados, +] + + +var multi_nomina = { + id: 'multi_nomina', + view: 'multiview', + animate: true, + cells:[ + {id: 'nomina_home', rows: rows_nomina_home}, + {id: 'nomina_empleados', rows: rows_nomina_empleados}, + ], +} + + +var app_nomina = { + id: 'app_nomina', + rows:[ + {view: 'template', type: 'header', template: 'Timbrado de Nómina'}, + multi_nomina + ], +} \ No newline at end of file diff --git a/source/templates/main.html b/source/templates/main.html index d5395ca..9ccb771 100644 --- a/source/templates/main.html +++ b/source/templates/main.html @@ -8,6 +8,7 @@ + @@ -15,6 +16,7 @@ +