Procházet zdrojové kódy

Reporte para recursos humanos

SEBAS před 2 roky
revize
bd754b15be

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+import controllers
+import models

binární
__init__.pyc


+ 26 - 0
__openerp__.py

@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+{
+    'name': "Eiru Reports RRHH",
+    'author': "Eiru",
+    'category': 'Reports',
+    'version': '0.1',
+    'depends': [
+        'base',
+        'hr',
+        'account',
+        'eiru_assets',
+        'eiru_reports',
+        'hr_payroll',
+        'hr_payslip_paid',
+    ],
+    'qweb': [
+        'static/src/xml/*.xml',
+        'static/src/reports/*.xml'
+    ],
+    'data': [
+        'templates.xml',
+        'views/actions.xml',
+        'views/menus.xml',
+        'views/hr_employee.xml',
+    ],
+}

+ 2 - 0
controllers.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from openerp import http

binární
controllers.pyc


+ 8 - 0
models.py

@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields, api
+
+class hr_employee(models.Model):
+	_inherit = 'hr.employee'
+
+	store_id = fields.Many2one("res.store","Sucursal");

binární
models.pyc


binární
static/description/icon.png


+ 10 - 0
static/src/css/custom.css

@@ -0,0 +1,10 @@
+.openerp_webclient_container {
+    height: 100% !important;
+    height: calc(100% - 45px) !important;
+    overflow: auto !important;
+  }
+
+.hover:hover{
+  cursor: -webkit-grab;
+  cursor: grab;
+}

+ 47 - 0
static/src/js/main.js

@@ -0,0 +1,47 @@
+openerp.eiru_reports_rrhh = function(instance) {
+  "use strict";
+
+  var reporting = instance.eiru_reports_rrhh;
+
+  reporting_base(instance, reporting);
+
+  try {
+    rrhh_pdf(reporting);
+    report_employee_list(reporting);
+    report_payslip(reporting);
+    report_payslip_run(reporting);
+    report_cash_advance(reporting);
+    report_bonus(reporting);
+    report_absence(reporting);
+    report_contract_list(reporting);
+    report_payslip_egreso(reporting);
+  } catch (e) {
+    // ignorar error
+  }
+
+  // lista de funcionarios
+  instance.web.client_actions.add('eiru_reports_rrhh.employee_list_action', 'instance.eiru_reports_rrhh.ReportEmployeeListWidget');
+
+  // analisis de nominas
+  instance.web.client_actions.add('eiru_reports_rrhh.payslip_action', 'instance.eiru_reports_rrhh.ReportPayslipWidget');
+
+  // procesamiento de nominas
+  instance.web.client_actions.add('eiru_reports_rrhh.payslip_run_action', 'instance.eiru_reports_rrhh.ReportPayslipRunWidget');
+
+  // historico de adelantos
+  instance.web.client_actions.add('eiru_reports_rrhh.cash_advance_action', 'instance.eiru_reports_rrhh.ReportCashdvanceWidget');
+
+  // historico de comision
+  instance.web.client_actions.add('eiru_reports_rrhh.bonus_action', 'instance.eiru_reports_rrhh.ReportBonusWidget');
+
+  // historico de ausencias
+  instance.web.client_actions.add('eiru_reports_rrhh.absence_action', 'instance.eiru_reports_rrhh.ReportAbsenceWidget');
+
+  // lista de contratos
+  instance.web.client_actions.add('eiru_reports_rrhh.contract_list_action', 'instance.eiru_reports_rrhh.ReportContractListWidget');
+
+  // resumen de egreso/pago de nómina
+  instance.web.client_actions.add('eiru_reports_rrhh.payslip_egreso_action', 'instance.eiru_reports_rrhh.ReportPayslipEgresoWidget');
+
+
+}

+ 222 - 0
static/src/js/pdf.js

@@ -0,0 +1,222 @@
+function rrhh_pdf(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPdfWidget = reporting.Base.extend({
+      drawAbsencePdf: function (row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
+         var self = this;
+         var base64Img = 'data:image/png;base64,' + ResCompany.logo;
+         var hoy = moment().format('DD/MM/YYYY');
+         var totalPagesExp = "{total_pages_count_string}";
+         var pdfDoc = new jsPDF(pdf_type);
+         var title = [];
+         var currentpage = 0;
+         var i = 0;
+         var position = 27;
+         var y_position2 = 27;
+
+         title.push({
+           title : 'Fecha',
+           dataKey: 'create_date',
+           align: 'center',
+         });
+         title.push({
+           title : 'Descripción',
+           dataKey: 'name',
+           align: 'center',
+         });
+         title.push({
+           title : 'Nómina',
+           dataKey: 'payslip',
+           align: 'center',
+         });
+         title.push({
+           title : 'Días Faltados',
+           dataKey: 'number_of_days',
+           align: 'center',
+         });
+
+
+
+         //LOGO
+         pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
+
+         //FECHA
+         pdfDoc.setFontSize(13);
+         pdfDoc.setFontStyle('normal');
+         pdfDoc.setTextColor(40)
+         pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
+
+         //TITULO
+         pdfDoc.setFontSize(15);
+         pdfDoc.setFontStyle('bold');
+         pdfDoc.setTextColor('#0288d1');
+         pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
+           halign: 'right',
+           valign: 'middle'
+         });
+         pdfDoc.setLineWidth(0.5);
+         pdfDoc.setDrawColor('#424242');
+         pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
+
+         var ii=0;
+         if(pdf_type == 'l'){
+           var col1_title = 15;
+           var col1_value = 55;
+           var col2_title = 150;
+           var col2_value = 190;
+         }
+         else{
+           var col1_title = 10;
+           var col1_value = 50;
+           var col2_title = 110;
+           var col2_value = 150;
+         }
+         if(filter.length >0){
+           _.each(filter,function(item){
+             if(ii<4){
+               self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,position);
+               position = position + 5;
+             }else{
+               self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
+               y_position2 = y_position2 + 5;
+             }
+               ii++;
+           });
+           pdfDoc.setLineWidth(0.5);
+           pdfDoc.setDrawColor('#424242');
+
+           if(position >= y_position2){
+             position = position;
+             pdfDoc.line(10, position, pdfDoc.internal.pageSize.getWidth() - 10 , position);
+           }else{
+             position = y_position2;
+             pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
+           }
+         }
+
+         _.each(row, function(item){
+           if(i > 0){
+             let first = pdfDoc.autoTable.previous;
+             position = first.finalY + 5;
+           };
+
+           var docItem = [];
+           if(item.info != 'undefined'){
+             _.each(item.info, function(index){
+               docItem.push({
+                 create_date: index.create_date,
+                 name: index.name,
+                 payslip: index.payslip,
+                 number_of_days: index.number_of_days,
+               })
+             });
+           }
+
+           pdfDoc.setDrawColor(0);
+           pdfDoc.setFillColor(76, 133, 248);
+           pdfDoc.rect(7, position+5, 196, 8, 'F');
+
+           pdfDoc.setFontSize(9);
+           pdfDoc.setTextColor(255,255,255)
+           pdfDoc.setFontStyle('bold');
+
+           pdfDoc.autoTableText('Funcionario: ', 10, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTableText(item.employee_name, 30, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTableText('Días Faltados: ', 100, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTableText(item.total_days, 123, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTableText('Monto Descontado: ', 140, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTableText(item.total_amount, 172, position+9, {
+             halign: 'left',
+             valign: 'middle'
+           });
+
+           pdfDoc.autoTable(title, docItem, {
+             //  showHeader: false,
+             startY: position+15,
+             theme: 'grid',
+             styles: {
+               overflow: 'linebreak',
+               fontSize: 8,
+               margin: 50,
+               lineWidth: 0.3,
+               lineColor: [132,132,132]
+             },
+             headerStyles: {
+               fillColor: [255,255,255],
+               fontSize: 9,
+               textColor: [0,0,0],
+               lineWidth: 0.3,
+               lineColor: [132,132,132]
+             },
+             columnStyles: pdf_columnStyles,
+             margin: 'auto',
+             tableWidth: 'auto',
+
+             addPageContent: function (data) {
+               // FOOTER
+               if (currentpage < pdfDoc.internal.getNumberOfPages()) {
+                 var str = "Página " + pdfDoc.internal.getNumberOfPages();
+                 str = str + " de " + totalPagesExp;
+                 pdfDoc.setFontSize(9);
+                 pdfDoc.setFontStyle('bold');
+                 pdfDoc.setTextColor(40);
+                 var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
+                 pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
+                 currentpage = pdfDoc.internal.getNumberOfPages();
+               }
+             }
+           });
+           i++;
+         });
+         if (typeof pdfDoc.putTotalPages === 'function') {
+           pdfDoc.putTotalPages(totalPagesExp);
+         }
+         row.pop();
+         if(model.printer_bridge){
+           var data = pdfDoc.output('datauristring');
+           model.printer_bridge.print(data);
+           return;
+         }
+         pdfDoc.save(pdf_name + hoy + '.pdf');
+       },
+
+       addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
+    pdfDoc.setFontSize(10);
+    pdfDoc.setTextColor('#424242');
+    pdfDoc.setFontStyle('bold');
+    pdfDoc.autoTableText(title+':', x_position_title, y_position, {
+      halign: 'left',
+      valign: 'middle'
+    });
+    pdfDoc.setFontSize(10);
+    pdfDoc.setTextColor('#424242');
+    pdfDoc.setFontStyle('normal');
+    pdfDoc.autoTableText(value, x_position_value, y_position, {
+      halign: 'left',
+      valign: 'middle'
+    });
+  },
+     });
+   }

+ 22 - 0
static/src/js/reporting_base.js

@@ -0,0 +1,22 @@
+function reporting_base (instance, widget) {
+    "use strict";
+
+    widget.Base = instance.Widget.extend({
+
+        position: 0,
+
+        init: function (parent, position) {
+            this._super(parent);
+            this.position = position || this.position;
+        },
+        start: function () {
+            
+        },
+        getPosition: function () {
+            return this.position;
+        },
+        setPosition: function (position) {
+            this.position = position;
+        }
+    });
+}

+ 751 - 0
static/src/js/reports/report_absence.js

@@ -0,0 +1,751 @@
+function report_absence(reporting) {
+  "use strict";
+  var model = openerp;
+
+  reporting.ReportAbsenceWidget = reporting.Base.extend({
+    template: 'ReportAbsence',
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-date': 'ShowDateRange',
+      'change #current-store': 'updateEmployee',
+      'change #current-company': 'updateStore',
+      'change #current-period': 'updatePeriodSelections',
+    },
+
+    init: function(parent) {
+      this._super(parent);
+    },
+
+    start: function() {
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    ShowDateRange: function() {
+      var self = this;
+      var date = self.$el.find('#current-date').val();
+      if (date == 'range') {
+        self.$el.find('.datepicker').css('display', 'block');
+      }
+      if (date != 'range') {
+        self.$el.find('.datepicker').css('display', 'none');
+      }
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Registro de Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+      if (field == 'payslip') {
+        this.do_action({
+          name: "Nómina",
+          type: 'ir.actions.act_window',
+          res_model: "hr.payslip",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.payslip_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.payslip_id,
+        });
+      }
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 0) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchAccountPeriod();
+      }).then(function(AccountPeriod) {
+        self.AccountPeriod = AccountPeriod;
+        if (AccountPeriod.length > 1) {
+          self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          _.each(AccountPeriod, function(item) {
+            self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.period').css('display', 'none');
+        }
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrPayslip().then(function(HrPayslip) {
+        return HrPayslip;
+      }).then(function(HrPayslip) {
+        self.HrPayslip = HrPayslip;
+        return self.fetchHrPayslipLine();
+      }).then(function(HrPayslipLine) {
+        self.HrPayslipLine = HrPayslipLine;
+        return self.fetchHrPayslipWorkedDays();
+      }).then(function(HrPayslipWorkedDays) {
+        self.HrPayslipWorkedDays = HrPayslipWorkedDays;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      company.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name', 'store_id'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchAccountPeriod: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var period = new model.web.Model('account.period');
+      var field = ['id', 'name','date_stop'];
+      period.query(field).filter().all().then(function(results) {
+        results.sort(function (a, b) {
+          if (a.date_stop > b.date_stop) {
+            return -1;
+          }
+          if (a.date_stop < b.date_stop) {
+            return 1;
+          }
+          return 0;
+        });
+        defer.resolve(results);
+      });
+
+      return defer;
+    },
+
+    fetchHrPayslipLine: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var payslip_ids = _.flatten(_.map(self.HrPayslip, function(item) {
+        return item.id;
+      }));
+      var domain = [
+        ['slip_id', 'in', payslip_ids]
+      ];
+
+      var line = new model.web.Model('hr.payslip.line');
+      var field = ['id', 'name', 'code', 'total'];
+      line.query(field).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslip: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee_id = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+
+      var domain = [];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (employee_id && employee_id != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee_id)]);
+      }
+
+      if (period && period != 9999999) {
+        domain.push(['period_id', '=', parseInt(period)]);
+      }
+
+      var fields = [
+        'id',
+        'name',
+        'company_id',
+        'employee_id',
+        'worked_days_line_ids',
+        'line_ids'
+      ];
+      var HrPayslip = new model.web.Model('hr.payslip');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslipWorkedDays: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+      var payslip_ids = _.flatten(_.map(self.HrPayslip, function(item) {
+        return item.id;
+      }));
+
+      var domain = [
+        ['code', '=', 'FALTAS'],
+        ['payslip_id', 'in', payslip_ids]
+      ];
+
+      if (date && date != 9999999) {
+        if (desde) {
+          var date = desde.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '>=', date]);
+        }
+        if (hasta) {
+          var date = hasta.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '<=', date]);
+        }
+        if (date == 'today') {
+          var today = moment().format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', today]);
+        }
+        if (date == 'yesterday') {
+          var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', yesterday]);
+        }
+        if (date == 'currentMonth') {
+          var currentMonth = moment().format('YYYY-MM');
+          domain.push(['create_date', 'like', currentMonth]);
+        }
+        if (date == 'lastMonth') {
+          var lastMonth = moment().add(-1, 'months').format('YYYY-MM');
+          domain.push(['create_date', 'like', lastMonth]);
+        }
+      }
+
+      var fields = [
+        'id',
+        'code',
+        'name',
+        'payslip_id',
+        'create_date',
+        'number_of_days',
+      ];
+
+      var HrPayslipWorkedDays = new model.web.Model('hr.payslip.worked_days');
+      HrPayslipWorkedDays.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getHrPayslipWorkedDays: function(ids) {
+      var self = this;
+      return _.filter(self.HrPayslipWorkedDays, function(a) {
+        return _.find(ids, function(b) {
+          return b === a.id;
+        });
+      });
+    },
+
+    getHrPayslip: function(id) {
+      var self = this;
+      return _.filter(self.HrPayslip, function(a) {
+          return a.employee_id[0] === id;
+      });
+    },
+
+    getAmount: function(line_ids, code) {
+      var self = this;
+      var amount = 0;
+      amount = _.map(_.filter(self.HrPayslipLine, function(a) {
+        return _.find(line_ids, function(b) {
+          return b === a.id && a.code == code;
+        });
+      }), function(map) {
+        return map.total;
+      });
+
+      if (amount.length == 0) {
+        return 0
+      } else {
+        return amount[0];
+      }
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updatePeriodSelections: function() {
+      var self = this;
+      var period = self.$el.find('#current-period').val();
+      if (period != 9999999) {
+        self.$el.find('#current-date').val(9999999);
+        self.$el.find('#current-date').prop('disabled', 'disabled');
+        self.$el.find('.datepicker').css('display', 'none');
+      } else {
+        self.$el.find('#current-date').prop('disabled', false);
+      }
+    },
+
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var info = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+
+      var HrEmployee = self.HrEmployee;
+      _.each(HrEmployee, function(each){
+        var total_amount = 0;
+        var total_days = 0;
+        info = [];
+
+          var HrPayslip = self.getHrPayslip(each.id);
+          _.each(HrPayslip, function(item) {
+
+            var HrPayslipWorkedDays = self.getHrPayslipWorkedDays(item.worked_days_line_ids);
+
+            _.each(HrPayslipWorkedDays, function(index) {
+              total_days = total_days + index.number_of_days;
+              info.push({
+                id: index.id,
+                payslip_id : index.payslip_id[0],
+
+                create_date: index.create_date,
+                name: index.name,
+                payslip : index.payslip_id[1],
+                number_of_days: index.number_of_days,
+              });
+            });
+            var amount = self.getAmount(item.line_ids, "FALTAS");
+            total_amount = total_amount + amount;
+          });
+
+          if (total_amount != 0) {
+
+            data.push({
+              id: each.id,
+              employee_name: each.name,
+
+              total_days : accounting.formatNumber(total_days, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+              total_amount: accounting.formatMoney(total_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+              total_days_no_format : total_days,
+              amount_no_format : total_amount,
+
+              decimal_places: CurrencyBase.decimal_places,
+              thousands_separator: CurrencyBase.thousands_separator,
+              decimal_separator: CurrencyBase.decimal_separator,
+
+              info: info,
+
+            });
+          }
+      })
+
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      var data = [];
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+
+      table.bootstrapTable({
+        data:rowsTable,
+        detailView: true,
+        onExpandRow: function(index, row, $detail) {
+          $detail.html('<div class="panel panel-first-style"><div class="panel-heading panel-header-first-style">Detalle de Ausencias</div><table id="table2"></table></div>').find('table').bootstrapTable({
+            columns: [{
+                      field: 'create_date',
+                      title: 'Fecha',
+                      align: 'center',
+                  },
+                  {
+                      field: 'name',
+                      title: 'Descripción',
+                      align: 'left',
+                  },
+                  {
+                      field: 'payslip',
+                      title: 'Nómina',
+                      align: 'left',
+                      class: 'hover',
+                  },
+                  {
+                      field: 'number_of_days',
+                      title: 'Días Faltados',
+                      align: 'center',
+                  }
+                ],
+
+          data:row.info,
+          })
+            $('#table2').removeClass('table-hover').addClass('table-no-bordered');
+            $('thead').css('background','none');
+        }
+      })
+
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var action = self.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+
+      var table = self.$el.find("#table");
+      var row = table.bootstrapTable('getData');
+
+      if (action === 'pdf') {
+
+        var pdf_title = 'Histórico de Ausencias';
+        var pdf_type = '';
+        var pdf_name = 'historico_de_ausencias_';
+        var pdf_columnStyles = {
+          create_date: {
+            columnWidth: 30,
+            halign: 'center'
+          },
+
+          name: {
+            columnWidth: 50,
+            halign: 'left'
+          },
+
+          payslip: {
+            halign: 'left'
+          },
+
+          number_of_days: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+        };
+
+        var filter = self.getFilter();
+        var pdf = new reporting.ReportPdfWidget(self);
+        pdf.drawAbsencePdf(
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+      }
+
+      if (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        })
+        filter.push({
+          title: 'Periodo',
+          value: AccountPeriod[0].name,
+        });
+      }
+
+      if (date && date != 9999999) {
+        moment.locale('es', {
+          months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+        });
+
+        if (date == 'range') {
+          filter.push({
+            title: 'Fecha',
+            value: desde + ' al ' + hasta,
+          });
+
+        } else {
+          if (date == 'today') {
+            var fecha = moment().format('DD/MM/YYYY');
+          }
+
+          if (date == 'yesterday') {
+            var fecha = moment().add(-1, 'days').format('DD/MM/YYYY');
+          }
+          if (date == 'currentMonth') {
+            var fecha = moment().format('MMMM/YYYY');
+          }
+          if (date == 'lastMonth') {
+            var fecha = moment().add(-1, 'months').format('MMMM/YYYY');
+          }
+
+          filter.push({
+            title: 'Fecha',
+            value: fecha,
+          });
+        }
+      }
+      return filter;
+    },
+  });
+}

+ 670 - 0
static/src/js/reports/report_bonus.js

@@ -0,0 +1,670 @@
+function report_bonus(reporting) {
+  "use strict";
+  var model = openerp;
+
+  reporting.ReportBonusWidget = reporting.Base.extend({
+    template: 'ReportBonus',
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-date': 'ShowDateRange',
+      'change #current-store': 'updateEmployee',
+      'change #current-company': 'updateStore',
+      'change #current-period': 'updatePeriodSelections',
+    },
+
+    init: function(parent) {
+      this._super(parent);
+    },
+
+    start: function() {
+      var table = this.$el.find('#table');
+      table.bootstrapTable({
+        data: self.rowsData
+      });
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    ShowDateRange: function() {
+      var self = this;
+      var date = self.$el.find('#current-date').val();
+      if (date == 'range') {
+        self.$el.find('.datepicker').css('display', 'block');
+      }
+      if (date != 'range') {
+        self.$el.find('.datepicker').css('display', 'none');
+      }
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Registro de Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.employee_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.employee_id,
+        });
+      }
+
+      if (field == 'payslip') {
+        this.do_action({
+          name: "Nómina",
+          type: 'ir.actions.act_window',
+          res_model: "hr.payslip",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 1) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchAccountPeriod();
+      }).then(function(AccountPeriod) {
+        self.AccountPeriod = AccountPeriod;
+        if (AccountPeriod.length > 1) {
+          self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          _.each(AccountPeriod, function(item) {
+            self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.period').css('display', 'none');
+        }
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrPayslipInput().then(function(HrPayslipInput) {
+        return HrPayslipInput;
+      }).then(function(HrPayslipInput) {
+        self.HrPayslipInput = HrPayslipInput;
+        return self.fetchHrPayslip();
+      }).then(function(HrPayslip) {
+        self.HrPayslip = HrPayslip;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      company.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name', 'store_id'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchAccountPeriod: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var period = new model.web.Model('account.period');
+      var field = ['id', 'name','date_stop'];
+      period.query(field).filter().all().then(function(results) {
+        results.sort(function (a, b) {
+          if (a.date_stop > b.date_stop) {
+            return -1;
+          }
+          if (a.date_stop < b.date_stop) {
+            return 1;
+          }
+          return 0;
+        });
+        defer.resolve(results);
+      });
+
+      return defer;
+    },
+
+    fetchHrPayslip: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee_id = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+
+      var payslip_ids = _.flatten(_.map(self.HrPayslipInput, function(item) {
+        return item.id;
+      }));
+
+      var domain = [
+        ['input_line_ids', 'in', payslip_ids]
+      ];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (employee_id && employee_id != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee_id)]);
+      }
+
+      if (period && period != 9999999) {
+        domain.push(['period_id', '=', parseInt(period)]);
+      }
+
+      var fields = [
+        'id',
+        'company_id',
+        'employee_id',
+        'input_line_ids',
+      ];
+      var HrPayslip = new model.web.Model('hr.payslip');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslipInput: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+
+      var domain = [
+        ['code', '=', 'CMS']
+      ]
+
+      if (date && date != 9999999) {
+        if (desde) {
+          var date = desde.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '>=', date]);
+        }
+        if (hasta) {
+          var date = hasta.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '<=', date]);
+        }
+        if (date == 'today') {
+          var today = moment().format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', today]);
+        }
+        if (date == 'yesterday') {
+          var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', yesterday]);
+        }
+        if (date == 'currentMonth') {
+          var currentMonth = moment().format('YYYY-MM');
+          domain.push(['create_date', 'like', currentMonth]);
+        }
+        if (date == 'lastMonth') {
+          var lastMonth = moment().add(-1, 'months').format('YYYY-MM');
+          domain.push(['create_date', 'like', lastMonth]);
+        }
+      }
+
+      var fields = [
+        'id',
+        'code',
+        'name',
+        'payslip_id',
+        'create_date',
+        'amount',
+      ];
+
+      var HrPayslip = new model.web.Model('hr.payslip.input');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getHrPayslip: function(id) {
+      var self = this;
+      return _.filter(self.HrPayslip, function(a) {
+        return a.id === id;
+      })
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updatePeriodSelections: function() {
+      var self = this;
+      var period = self.$el.find('#current-period').val();
+      if (period != 9999999) {
+        self.$el.find('#current-date').val(9999999);
+        self.$el.find('#current-date').prop('disabled', 'disabled');
+        self.$el.find('.datepicker').css('display', 'none');
+      } else {
+        self.$el.find('#current-date').prop('disabled', false);
+      }
+    },
+
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+      var HrPayslipInput = self.HrPayslipInput;
+      _.each(HrPayslipInput, function(item) {
+        var HrPayslip = self.getHrPayslip(item.payslip_id[0]);
+        _.each(HrPayslip, function(index) {
+          data.push({
+            id: index.id,
+            employee_id: index.employee_id[0],
+
+            create_date: item.create_date,
+            employee_name: index.employee_id[1],
+            name: item.name,
+            payslip: item.payslip_id[1],
+            amount: accounting.formatMoney(item.amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+            amount_no_format: item.amount,
+
+            decimal_places: CurrencyBase.decimal_places,
+            thousands_separator: CurrencyBase.thousands_separator,
+            decimal_separator: CurrencyBase.decimal_separator,
+
+          });
+        })
+      });
+
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var action = self.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = self.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      var amount = amountFormatter(row);
+
+      row.push({
+        create_date: 'Totales',
+        amount: amount,
+
+      });
+
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Histórico de Comisiones';
+        var pdf_type = '';
+        var pdf_name = 'historico_de_comisiones_';
+        var pdf_columnStyles = {
+          create_date: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+
+          employee_name: {
+            columnWidth: 25,
+            halign: 'left'
+          },
+
+          payslip: {
+            halign: 'left'
+          },
+
+          name: {
+            columnWidth: 35,
+            halign: 'left'
+          },
+
+          amount: {
+            columnWidth: 25,
+            halign: 'center'
+          },
+        };
+
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+      }
+
+      if (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        })
+        filter.push({
+          title: 'Periodo',
+          value: AccountPeriod[0].name,
+        });
+      }
+
+      if (date && date != 9999999) {
+        moment.locale('es', {
+          months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+        });
+
+        if (date == 'range') {
+          filter.push({
+            title: 'Fecha',
+            value: desde + ' al ' + hasta,
+          });
+
+        } else {
+          if (date == 'today') {
+            var fecha = moment().format('DD/MM/YYYY');
+          }
+
+          if (date == 'yesterday') {
+            var fecha = moment().add(-1, 'days').format('DD/MM/YYYY');
+          }
+          if (date == 'currentMonth') {
+            var fecha = moment().format('MMMM/YYYY');
+          }
+          if (date == 'lastMonth') {
+            var fecha = moment().add(-1, 'months').format('MMMM/YYYY');
+          }
+
+          filter.push({
+            title: 'Fecha',
+            value: fecha,
+          });
+        }
+      }
+      return filter;
+    },
+  });
+}

+ 670 - 0
static/src/js/reports/report_cash_advance.js

@@ -0,0 +1,670 @@
+function report_cash_advance(reporting) {
+  "use strict";
+  var model = openerp;
+
+  reporting.ReportCashdvanceWidget = reporting.Base.extend({
+    template: 'ReportCashAdvance',
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-date': 'ShowDateRange',
+      'change #current-store': 'updateEmployee',
+      'change #current-company': 'updateStore',
+      'change #current-period': 'updatePeriodSelections',
+    },
+
+    init: function(parent) {
+      this._super(parent);
+    },
+
+    start: function() {
+      var table = this.$el.find('#table');
+      table.bootstrapTable({
+        data: self.rowsData
+      });
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    ShowDateRange: function() {
+      var self = this;
+      var date = self.$el.find('#current-date').val();
+      if (date == 'range') {
+        self.$el.find('.datepicker').css('display', 'block');
+      }
+      if (date != 'range') {
+        self.$el.find('.datepicker').css('display', 'none');
+      }
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Registro de Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.employee_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.employee_id,
+        });
+      }
+
+      if (field == 'payslip') {
+        this.do_action({
+          name: "Nómina",
+          type: 'ir.actions.act_window',
+          res_model: "hr.payslip",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 1) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchAccountPeriod();
+      }).then(function(AccountPeriod) {
+        self.AccountPeriod = AccountPeriod;
+        if (AccountPeriod.length > 1) {
+          self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          _.each(AccountPeriod, function(item) {
+            self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.period').css('display', 'none');
+        }
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrPayslipInput().then(function(HrPayslipInput) {
+        return HrPayslipInput;
+      }).then(function(HrPayslipInput) {
+        self.HrPayslipInput = HrPayslipInput;
+        return self.fetchHrPayslip();
+      }).then(function(HrPayslip) {
+        self.HrPayslip = HrPayslip;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      company.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name', 'store_id'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchAccountPeriod: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var period = new model.web.Model('account.period');
+      var field = ['id', 'name','date_stop'];
+      period.query(field).filter().all().then(function(results) {
+        results.sort(function (a, b) {
+          if (a.date_stop > b.date_stop) {
+            return -1;
+          }
+          if (a.date_stop < b.date_stop) {
+            return 1;
+          }
+          return 0;
+        });
+        defer.resolve(results);
+      });
+
+      return defer;
+    },
+
+    fetchHrPayslip: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee_id = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+
+      var payslip_ids = _.flatten(_.map(self.HrPayslipInput, function(item) {
+        return item.id;
+      }));
+
+      var domain = [
+        ['input_line_ids', 'in', payslip_ids]
+      ];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (employee_id && employee_id != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee_id)]);
+      }
+
+      if (period && period != 9999999) {
+        domain.push(['period_id', '=', parseInt(period)]);
+      }
+
+      var fields = [
+        'id',
+        'company_id',
+        'employee_id',
+        'input_line_ids',
+      ];
+
+      var HrPayslip = new model.web.Model('hr.payslip');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslipInput: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+
+      var domain = [
+        ['code', '=', 'ADL']
+      ]
+
+      if (date && date != 9999999) {
+        if (desde) {
+          var date = desde.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '>=', date]);
+        }
+        if (hasta) {
+          var date = hasta.split('/')
+          date = (date[2] + "-" + date[1] + "-" + date[0]);
+          domain.push(['create_date', '<=', date]);
+        }
+        if (date == 'today') {
+          var today = moment().format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', today]);
+        }
+        if (date == 'yesterday') {
+          var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD ');
+          domain.push(['create_date', 'like', yesterday]);
+        }
+        if (date == 'currentMonth') {
+          var currentMonth = moment().format('YYYY-MM');
+          domain.push(['create_date', 'like', currentMonth]);
+        }
+        if (date == 'lastMonth') {
+          var lastMonth = moment().add(-1, 'months').format('YYYY-MM');
+          domain.push(['create_date', 'like', lastMonth]);
+        }
+      }
+
+      var fields = [
+        'id',
+        'code',
+        'name',
+        'payslip_id',
+        'create_date',
+        'amount',
+      ];
+
+      var HrPayslip = new model.web.Model('hr.payslip.input');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getHrPayslip: function(id) {
+      var self = this;
+      return _.filter(self.HrPayslip, function(a) {
+        return a.id === id;
+      })
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updatePeriodSelections: function() {
+      var self = this;
+      var period = self.$el.find('#current-period').val();
+      if (period != 9999999) {
+        self.$el.find('#current-date').val(9999999);
+        self.$el.find('#current-date').prop('disabled', 'disabled');
+        self.$el.find('.datepicker').css('display', 'none');
+      } else {
+        self.$el.find('#current-date').prop('disabled', false);
+      }
+    },
+
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+      var HrPayslipInput = self.HrPayslipInput;
+      _.each(HrPayslipInput, function(item) {
+        var HrPayslip = self.getHrPayslip(item.payslip_id[0]);
+        _.each(HrPayslip, function(index) {
+          data.push({
+            id: index.id,
+            employee_id: index.employee_id[0],
+
+            create_date: item.create_date,
+            employee_name: index.employee_id[1],
+            name: item.name,
+            payslip: item.payslip_id[1],
+            amount: accounting.formatMoney(item.amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+            amount_no_format: item.amount,
+
+            decimal_places: CurrencyBase.decimal_places,
+            thousands_separator: CurrencyBase.thousands_separator,
+            decimal_separator: CurrencyBase.decimal_separator,
+
+          });
+        })
+      });
+
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var action = self.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = self.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      var amount = amountFormatter(row);
+
+      row.push({
+        create_date: 'Totales',
+        amount: amount,
+      });
+
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Histórico de Adelantos';
+        var pdf_type = '';
+        var pdf_name = 'historico_de_adelantos_';
+        var pdf_columnStyles = {
+          create_date: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+
+          employee_name: {
+            columnWidth: 25,
+            halign: 'left'
+          },
+
+          payslip: {
+            halign: 'left'
+          },
+
+          name: {
+            columnWidth: 35,
+            halign: 'left'
+          },
+
+          amount: {
+            columnWidth: 25,
+            halign: 'center'
+          },
+        };
+
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var period = self.$el.find('#current-period').val();
+      var date = self.$el.find('#current-date').val();
+      var desde = self.$el.find('#from').val();
+      var hasta = self.$el.find('#to').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+      }
+
+      if (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        })
+        filter.push({
+          title: 'Periodo',
+          value: AccountPeriod[0].name,
+        });
+      }
+
+      if (date && date != 9999999) {
+        moment.locale('es', {
+          months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+        });
+
+        if (date == 'range') {
+          filter.push({
+            title: 'Fecha',
+            value: desde + ' al ' + hasta,
+          });
+
+        } else {
+          if (date == 'today') {
+            var fecha = moment().format('DD/MM/YYYY');
+          }
+
+          if (date == 'yesterday') {
+            var fecha = moment().add(-1, 'days').format('DD/MM/YYYY');
+          }
+          if (date == 'currentMonth') {
+            var fecha = moment().format('MMMM/YYYY');
+          }
+          if (date == 'lastMonth') {
+            var fecha = moment().add(-1, 'months').format('MMMM/YYYY');
+          }
+
+          filter.push({
+            title: 'Fecha',
+            value: fecha,
+          });
+        }
+      }
+      return filter;
+    },
+  });
+}

+ 633 - 0
static/src/js/reports/report_contract_list.js

@@ -0,0 +1,633 @@
+function report_contract_list(reporting) {
+  "use strict";
+
+  var model = openerp;
+
+  reporting.ReportContractListWidget = reporting.Base.extend({
+    template: 'ReportContractList',
+    AccountVoucher: [],
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-company': 'updateStore',
+      'chnage #current-store' : 'updateEmployee',
+    },
+    init: function(parent) {
+      this._super(parent);
+    },
+    start: function() {
+      var table = this.$el.find('#table');
+      table.bootstrapTable({
+        data: self.rowsData
+      });
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'name') {
+        this.do_action({
+          name: "Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.contract",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.employee_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.employee_id,
+        });
+      }
+
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 0) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchHrJob();
+      }).then(function(HrJob) {
+        self.HrJob = HrJob;
+        if (HrJob.length > 1) {
+          self.$el.find('#current-job').append('<option value="9999999">Todos los cargos</option>');
+          _.each(HrJob, function(item) {
+            self.$el.find('#current-job').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.job').css('display', 'none');
+        }
+        return self.fetchHrContractType();
+      }).then(function(HrContractType) {
+        self.HrContractType = HrContractType;
+        if (HrContractType.length > 1) {
+          self.$el.find('#current-type').append('<option value="9999999">Todos los tipos</option>');
+          _.each(HrContractType, function(item) {
+            self.$el.find('#current-type').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.type').css('display', 'none');
+        }
+        return self.fetchHrPayrollStructure();
+      }).then(function(HrPayrollStructure) {
+        self.HrPayrollStructure = HrPayrollStructure;
+        if (HrPayrollStructure.length > 1) {
+          self.$el.find('#current-struct').append('<option value="9999999">Todos los tipos</option>');
+          _.each(HrPayrollStructure, function(item) {
+            self.$el.find('#current-struct').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.struct').css('display', 'none');
+        }
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrContract().then(function(HrContract) {
+        return HrContract;
+      }).then(function(HrContract) {
+        self.HrContract = HrContract;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules],
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    /*====================================================================
+        RES COMPANY
+    ====================================================================*/
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var currency = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      currency.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrJob: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var job = new model.web.Model('hr.job');
+      var field = ['id', 'name'];
+      job.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrContractType: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var type = new model.web.Model('hr.contract.type');
+      var field = ['id', 'name'];
+      type.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayrollStructure: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var struct = new model.web.Model('hr.payroll.structure');
+      var field = ['id', 'name'];
+      struct.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrContract: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var domain = [];
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var job = self.$el.find('#current-job').val();
+      var type = self.$el.find('#current-type').val();
+      var struct = self.$el.find('#current-struct').val();
+
+
+      if (company && company != 9999999) {
+        domain.push(['employee_id.company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (employee && employee != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee)]);
+      }
+
+      if (job && job != 9999999) {
+        domain.push(['job_id', '=', parseInt(job)]);
+      }
+
+      if (type && type != 9999999) {
+        domain.push(['type_id', '=', parseInt(type)]);
+      }
+
+      if (struct && struct != 9999999) {
+        domain.push(['struct_id', '=', parseInt(struct)]);
+      }
+
+      var fields = [
+        'id',
+        'name',
+        'employee_id',
+        'name',
+        'job_id',
+        'type_id',
+        'wage',
+        'struct_id',
+        'date_start',
+        'date_end',
+
+      ];
+
+      var HrEmployee = new model.web.Model('hr.contract');
+      HrEmployee.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    /*====================================================================
+        BUILD
+    ====================================================================*/
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+
+      var HrContract = self.HrContract;
+      _.each(HrContract, function(item) {
+        if (item.date_end) {
+          var date_end = moment(item.date_end, 'YYYY-MM-DD').format('DD-MM-YYYY');
+        } else {
+          var date_end = 'En curso';
+        }
+
+        data.push({
+          id: item.id,
+          employee_id: self.valorNull(item.employee_id[0]),
+
+          name: self.valorNull(item.name),
+          employee_name: self.valorNull(item.employee_id[1]),
+          job_id: self.valorNull(item.job_id[1]),
+          type_id: self.valorNull(item.type_id[1]),
+          wage: accounting.formatMoney(item.wage, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          struct_id: self.valorNull(item.struct_id[1]),
+          date_start: moment(item.date_start, 'YYYY-MM-DD').format('DD-MM-YYYY'),
+          date_end: date_end,
+
+          wage_no_format: item.wage,
+
+          decimal_places: CurrencyBase.decimal_places,
+          thousands_separator: CurrencyBase.thousands_separator,
+          decimal_separator: CurrencyBase.decimal_separator,
+        });
+      });
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var ResCompany;
+      var action = this.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = this.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      var wage = wageFormatter(row);
+
+      row.push({
+        name:'Totales',
+        wage: wage,
+      });
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Lista de Contratos';
+        var pdf_type = '';
+        var pdf_name = 'lista_de_contratos_';
+        var pdf_columnStyles = {
+          name: {
+            halign: 'left'
+          },
+          employee_name: {
+            columnWidth: 25,
+            halign: 'left'
+          },
+          job_id: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+          type_id: {
+            columnWidth: 20,
+            halign: 'left'
+          },
+          wage: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+          struct_id: {
+            columnWidth: 19,
+            halign: 'center'
+          },
+          date_start: {
+            columnWidth: 16,
+            halign: 'center'
+          },
+          date_end: {
+            columnWidth: 22,
+            halign: 'center'
+          },
+        };
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var job = self.$el.find('#current-job').val();
+      var type = self.$el.find('#current-type').val();
+      var struct = self.$el.find('#current-struct').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+      }
+
+      if (job && job != 9999999) {
+        var HrJob = _.filter(self.HrJob, function(item) {
+          return item.id == job;
+        });
+
+        filter.push({
+          title: 'Cargo',
+          value: HrJob[0].name,
+        });
+      }
+
+      if (type && type != 9999999) {
+        var HrContractType = _.filter(self.HrContractType, function(item) {
+          return item.id == type;
+        });
+
+        filter.push({
+          title: 'Tipo de Contrato',
+          value: HrContractType[0].name,
+        });
+      }
+
+      if (struct && struct != 9999999) {
+        var HrPayrollStructure = _.filter(self.HrPayrollStructure, function(item) {
+          return item.id == struct;
+        });
+
+        filter.push({
+          title: 'Estructura Salarial',
+          value: HrPayrollStructure[0].name,
+        });
+      }
+      return filter;
+    },
+  });
+}

+ 397 - 0
static/src/js/reports/report_employee_list.js

@@ -0,0 +1,397 @@
+function report_employee_list(reporting) {
+  "use strict";
+
+  var model = openerp;
+
+  reporting.ReportEmployeeListWidget = reporting.Base.extend({
+    template: 'ReportEmployeeList',
+    AccountVoucher: [],
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-company': 'updateStore',
+    },
+    init: function(parent) {
+      this._super(parent);
+    },
+    start: function() {
+      var table = this.$el.find('#table');
+      table.bootstrapTable({
+        data: self.rowsData
+      });
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'name') {
+        this.do_action({
+          name: "Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 1) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrEmployee().then(function(HrEmployee) {
+        return HrEmployee;
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules],
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    /*====================================================================
+        RES COMPANY
+    ====================================================================*/
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var currency = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      currency.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name','company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var state = self.$el.find('#current-state').val();
+
+      var domain = [
+        '|', ['active', '=', true],
+        ['active', '=', false]
+      ];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['store_id', '=', parseInt(store)]);
+      }
+
+      if (state && state != 9999999) {
+        if (state == 'activo') {
+          domain.push(['active', '=', true]);
+        } else {
+          domain.push(['active', '=', false]);
+        }
+      }
+
+      var fields = [
+        'id',
+        'company_id',
+        'name',
+        'identification_id',
+        'work_email',
+        'work_phone',
+        'job_id',
+        'contracts_count',
+        'leaves_count',
+        'payslip_count',
+
+      ];
+
+      var HrEmployee = new model.web.Model('hr.employee');
+      HrEmployee.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    /*====================================================================
+        BUILD
+    ====================================================================*/
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+
+      var HrEmployee = self.HrEmployee;
+      _.each(HrEmployee, function(item) {
+        data.push({
+          id: item.id,
+          name: self.valorNull(item.name),
+          company_id: self.valorNull(item.company_id[1]),
+          identification_id: self.valorNull(item.identification_id),
+          work_email: self.valorNull(item.work_email),
+          work_phone: self.valorNull(item.work_phone),
+          job_id: self.valorNull(item.job_id[1]),
+          contracts_count: item.contracts_count,
+          payslip_count: item.payslip_count,
+        });
+      });
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var ResCompany;
+      var action = this.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = this.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      row.push({});
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Lista de Funcionarios';
+        var pdf_type = '';
+        var pdf_name = 'lista_de_funcionarios_';
+        var pdf_columnStyles = {
+          identification_id: {
+            columnWidth: 15,
+            halign: 'center'
+          },
+          name: {
+            halign: 'left'
+          },
+          job_id: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+          work_email: {
+            columnWidth: 50,
+            halign: 'left'
+          },
+          work_phone: {
+            columnWidth: 18,
+            halign: 'center'
+          },
+          contracts_count: {
+            columnWidth: 19,
+            halign: 'center'
+          },
+          payslip_count: {
+            columnWidth: 19,
+            halign: 'center'
+          },
+        };
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var state = self.$el.find('#current-state').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (state && state != 9999999) {
+        filter.push({
+          title: 'Estado',
+          value: $('#current-state option:selected').text(),
+        });
+      }
+      return filter;
+    },
+  });
+}

+ 731 - 0
static/src/js/reports/report_payslip.js

@@ -0,0 +1,731 @@
+function report_payslip(reporting) {
+  "use strict";
+
+  var model = openerp;
+
+  reporting.ReportPayslipWidget = reporting.Base.extend({
+    template: 'ReportPayslip',
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-store': 'updateEmployee',
+      'change #current-company': 'updateStore',
+    },
+
+    init: function(parent) {
+      this._super(parent);
+    },
+
+    start: function() {
+      var table = this.$el.find('#table');
+      table.bootstrapTable({
+        data: self.rowsData
+      });
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.employee_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.employee_id,
+        });
+      }
+      if (field == 'name') {
+        this.do_action({
+          name: "Nómina",
+          type: 'ir.actions.act_window',
+          res_model: "hr.payslip",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+
+      if (field == 'contract_name') {
+        this.do_action({
+          name: "Contrato",
+          type: 'ir.actions.act_window',
+          res_model: "hr.contract",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.contract_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.contract_id,
+        });
+      }
+
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 1) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchHrPayrollStructure();
+      }).then(function(HrPayrollStructure) {
+        self.HrPayrollStructure = HrPayrollStructure;
+        if (HrPayrollStructure.length > 1) {
+          self.$el.find('#current-structure').append('<option value="9999999">Todos los tipos</option>');
+          _.each(HrPayrollStructure, function(item) {
+            self.$el.find('#current-structure').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.structure').css('display', 'none');
+        }
+        return self.fetchAccountPeriod();
+      }).then(function(AccountPeriod){
+        self.AccountPeriod = AccountPeriod;
+        if (AccountPeriod.length > 1) {
+          self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          _.each(AccountPeriod, function(item) {
+            self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.period').css('display', 'none');
+        }
+        return self.fetchHrPayslipLine();
+      }).then(function(HrPayslipLine) {
+        self.HrPayslipLine = HrPayslipLine;
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrPayslip().then(function(HrPayslip) {
+        return HrPayslip;
+      }).then(function(HrPayslip) {
+        self.HrPayslip = HrPayslip;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var currency = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      currency.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name','store_id'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayrollStructure: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var structure = new model.web.Model('hr.payroll.structure');
+      var field = ['id', 'name'];
+      structure.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslipLine: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var line = new model.web.Model('hr.payslip.line');
+      var field = ['id', 'name', 'code', 'total'];
+      line.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchAccountPeriod: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var period = new model.web.Model('account.period');
+      var field = ['id', 'name','date_stop'];
+      period.query(field).filter().all().then(function(results) {
+        results.sort(function (a, b) {
+          if (a.date_stop > b.date_stop) {
+            return -1;
+          }
+          if (a.date_stop < b.date_stop) {
+            return 1;
+          }
+          return 0;
+        });
+        defer.resolve(results);
+      });
+
+      return defer;
+    },
+
+    fetchHrPayslip: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var state = self.$el.find('#current-state').val();
+      var employee_id = self.$el.find('#current-employee').val();
+      var struct_id = self.$el.find('#current-structure').val();
+      var period = self.$el.find('#current-period').val();
+      var domain = [];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (state && state != 9999999) {
+        domain.push(['state', '=', state]);
+      }
+
+      if (employee_id && employee_id != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee_id)]);
+      }
+
+      if (struct_id && struct_id != 9999999) {
+        domain.push(['struct_id', '=', parseInt(struct_id)]);
+      }
+
+      if (period && period != 9999999){
+        domain.push(['period_id','=', parseInt(period)]);
+      }
+
+      var fields = [
+        'id',
+        'employee_id',
+        'name',
+        'number',
+        'contract_id',
+        'struct_id',
+        'state',
+        'line_ids',
+        'period_id'
+      ];
+      var HrPayslip = new model.web.Model('hr.payslip');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getAmount: function(line_ids, code) {
+      var self = this;
+      var amount = 0;
+      amount =  _.map(_.filter(self.HrPayslipLine, function(a) {
+        return _.find(line_ids, function(b) {
+          return b === a.id && a.code == code;
+        });
+      }), function(map) {
+        return map.total;
+      });
+
+      if(amount.length == 0){
+        return 0
+      }
+      else {
+        return amount[0];
+      }
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+
+      var HrPayslip = self.HrPayslip;
+      _.each(HrPayslip, function(item) {
+
+        if (item.state == 'done') {
+          var state = 'Hecho';
+        }
+        if (item.state == 'cancel') {
+          var state = 'Cancelado';
+        }
+        if (item.state == 'paid') {
+          var state = 'Pagado';
+        }
+
+        var salary = self.getAmount(item.line_ids, "BASIC");
+        var ips = self.getAmount(item.line_ids, "IPSE");
+        var cash_advance = self.getAmount(item.line_ids, "ADPER");
+        var bonus = self.getAmount(item.line_ids, "CMS");
+        var faltas = self.getAmount(item.line_ids, "FALTAS");
+        var neto = self.getAmount(item.line_ids,"NET");
+
+        data.push({
+          id: item.id,
+          contract_id : self.valorNull(item.contract_id[0]),
+          employee_id: self.valorNull(item.employee_id[0]),
+
+          employee_name: self.valorNull(item.employee_id[1]),
+          number: self.valorNull(item.number),
+          name: self.valorNull(item.name),
+          contract_name: self.valorNull(item.contract_id[1]),
+          struct_id: self.valorNull(item.struct_id[1]),
+          salary: accounting.formatMoney(salary, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          ips: accounting.formatMoney(ips, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          faltas: accounting.formatMoney(faltas, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          cash_advance: accounting.formatMoney(cash_advance, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          bonus: accounting.formatMoney(bonus, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          neto: accounting.formatMoney(salary+bonus-faltas, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          totsalary: accounting.formatMoney((salary+cash_advance), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          state: state,
+          period_id: item.period_id,
+
+          salary_no_format: salary,
+          totsalary_no_format: (salary+cash_advance),
+          ips_no_format: ips,
+          cash_advance_no_format: cash_advance,
+          bonus_no_format: bonus,
+          neto_no_format: salary+bonus-faltas,
+          faltas_no_format: faltas,
+
+          decimal_places : CurrencyBase.decimal_places,
+          thousands_separator: CurrencyBase.thousands_separator,
+          decimal_separator: CurrencyBase.decimal_separator,
+
+        });
+      });
+      data.sort(function (a, b) {
+        if (a.period_id > b.period_id) {
+          return -1;
+        }
+        if (a.period_id < b.period_id) {
+          return 1;
+        }
+        return 0;
+      });
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var action = self.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = self.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      var salary = salaryFormatter(row);
+      var ips = ipsFormatter(row);
+      var cash_advance = cash_advanceFormatter(row);
+      var bonus = bonusFormatter(row);
+      var faltas = faltasFormatter(row);
+      var neto = netoFormatter(row);
+      var totsalary = totsalaryFormatter(row);
+
+      row.push({
+        employee_name: 'Totales',
+        salary : salary,
+        ips : ips,
+        cash_advance : cash_advance,
+        bonus : bonus,
+        faltas : faltas,
+        neto : neto,
+        totsalary : totsalary,
+      });
+
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Análisis de Nóminas';
+        var pdf_type = 'l';
+        var pdf_name = 'analisis_de_nominas_';
+        var pdf_columnStyles = {
+          employee_name: {
+            columnWidth: 25,
+            halign: 'left'
+          },
+          number: {
+            columnWidth: 14,
+            halign: 'center'
+          },
+          name: {
+            halign: 'left'
+          },
+          contract_name: {
+            columnWidth: 30,
+            halign: 'left'
+          },
+          struct_id: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+          salary: {
+            columnWidth: 23,
+            halign: 'center'
+          },
+          ips: {
+            columnWidth: 22,
+            halign: 'center'
+          },
+          cash_advance: {
+            columnWidth: 22,
+            halign: 'center'
+          },
+          bonus: {
+            columnWidth: 22,
+            halign: 'center'
+          },
+          faltas: {
+            columnWidth: 20,
+            halign: 'center'
+          },
+          neto: {
+            columnWidth: 25,
+            halign: 'center'
+          },
+          totsalary: {
+            columnWidth: 25,
+            halign: 'center'
+          },
+          state: {
+            columnWidth: 13,
+            halign: 'center'
+          },
+        };
+
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var structure = self.$el.find('#current-structure').val();
+      var state = self.$el.find('#current-state').val();
+      var period = self.$el.find('#current-period').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+
+      }
+      if (structure && structure != 9999999) {
+        var HrPayrollStructure = _.filter(self.HrPayrollStructure, function(item) {
+          return item.id == structure;
+        })
+        filter.push({
+          title: 'Estructura Salarial',
+          value: HrPayrollStructure[0].name,
+        });
+      }
+
+      if (state && state != 9999999) {
+        filter.push({
+          title: 'Estado',
+          value: $('#current-state option:selected').text(),
+        });
+      }
+
+      if (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        })
+        filter.push({
+          title: 'Período',
+          value: AccountPeriod[0].name,
+        });
+      }
+
+      return filter;
+    },
+  });
+}

+ 876 - 0
static/src/js/reports/report_payslip_egreso.js

@@ -0,0 +1,876 @@
+function report_payslip_egreso(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPayslipEgresoWidget = reporting.Base.extend({
+        template: 'ReportPayslipEgreso',
+        rowsData :[],
+        content :[],
+        modules: ['hr'],
+
+        events:{
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'change #current-store' : 'updateJournalSelections',
+            'change #current-date' : 'ShowDateRange',
+            'click .print-report':'clickOnAction',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model;
+            });
+        },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            if(date == 'range'){
+                self.$el.find('.datepicker').css('display','block');
+            }
+            if(date != 'range'){
+                self.$el.find('.datepicker').css('display','none');
+            }
+        },
+
+        fetchInitial: function() {
+          var self = this;
+          self.fecthIrModuleModule().then(function(IrModuleModule) {
+            return IrModuleModule;
+          }).then(function(IrModuleModule) {
+            self.IrModuleModule = IrModuleModule;
+            return self.fetchResCompany();
+          }).then(function(ResCompany) {
+            self.ResCompany = ResCompany;
+            if (ResCompany.length > 1) {
+              self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+              _.each(ResCompany, function(item) {
+                self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+              });
+            } else {
+              self.$el.find('.company').css('display', 'none');
+            }
+            return self.fetchResStore();
+          }).then(function(ResStore) {
+            self.ResStore = ResStore;
+            if (ResStore.length > 1) {
+              self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+              _.each(ResStore, function(item) {
+                self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+              });
+            } else {
+              self.$el.find('.store').css('display', 'none');
+            }
+            return self.fetchHrEmployee();
+          }).then(function(HrEmployee) {
+            self.HrEmployee = HrEmployee;
+            if (HrEmployee.length > 1) {
+              self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+              _.each(HrEmployee, function(item) {
+                self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+              });
+            } else {
+              self.$el.find('.employee').css('display', 'none');
+            }
+            return self.fetchHrPayrollStructure();
+          }).then(function(HrPayrollStructure) {
+            self.HrPayrollStructure = HrPayrollStructure;
+            if (HrPayrollStructure.length > 1) {
+              self.$el.find('#current-structure').append('<option value="9999999">Todos los tipos</option>');
+              _.each(HrPayrollStructure, function(item) {
+                self.$el.find('#current-structure').append('<option value="' + item.id + '">' + item.name + '</option>');
+              });
+            } else {
+              self.$el.find('.structure').css('display', 'none');
+            }
+          //   return self.fetchAccountPeriod();
+          // }).then(function(AccountPeriod){
+          //   self.AccountPeriod = AccountPeriod;
+          //   if (AccountPeriod.length > 1) {
+          //     self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          //     _.each(AccountPeriod, function(item) {
+          //       self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          //     });
+          //   } else {
+          //     self.$el.find('.period').css('display', 'none');
+          //   }
+            return self.fetchAccountVoucher();
+          }).then(function (AccountVoucher) {
+              self.AccountVoucher = AccountVoucher;
+              return self.fetchAccountInvoice();
+          }).then(function(AccountInvoice){
+              self.AccountInvoice = AccountInvoice;
+              return self.fetchAccountJournal();
+          }).then(function (AccountJournal) {
+              self.AccountJournal =AccountJournal;
+              self.$el.find('#current-journal').append('<option value="9999999">Todos los pagos</option>');
+              _.each(AccountJournal, function (item) {
+                  self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+              });
+            return self.fetchHrPayslipLine();
+          }).then(function(HrPayslipLine) {
+            self.HrPayslipLine = HrPayslipLine;
+            return self.fetchResCurrency();
+          }).then(function(ResCurrency) {
+            self.ResCurrency = ResCurrency;
+          });
+          self.$el.find('#generate').css('display', 'inline');
+          return;
+        },
+
+        fetchGenerate: function() {
+          var self = this;
+          self.$el.find('.search-form').block({
+            message: null,
+            overlayCSS: {
+              backgroundColor: '#FAFAFA'
+            }
+          });
+          self.$el.find('.report-form').block({
+            message: null,
+            overlayCSS: {
+              backgroundColor: '#FAFAFA'
+            }
+          });
+
+          this.fetchHrPayslip().then(function(HrPayslip){
+            return HrPayslip;
+          }).then(function(HrPayslip){
+            self.HrPayslip = HrPayslip;
+            return self.BuildTable();
+          });
+        },
+
+        fecthIrModuleModule: function() {
+          var self = this;
+          var defer = $.Deferred();
+          var fields = ['name', 'id'];
+          var domain = [
+            ['state', '=', 'installed'],
+            ['name', 'in', self.modules]
+          ];
+          var IrModuleModule = new model.web.Model('ir.module.module');
+          IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+            defer.resolve(results);
+          })
+          return defer;
+        },
+
+
+        getAmount: function(line_ids, code) {
+          var self = this;
+          var amount = 0;
+          amount =  _.map(_.filter(self.HrPayslipLine, function(a) {
+            return _.find(line_ids, function(b) {
+              return b === a.id && a.code == code;
+            });
+          }), function(map) {
+            return map.total;
+          });
+
+          if(amount.length == 0){
+            return 0
+          }
+          else {
+            return amount[0];
+          }
+        },
+
+
+        fetchResCompany: function() {
+          var self = this;
+          var defer = $.Deferred();
+          var currency = new model.web.Model('res.company');
+          var field = ['id', 'name', 'currency_id', 'logo'];
+          currency.query(field).filter().all().then(function(results) {
+            defer.resolve(results);
+          });
+          return defer;
+        },
+
+
+        // fetchIntialSQL: function() {
+        //     var self = this;
+        //     var data = $.get('/report-filter-data');
+        //     return data;
+        // },
+        //
+        // fetchDataSQL: function() {
+        //     var self = this;
+        //     var data = $.get('/report-supplier-account-voucher');
+        //     return data;
+        // },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var store;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var journal;
+            var AccountJournal = _.flatten(_.filter(self.AccountJournal,function (item) {
+                return item.type == 'cash' || item.type == 'bank';
+            }));
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todos los métodos de pago</option>');
+                _.each(AccountJournal,function(item){
+                    if(item.store_id == store){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todos los métodos de pago</option>');
+                _.each(AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        getAccountVoucher:function(number) {
+            var self = this;
+            var content = self.AccountVoucher;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var journal = self.$el.find('#current-journal').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            content = _.filter(content,function (item) {
+                return item.reference == number;
+            })
+
+            if((store && store == 9999999)||(company && company == 9999999)){
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                    return item.id;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                }));
+            }
+
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(journal && journal != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.journal_id == journal;
+                }));
+            }
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+            return content;
+        },
+
+        fetchAccountVoucher: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var AccountVoucher = new model.web.Model('account.voucher');
+            AccountVoucher.query(['id', 'number','reference','partner_id','journal_id','amount','date','number','type']).filter([['state', '=', 'posted']]).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        // fetchAccountInvoice: function () {
+        //     var self = this;
+        //     var defer = $.Deferred();
+        //     var AccountInvoice = new model.web.Model('account.invoice');
+        //     AccountInvoice.query(['id','number']).filter(['type', '=', 'out_invoice'],[['state', 'in', ['open','paid']]]).all().then(function(results){
+        //         defer.resolve(results);
+        //     });
+        //     return defer;
+        //  },
+
+         // Invoice (FACTURAS)
+        fetchAccountInvoice: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var filter =[['state', 'in',['open','paid']],['type', '=', 'in_invoice']];
+
+            var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice'];
+            var AccountInvoice = new model.web.Model('account.invoice');
+            AccountInvoice.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+         getResCompany: function(id) {
+            var self = this;
+            return _.filter(self.ResCompany, function(item) {
+              return item.id == id;
+            })
+          },
+
+          fetchResStore: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var store = new model.web.Model('res.store');
+            var field = ['id', 'name', 'company_id'];
+            store.query(field).filter().all().then(function(results) {
+              defer.resolve(results);
+            });
+            return defer;
+          },
+
+          fetchResCurrency: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+            var domain = [
+              ['active', '=', true]
+            ];
+            var ResCurrency = new model.web.Model('res.currency');
+            ResCurrency.query(fields).filter(domain).all().then(function(results) {
+              defer.resolve(results);
+            });
+            return defer;
+          },
+
+          getResCurrency: function(id) {
+            var self = this;
+            return _.filter(self.ResCurrency, function(item) {
+              return item.id === id;
+            })
+          },
+
+          fetchHrEmployee: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var employee = new model.web.Model('hr.employee');
+            var field = ['id', 'name','store_id'];
+            employee.query(field).filter().all().then(function(results) {
+              defer.resolve(results);
+            });
+            return defer;
+          },
+
+          fetchAccountJournal: function () {
+             var self = this;
+             var defer = $.Deferred();
+             var AccountJournal = new model.web.Model('account.journal');
+             AccountJournal.query(['id','name']).filter([['active','=',true],['type', 'in', ['bank','cash']]]).all().then(function(results){
+                 defer.resolve(results);
+             });
+             return defer;
+         },
+
+         fetchHrPayrollStructure: function() {
+             var self = this;
+             var defer = $.Deferred();
+             var structure = new model.web.Model('hr.payroll.structure');
+             var field = ['id', 'name'];
+             structure.query(field).filter().all().then(function(results) {
+               defer.resolve(results);
+             });
+             return defer;
+           },
+
+           fetchHrPayslipLine: function() {
+             var self = this;
+             var defer = $.Deferred();
+             var line = new model.web.Model('hr.payslip.line');
+             var domain = [
+               ['code', '=', "NET"]
+             ];
+
+             var field = ['id', 'name', 'code',  'slip_id', 'total'];
+             line.query(field).filter(domain).all().then(function(results) {
+               defer.resolve(results);
+             });
+             return defer;
+           },
+
+
+           fetchHrPayslip: function() {
+             var self = this;
+             var defer = $.Deferred();
+             var company = self.$el.find('#current-company').val();
+             var store = self.$el.find('#current-store').val();
+             var state = self.$el.find('#current-state').val();
+             var period = self.$el.find('#current-period').val();
+             var date = self.$el.find('#current-date').val();
+             var desde = self.$el.find('#from').val();
+             var hasta = self.$el.find('#to').val();
+             var domain = [['state', 'in', ['done','paid']]];
+
+             if (company && company != 9999999) {
+               domain.push(['company_id', '=', parseInt(company)]);
+             }
+
+             if (store && store != 9999999) {
+               domain.push(['employee_id.store_id', '=', parseInt(store)]);
+             }
+
+             if (state && state != 9999999) {
+               domain.push(['state', '=', state]);
+             }
+
+             if (period && period != 9999999){
+               domain.push(['period_id','=', parseInt(period)]);
+             }
+
+             var fields = [
+               'id',
+               'employee_id',
+               'name',
+               'number',
+               'date_to',
+               'contract_id',
+               'struct_id',
+               'state',
+               'line_ids',
+             ];
+             var HrPayslip = new model.web.Model('hr.payslip');
+             HrPayslip.query(fields).filter(domain).all().then(function(results) {
+               defer.resolve(results);
+             });
+             return defer;
+           },
+
+
+
+
+           getHrPayslip:function(id) {
+               var self = this;
+               var content = self.HrPayslip;
+               var company = self.$el.find('#current-company').val();
+               var store = self.$el.find('#current-store').val();
+               var journal = self.$el.find('#current-journal').val();
+               var date = self.$el.find('#current-date').val();
+               var desde = self.$el.find('#from').val();
+               var hasta = self.$el.find('#to').val();
+
+               content = _.filter(content,function (item) {
+                   return item.id == id;
+               })
+
+               if((store && store == 9999999)||(company && company == 9999999)){
+                   var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                       return item.id;
+                   }));
+                   var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                       return item.id;
+                   }));
+                   content = _.flatten(_.filter(content,function (item) {
+                       return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                   }));
+               }
+
+               if(company && company != 9999999){
+                   content = _.flatten(_.filter(content,function (item) {
+                       return item.company_id == company;
+                   }));
+               }
+               if(store && store != 9999999){
+                   content = _.flatten(_.filter(content,function (item) {
+                       return item.store_id == store;
+                   }));
+               }
+               if(journal && journal != 9999999){
+                   content = _.flatten(_.filter(content,function (item) {
+                       return item.journal_id == journal;
+                   }));
+               }
+               if(date && date != 9999999){
+                   if(date == 'range'){
+                       if(desde){
+                           date = desde.split('/');
+                           date = (date[2]+"-"+date[1]+"-"+date[0]);
+                           content = _.flatten(_.filter(content,function (inv) {
+                               return moment(inv.date_to).format('YYYY-MM-DD') >= date;
+                           }));
+                       }
+                       if(hasta){
+                           date = hasta.split('/');
+                           date = (date[2]+"-"+date[1]+"-"+date[0]);
+                           content = _.flatten(_.filter(content,function (inv) {
+                               return moment(inv.date_to).format('YYYY-MM-DD') <= date;
+                           }));
+                       }
+                   }
+                   if(date == 'today'){
+                       var today = moment().format('YYYY-MM-DD');
+                       content = _.flatten(_.filter(content,function (inv) {
+                           return moment(inv.date_to).format('YYYY-MM-DD') === today;
+                       }));
+                   }
+                   if(date == 'yesterday'){
+                       var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                       content = _.flatten(_.filter(content,function (inv) {
+                           return moment(inv.date_to).format('YYYY-MM-DD') === yesterday;
+                       }));
+                   }
+                   if(date == 'currentMonth'){
+                       var currentMonth = moment().format('YYYY-MM');
+                       content = _.flatten(_.filter(content,function (inv) {
+                           return moment(inv.date_to).format('YYYY-MM') === currentMonth;
+                       }));
+                   }
+                   if(date == 'lastMonth'){
+                       var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                       content = _.flatten(_.filter(content,function (inv) {
+                           return moment(inv.date_to).format('YYYY-MM') === lastMonth;
+                       }));
+                   }
+               }
+               return content;
+           },
+
+           // getHrPayslip: function (id){
+           //      return _.find(this.HrPayslip, function (inv) {
+           //          return _.contains(inv.id, id);
+           //      });
+           //    },
+
+
+
+        BuildTable: function(){
+            var self = this;
+
+            var data = [];
+
+            var CurrencyBase = self.ResCompany[0].currency_id;
+
+              var AccountInvoice = self.AccountInvoice;
+
+
+            _.each(AccountInvoice, function(each){
+        
+              var AccountVoucher = self.getAccountVoucher(each.number);
+
+              _.each(AccountVoucher, function(item){
+
+                var amount = item.amount;
+                if(item.currency_id != null){
+                    amount = amount + '('  + item.amount + ')';
+                }
+
+                data.push({
+                    id:item.id,
+                    date:moment(item.date).format('DD/MM/YYYY'),
+                    name:item.reference,
+                  //  reference:item.reference,
+                    total:accounting.formatMoney(amount,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
+                    /*
+                    =======================
+                        NO FORMAT
+                    =======================
+                    */
+                    date_no_format: moment(item.date).format('YYYY-MM-DD'),
+                    total_no_format:item.amount,
+                    /*
+                    =======================
+                        FOOTER
+                    =======================
+                    */
+                    decimal_places:CurrencyBase.decimal_places,
+                    thousands_separator:CurrencyBase.thousands_separator,
+                    decimal_separator:CurrencyBase.decimal_separator,
+                });
+              });
+            });
+
+
+                var HrPayslipline = self.HrPayslipLine;
+
+                    var total_neto = 0;
+
+
+                    _.each(HrPayslipline, function(item) {
+
+
+
+                    //  console.log(item);
+
+                      var hrpayslip = self.getHrPayslip(item.slip_id[0]);
+
+                      _.each(hrpayslip, function(index) {
+
+                          if (hrpayslip.state == 'done') {
+                            var state = 'Hecho';
+                          }
+
+                          if (hrpayslip.state == 'paid') {
+                            var state = 'Pagado';
+                          }
+
+
+                        data.push({
+                              id:item.id,
+                              name: item.slip_id[1],
+                              date: moment(index.date_to).format("DD/MM/YYYY"),
+                              date_no_format:  index.date_to,
+                              total : accounting.formatMoney(item.total,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
+                              total_no_format : item.total,
+
+                              decimal_places:CurrencyBase.decimal_places,
+                              thousands_separator:CurrencyBase.thousands_separator,
+                              decimal_separator:CurrencyBase.decimal_separator,
+
+                        });
+                    });
+                });
+
+
+
+            data.sort(function (a, b) {
+                if (a.date_no_format > b.date_no_format) {
+                    return -1;
+                }
+                if (a.date_no_format < b.date_no_format) {
+                    return 1;
+                }
+                return 0;
+            });
+            self.content = data;
+            self.loadTable(data);
+            self.$el.find('.report-form').css('display','block');
+            self.$el.find('.search-form').unblock();
+            self.$el.find('.report-form').unblock();
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var CurrencyBase;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if (company && company != 9999999) {
+              var ResCompany = self.getResCompany(company).shift();
+
+            } else {
+              var ResCompany = self.ResCompany[0];
+            }
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var total = TotalFooter(row);
+          //  var total = totalFormatter(row);
+            row.push({
+                date:'Totales',
+                total:total,
+            });
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){
+                    return val.field;
+                });
+                _.each(_.map(column,function(val){
+                    return val;
+                }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Egresos con egresos y nóminas.';
+                var pdf_type = '';
+                var pdf_name = 'egresosconegresosynominas';
+                var pdf_columnStyles = {
+                    date:{columnWidth: 20, halign:'center'},
+                    name:{columnWidth: 'auto', halign:'center'},
+                    total:{columnWidth: 20, halign:'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter
+                );
+            }
+        },
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var state = self.$el.find('#current-state').val();
+            var journal = self.$el.find('#current-journal').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var filter = [];
+            if(company && company != 9999999){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            }
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                        return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            }
+            if(journal && journal != 9999999){
+                var AccountJournal =  _.filter(self.AccountJournal,function (item) {
+                    return item.id == journal;
+                });
+                filter.push({
+                   title: 'Método de pago',
+                   value: AccountJournal[0].name,
+                });
+            }
+            if(date && date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+
+                if(date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde +' al '+hasta,
+                    });
+                }else {
+                    var fecha;
+                    if(date == 'today'){
+                        fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                }
+            }
+            return filter;
+        },
+    });
+}

+ 764 - 0
static/src/js/reports/report_payslip_run.js

@@ -0,0 +1,764 @@
+function report_payslip_run(reporting) {
+  "use strict";
+
+  var model = openerp;
+
+  reporting.ReportPayslipRunWidget = reporting.Base.extend({
+    template: 'ReportPayslipRun',
+    content: [],
+    rowsData: [],
+    modules: ['hr'],
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'click-row.bs.table #table ': 'clickAnalysisDetail',
+      'change #current-store': 'updateEmployee',
+      'change #current-company': 'updateStore',
+    },
+
+    init: function(parent) {
+      this._super(parent);
+    },
+
+    start: function() {
+      var date = new model.eiru_reports.ReportDatePickerWidget(self);
+      date.fecthFecha();
+      this.fetchInitial();
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.modules, function(item) {
+        return item.name === model
+      });
+    },
+
+    valorNull: function(dato) {
+      var valor = "";
+      if (dato) {
+        valor = dato;
+      }
+      return valor;
+    },
+
+    clickAnalysisDetail: function(e, row, $element, field) {
+      if (field == 'name') {
+        this.do_action({
+          name: "Procesamiento de Nóminas",
+          type: 'ir.actions.act_window',
+          res_model: "hr.payslip.run",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.id,
+        });
+      }
+
+      if (field == 'employee_name') {
+        this.do_action({
+          name: "Funcionario",
+          type: 'ir.actions.act_window',
+          res_model: "hr.employee",
+          views: [
+            [false, 'form']
+          ],
+          target: 'new',
+          domain: [
+            ['id', '=', row.employee_id]
+          ],
+          context: {},
+          flags: {
+            'form': {
+              'action_buttons': false,
+              'options': {
+                'mode': 'view'
+              }
+            }
+          },
+          res_id: row.employee_id,
+        });
+      }
+
+      e.stopImmediatePropagation();
+    },
+
+    fetchInitial: function() {
+      var self = this;
+      self.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResCompany();
+      }).then(function(ResCompany) {
+        self.ResCompany = ResCompany;
+        if (ResCompany.length > 1) {
+          self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+          _.each(ResCompany, function(item) {
+            self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.company').css('display', 'none');
+        }
+        return self.fetchResStore();
+      }).then(function(ResStore) {
+        self.ResStore = ResStore;
+        if (ResStore.length > 1) {
+          self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+          _.each(ResStore, function(item) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.store').css('display', 'none');
+        }
+        return self.fetchHrEmployee();
+      }).then(function(HrEmployee) {
+        self.HrEmployee = HrEmployee;
+        if (HrEmployee.length > 1) {
+          self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+          _.each(HrEmployee, function(item) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.employee').css('display', 'none');
+        }
+        return self.fetchHrPayrollStructure();
+      }).then(function(HrPayrollStructure) {
+        self.HrPayrollStructure = HrPayrollStructure;
+        if (HrPayrollStructure.length > 1) {
+          self.$el.find('#current-structure').append('<option value="9999999">Todos los tipos</option>');
+          _.each(HrPayrollStructure, function(item) {
+            self.$el.find('#current-structure').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.structure').css('display', 'none');
+        }
+        return self.fetchAccountPeriod();
+      }).then(function(AccountPeriod){
+        self.AccountPeriod = AccountPeriod;
+        if (AccountPeriod.length > 1) {
+          self.$el.find('#current-period').append('<option value="9999999">Todos los períodos</option>');
+          _.each(AccountPeriod, function(item) {
+            self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+          });
+        } else {
+          self.$el.find('.period').css('display', 'none');
+        }
+        return self.fetchHrPayslipLine();
+      }).then(function(HrPayslipLine) {
+        self.HrPayslipLine = HrPayslipLine;
+        return self.fetchResCurrency();
+      }).then(function(ResCurrency) {
+        self.ResCurrency = ResCurrency;
+      });
+      self.$el.find('#generate').css('display', 'inline');
+      return;
+    },
+
+    fetchGenerate: function() {
+      var self = this;
+      self.$el.find('.search-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+      self.$el.find('.report-form').block({
+        message: null,
+        overlayCSS: {
+          backgroundColor: '#FAFAFA'
+        }
+      });
+
+      this.fetchHrPayslipRun().then(function(HrPayslipRun){
+        return HrPayslipRun;
+      }).then(function(HrPayslipRun){
+        self.HrPayslipRun = HrPayslipRun;
+        return self.fetchHrPayslip();
+      }).then(function(HrPayslip) {
+        self.HrPayslip = HrPayslip;
+        return self.BuildTable();
+      });
+    },
+
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    fetchResCompany: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var currency = new model.web.Model('res.company');
+      var field = ['id', 'name', 'currency_id', 'logo'];
+      currency.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCompany: function(id) {
+      var self = this;
+      return _.filter(self.ResCompany, function(item) {
+        return item.id == id;
+      })
+    },
+
+    fetchResStore: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var store = new model.web.Model('res.store');
+      var field = ['id', 'name', 'company_id'];
+      store.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchResCurrency: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResCurrency = new model.web.Model('res.currency');
+      ResCurrency.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getResCurrency: function(id) {
+      var self = this;
+      return _.filter(self.ResCurrency, function(item) {
+        return item.id === id;
+      })
+    },
+
+    fetchHrEmployee: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var employee = new model.web.Model('hr.employee');
+      var field = ['id', 'name','store_id'];
+      employee.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayrollStructure: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var structure = new model.web.Model('hr.payroll.structure');
+      var field = ['id', 'name'];
+      structure.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslipLine: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var line = new model.web.Model('hr.payslip.line');
+      var field = ['id', 'name', 'code', 'total'];
+      line.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchAccountPeriod: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var period = new model.web.Model('account.period');
+      var field = ['id', 'name','date_stop'];
+      period.query(field).filter().all().then(function(results) {
+        results.sort(function (a, b) {
+          if (a.date_stop > b.date_stop) {
+            return -1;
+          }
+          if (a.date_stop < b.date_stop) {
+            return 1;
+          }
+          return 0;
+        });
+        defer.resolve(results);
+      });
+
+      return defer;
+    },
+
+    fetchHrPayslipRun: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var payslip = new model.web.Model('hr.payslip.run');
+      var field = ['id', 'name','slip_ids','date_end'];
+      payslip.query(field).filter().all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    fetchHrPayslip: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var state = self.$el.find('#current-state').val();
+      var employee_id = self.$el.find('#current-employee').val();
+      var struct_id = self.$el.find('#current-structure').val();
+      var period = self.$el.find('#current-period').val();
+      var domain = [['state', 'in', ['done','paid']]];
+
+      if (company && company != 9999999) {
+        domain.push(['company_id', '=', parseInt(company)]);
+      }
+
+      if (store && store != 9999999) {
+        domain.push(['employee_id.store_id', '=', parseInt(store)]);
+      }
+
+      if (state && state != 9999999) {
+        domain.push(['state', '=', state]);
+      }
+
+      if (employee_id && employee_id != 9999999) {
+        domain.push(['employee_id', '=', parseInt(employee_id)]);
+      }
+
+      if (struct_id && struct_id != 9999999) {
+        domain.push(['struct_id', '=', parseInt(struct_id)]);
+      }
+
+      if (period && period != 9999999){
+        domain.push(['period_id','=', parseInt(period)]);
+      }
+
+      var fields = [
+        'id',
+        'employee_id',
+        'name',
+        'number',
+        'contract_id',
+        'struct_id',
+        'state',
+        'line_ids',
+        'details_by_salary_rule_category',
+      ];
+      var HrPayslip = new model.web.Model('hr.payslip');
+      HrPayslip.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    getHrPayslip: function(ids) {
+      var self = this;
+      return _.filter(self.HrPayslip, function(a) {
+        return _.find(ids, function(b) {
+          return b === a.id;
+        });
+      });
+    },
+
+    getAmount: function(line_ids, code) {
+      var self = this;
+      var amount = 0;
+      amount =  _.map(_.filter(self.HrPayslipLine, function(a) {
+        return _.find(line_ids, function(b) {
+          return b === a.id && a.code == code;
+        });
+      }), function(map) {
+        return map.total;
+      });
+
+      if(amount.length == 0){
+        return 0
+      }
+      else {
+        return amount[0];
+      }
+    },
+
+    updateEmployee: function() {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      if (store != 9999999) {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          if (parseFloat(store) == item.store_id[0]) {
+            self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var employee = self.$el.find('#current-employee').empty();
+        self.$el.find('#current-employee').append('<option value="9999999">Todos los funcionarios</option>');
+        _.each(self.HrEmployee, function(item) {
+          self.$el.find('#current-employee').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    updateStore: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      if (company != 9999999) {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          if (parseFloat(company) == item.company_id[0]) {
+            self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+          }
+        });
+      } else {
+        var store = self.$el.find('#current-store').empty();
+        self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+        _.each(self.ResStore, function(item) {
+          self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+        });
+      }
+    },
+
+    BuildTable: function() {
+      var self = this;
+      var data = [];
+      var info = [];
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+        var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+      } else {
+        var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+      }
+      var HrPayslipRun = self.HrPayslipRun;
+      _.each(HrPayslipRun, function(index){
+        info = [];
+        var total_salary= 0;
+        var total_ipse = 0;
+        var total_ipsc = 0;
+        var total_ips = 0;
+        var total_neto = 0;
+
+        var HrPayslip = self.getHrPayslip(index.slip_ids);
+        _.each(HrPayslip, function(item) {
+
+          if (item.state == 'done') {
+            var state = 'Hecho';
+          }
+       
+          if (item.state == 'paid') {
+            var state = 'Pagado';
+          }
+
+          var salary = self.getAmount(item.line_ids, "BASIC");
+          var ipse = self.getAmount(item.line_ids, "IPSE");
+          var ipsc = self.getAmount(item.details_by_salary_rule_category, "IPSC");
+          var neto = self.getAmount(item.line_ids,"NET");
+          var ips = Math.abs(ipse) + Math.abs(ipsc);
+
+          total_salary = total_salary + salary;
+          total_ipse = total_ipse + ipse;
+          total_ipsc = total_ipsc + ipsc;
+          total_ips = total_ips + ips;
+          total_neto = total_neto + neto;
+
+          info.push({
+            id: item.id,
+            employee_id: self.valorNull(item.employee_id[0]),
+
+            employee_name: self.valorNull(item.employee_id[1]),
+            struct_id: self.valorNull(item.struct_id[1]),
+            salary: accounting.formatMoney(salary, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            ipse: accounting.formatMoney(ipse, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            ipsc: accounting.formatMoney(ipsc, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            ips: accounting.formatMoney(ips, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            neto: accounting.formatMoney(neto, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            state: state,
+
+          });
+        });
+
+        if(info.length > 0){
+          data.push({
+            id:index.id,
+            name: index.name,
+            date_end: index.date_end,
+            total_salary : accounting.formatMoney(total_salary, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            total_ipse : accounting.formatMoney(total_ipse, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            total_ipsc : accounting.formatMoney(total_ipsc, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            total_ips : accounting.formatMoney(total_ips, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            total_neto : accounting.formatMoney(total_neto, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+            salary_no_format : total_salary,
+            ipse_no_format : total_ipse,
+            ipsc_no_format : total_ipsc,
+            ips_no_format : total_ips,
+            neto_no_format : total_neto,
+
+            info: info,
+
+            decimal_places : CurrencyBase.decimal_places,
+            thousands_separator: CurrencyBase.thousands_separator,
+            decimal_separator: CurrencyBase.decimal_separator,
+          });
+        }
+      });
+
+      data.sort(function (a, b) {
+        if (a.date_end > b.date_end) {
+          return -1;
+        }
+        if (a.date_end < b.date_end) {
+          return 1;
+        }
+        return 0;
+      });
+
+      self.content = data;
+      self.loadTable(data);
+      self.$el.find('.report-form').css('display', 'block');
+      self.$el.find('.search-form').unblock();
+      self.$el.find('.report-form').unblock();
+    },
+
+    loadTable: function(rowsTable) {
+      var self = this;
+      var data = [];
+      self.rowsData = rowsTable;
+      var table = this.$el.find('#table');
+
+      table.bootstrapTable({
+        data:rowsTable,
+        detailView: true,
+        onExpandRow: function(index, row, $detail) {
+          $detail.html('<div class="panel panel-first-style"><div class="panel-heading panel-header-first-style">Detalle de Nóminas</div><table id="table2"></table></div>').find('table').bootstrapTable({
+            columns: [{
+                      field: 'employee_name',
+                      title: 'Funcionario',
+                      class: 'hover',
+                  },
+                  {
+                      field: 'struct_id',
+                      title: 'Estructura Salarial',
+                  },
+                  {
+                      field: 'salary',
+                      title: 'Salario',
+                  },
+                  {
+                      field: 'ipse',
+                      title: 'IPS Funcionario',
+                  },
+                  {
+                      field: 'ipsc',
+                      title: 'IPS Patronal',
+                  },
+                  {
+                      field: 'ips',
+                      title: 'IPS ',
+                  },
+                  {
+                      field: 'neto',
+                      title: 'Neto',
+                  },
+                  {
+                      field: 'state',
+                      title: 'Estado',
+                  },
+                ],
+
+          data:row.info,
+          })
+            $('#table2').removeClass('table-hover').addClass('table-no-bordered');
+            $('thead').css('background','none');
+        }
+      })
+
+      table.bootstrapTable('load', rowsTable);
+    },
+
+    clickOnAction: function(e) {
+      var self = this;
+      var action = self.$el.find(e.target).val();
+      var company = $('#current-company').val();
+      if (company && company != 9999999) {
+        var ResCompany = self.getResCompany(company).shift();
+
+      } else {
+        var ResCompany = self.ResCompany[0];
+      }
+      var getColumns = [];
+      var rows = [];
+      var table = self.$el.find("#table");
+      var column = table.bootstrapTable('getVisibleColumns');
+      var row = table.bootstrapTable('getData');
+
+      var total_salary = salaryFormatter(row);
+      var total_ipse = ipseFormatter(row);
+      var total_ipsc = ipscFormatter(row);
+      var total_ips = ipsFormatter(row);
+      var total_neto = netoFormatter(row);
+
+      row.push({
+        name: 'Totales',
+        total_salary : total_salary,
+        total_ipse : total_ipse,
+        total_ipsc : total_ipsc,
+        total_ips : total_ips,
+        total_neto : total_neto,
+      });
+
+      if (action === 'pdf') {
+        var data = _.map(column, function(val) {
+          return val.field
+        });
+        _.each(_.map(column, function(val) {
+          return val
+        }), function(item) {
+          getColumns.push([{
+            title: item.title,
+            dataKey: item.field
+          }]);
+        });
+        var pdf_title = 'Procesamiento de Nóminas';
+        var pdf_type = '';
+        var pdf_name = 'Procesamiento_de_nominas_';
+        var pdf_columnStyles = {
+          name: {
+            halign: 'left'
+          },
+          total_salary: {
+            columnWidth: 30,
+            halign: 'right'
+          },
+          total_ipse: {
+            columnWidth: 30,
+            halign: 'right'
+          },
+          total_ipsc: {
+            columnWidth: 30,
+            halign: 'right'
+          },
+          total_ips: {
+            columnWidth: 30,
+            halign: 'right'
+          },
+          total_neto: {
+            columnWidth: 30,
+            halign: 'right'
+          },
+        };
+
+        var filter = self.getFilter();
+        var pdf = new model.eiru_reports.ReportPdfWidget(self);
+        pdf.drawPDF(
+          _.flatten(getColumns),
+          row,
+          ResCompany,
+          pdf_title,
+          pdf_type,
+          pdf_name,
+          pdf_columnStyles,
+          filter,
+        );
+      }
+    },
+    getFilter: function() {
+      var self = this;
+      var company = self.$el.find('#current-company').val();
+      var store = self.$el.find('#current-store').val();
+      var employee = self.$el.find('#current-employee').val();
+      var structure = self.$el.find('#current-structure').val();
+      var state = self.$el.find('#current-state').val();
+      var period = self.$el.find('#current-period').val();
+
+      var filter = [];
+
+      if (company && company != 9999999) {
+        var ResCompany = _.filter(self.ResCompany, function(item) {
+          return item.id == company;
+        });
+        filter.push({
+          title: 'Empresa',
+          value: ResCompany[0].name,
+        });
+      }
+
+      if (store && store != 9999999) {
+        var ResStore = _.filter(self.ResStore, function(item) {
+          return item.id == store;
+        });
+
+        filter.push({
+          title: 'Sucursal',
+          value: ResStore[0].name,
+        });
+      }
+
+      if (employee && employee != 9999999) {
+        var HrEmployee = _.filter(self.HrEmployee, function(item) {
+          return item.id == employee;
+        });
+
+        filter.push({
+          title: 'Funcionario',
+          value: HrEmployee[0].name,
+        });
+
+      }
+      if (structure && structure != 9999999) {
+        var HrPayrollStructure = _.filter(self.HrPayrollStructure, function(item) {
+          return item.id == structure;
+        })
+        filter.push({
+          title: 'Estructura Salarial',
+          value: HrPayrollStructure[0].name,
+        });
+      }
+
+      if (state && state != 9999999) {
+        filter.push({
+          title: 'Estado',
+          value: $('#current-state option:selected').text(),
+        });
+      }
+
+      if (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        })
+        filter.push({
+          title: 'Período',
+          value: AccountPeriod[0].name,
+        });
+      }
+
+      return filter;
+    },
+  });
+}

+ 155 - 0
static/src/reports/report_absence.xml

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportAbsence">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Histórico de Ausencias</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 period filter-style">
+            <label>Período</label>
+            <select id="current-period" class="form-control form-control-sm"></select>
+          </div>
+
+
+          <div class="col-lg-3 filter-style">
+            <label>Fechas</label>
+            <select id="current-date" class="form-control form-control-sm">
+              <option value="9999999">Todas las fechas</option>
+              <option value="today">Hoy</option>
+              <option value="yesterday">Ayer</option>
+              <option value="currentMonth">Mes Actual</option>
+              <option value="lastMonth">Mes Pasado</option>
+              <option value="range">Busqueda Avanzada</option>
+            </select>
+          </div>
+        </div>
+        <div class="row">
+          <div class="datepicker" style="display:none;">
+            <div class="col-lg-3 filter-style col-md-offset-3">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+            <div class="col-lg-3 filter-style">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+          </div>
+        </div>
+
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+              Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf" id="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:95%;">
+          <table
+            id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-height="auto"
+            data-classes="table table-condensed table-no-bordered"
+            data-row-style="rowStyle"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" "
+            data-detail-view="true">
+            <thead style="background:none;">
+              <tr>
+                <th class="hover" data-field="employee_name" data-align="left" data-footer-formatter="Totales">Funcionario</th>
+                <th data-field="total_days" data-align="center" data-footer-formatter="daysFormatter">Días Faltados</th>
+                <th data-field="total_amount" data-align="right" data-footer-formatter="amountFormatter">Monto Descontado</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+
+        function daysFormatter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if (rowsTable.length > 0) {
+            decimal_places = rowsTable[0].decimal_places;
+            thousands_separator = rowsTable[0].thousands_separator;
+            decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var amount = _.reduce(_.map(rowsTable, function(item) {
+            return (item.total_days_no_format);
+          }), function(memo, num) {
+            return memo + num;
+          }, 0)
+          return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+        };
+
+        function amountFormatter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if (rowsTable.length > 0) {
+            decimal_places = rowsTable[0].decimal_places;
+            thousands_separator = rowsTable[0].thousands_separator;
+            decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var amount = _.reduce(_.map(rowsTable, function(item) {
+            return (item.amount_no_format);
+          }), function(memo, num) {
+            return memo + num;
+          }, 0)
+          return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+        };
+
+         <!-- FOOTER STYLE -->
+
+        function footerStyle(row, index) {
+          return {
+            css: {
+              "font-weight": "bold",
+            }
+          };
+        };
+      </script>
+    </div>
+  </t>
+</template>

+ 138 - 0
static/src/reports/report_bonus.xml

@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportBonus">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Histórico de Comisiones</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 period filter-style">
+            <label>Período</label>
+            <select id="current-period" class="form-control form-control-sm"></select>
+          </div>
+
+
+          <div class="col-lg-3 filter-style">
+            <label>Fechas</label>
+            <select id="current-date" class="form-control form-control-sm">
+              <option value="9999999">Todas las fechas</option>
+              <option value="today">Hoy</option>
+              <option value="yesterday">Ayer</option>
+              <option value="currentMonth">Mes Actual</option>
+              <option value="lastMonth">Mes Pasado</option>
+              <option value="range">Busqueda Avanzada</option>
+            </select>
+          </div>
+        </div>
+        <div class="row">
+          <div class="datepicker" style="display:none;">
+            <div class="col-lg-3 filter-style col-md-offset-3">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+            <div class="col-lg-3 filter-style">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+          </div>
+        </div>
+
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+              Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf" id="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:95%;">
+          <table
+            id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-height="auto"
+            data-classes="table table-condensed table-no-bordered"
+            data-row-style="rowStyle"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" ">
+            <thead style="background:none;">
+              <tr>
+                <th data-field="create_date" data-footer-formatter="Totales">Fecha</th>
+                <th class="hover" data-field="employee_name">Funcionario</th>
+                <th class="hover" data-field="payslip">Nómina</th>
+                <th data-field="name">Descripción</th>
+                <th data-field="amount" data-footer-formatter="amountFormatter">Monto Adelantado</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+        function amountFormatter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if (rowsTable.length > 0) {
+            decimal_places = rowsTable[0].decimal_places;
+            thousands_separator = rowsTable[0].thousands_separator;
+            decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var amount = _.reduce(_.map(rowsTable, function(item) {
+            return (item.amount_no_format);
+          }), function(memo, num) {
+            return memo + num;
+          }, 0)
+          return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+        };
+
+         <!-- FOOTER STYLE -->
+
+        function footerStyle(row, index) {
+          return {
+            css: {
+              "font-weight": "bold",
+            }
+          };
+        };
+      </script>
+    </div>
+  </t>
+</template>

+ 138 - 0
static/src/reports/report_cash_advance.xml

@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportCashAdvance">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Histórico de Adelantos</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 period filter-style">
+            <label>Período</label>
+            <select id="current-period" class="form-control form-control-sm"></select>
+          </div>
+
+
+          <div class="col-lg-3 filter-style">
+            <label>Fechas</label>
+            <select id="current-date" class="form-control form-control-sm">
+              <option value="9999999">Todas las fechas</option>
+              <option value="today">Hoy</option>
+              <option value="yesterday">Ayer</option>
+              <option value="currentMonth">Mes Actual</option>
+              <option value="lastMonth">Mes Pasado</option>
+              <option value="range">Busqueda Avanzada</option>
+            </select>
+          </div>
+        </div>
+        <div class="row">
+          <div class="datepicker" style="display:none;">
+            <div class="col-lg-3 filter-style col-md-offset-3">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+            <div class="col-lg-3 filter-style">
+              <div class="input-group">
+                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+              </div>
+            </div>
+          </div>
+        </div>
+
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+              Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf" id="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:95%;">
+          <table
+            id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-height="auto"
+            data-classes="table table-condensed table-no-bordered"
+            data-row-style="rowStyle"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" ">
+            <thead style="background:none;">
+              <tr>
+                <th data-field="create_date" data-footer-formatter="Totales">Fecha</th>
+                <th class="hover" data-field="employee_name">Funcionario</th>
+                <th class="hover" data-field="payslip">Nómina</th>
+                <th data-field="name">Descripción</th>
+                <th data-field="amount" data-footer-formatter="amountFormatter">Monto Adelantado</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+        function amountFormatter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if (rowsTable.length > 0) {
+            decimal_places = rowsTable[0].decimal_places;
+            thousands_separator = rowsTable[0].thousands_separator;
+            decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var amount = _.reduce(_.map(rowsTable, function(item) {
+            return (item.amount_no_format);
+          }), function(memo, num) {
+            return memo + num;
+          }, 0)
+          return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+        };
+
+         <!-- FOOTER STYLE -->
+
+        function footerStyle(row, index) {
+          return {
+            css: {
+              "font-weight": "bold",
+            }
+          };
+        };
+      </script>
+    </div>
+  </t>
+</template>

+ 120 - 0
static/src/reports/report_contract_list.xml

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportContractList">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Lista de Contratos</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 job filter-style">
+            <label>Cargo</label>
+            <select id="current-job" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 struct filter-style">
+            <label>Estructura Salarial</label>
+            <select id="current-struct" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 type filter-style">
+            <label>Tipo de Contrato</label>
+            <select id="current-type" class="form-control form-control-sm"></select>
+          </div>
+        </div>
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+              Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:100%">
+          <table
+            id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-classes="table table-condensed table-no-bordered"
+            data-row-style="rowStyle"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" ">
+            <thead style="background:none;">
+              <tr>
+                <th class="hover" data-field="name" data-align="left" data-footer-formatter="Totales">Contrato</th>
+                <th class="hover" data-field="employee_name" data-align="left">Funcionario</th>
+                <th data-field="job_id" data-align="left">Cargo</th>
+                <th data-field="type_id" data-align="left">Tipo de Contrato</th>
+                <th data-field="wage" data-align="right" data-footer-formatter="wageFormatter">Salario</th>
+                <th data-field="struct_id" data-align="left">Estructura Salarial</th>
+                <th data-field="date_start" data-align="center" data-width="80px">Inicio</th>
+                <th data-field="date_end" data-align="center" data-width="80px">Finalización</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+        function wageFormatter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if (rowsTable.length > 0) {
+            decimal_places = rowsTable[0].decimal_places;
+            thousands_separator = rowsTable[0].thousands_separator;
+            decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var amount = _.reduce(_.map(rowsTable, function(item) {
+            return (item.wage_no_format);
+          }), function(memo, num) {
+            return memo + num;
+          }, 0)
+          return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+        };
+
+         <!-- FOOTER STYLE -->
+
+        function footerStyle(row, index) {
+          return {
+            css: {
+              "font-weight": "bold",
+            }
+          };
+        };
+      </script>
+    </div>
+  </t>
+</template>

+ 80 - 0
static/src/reports/report_employee_list.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportEmployeeList">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Lista de Funcionarios</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 state filter-style">
+            <label>Estado</label>
+            <select id="current-state" class="form-control form-control-sm">
+              <option value="9999999">Todos los estados</option>
+              <option value="activo">Activo</option>
+              <option value="desactivado">Desactivado</option>
+            </select>
+          </div>
+        </div>
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+              Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:100%">
+          <table
+            id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-classes="table table-condensed table-no-bordered"
+            data-row-style="rowStyle"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" ">
+            <thead style="background:none;">
+              <tr>
+                <th data-field="identification_id" data-align="center">RUC</th>
+                <th class="hover" data-field="name" data-align="left">Nombre</th>
+                <th data-field="job_id" data-align="left">Cargo</th>
+                <th data-field="work_email" data-align="left">Email</th>
+                <th data-field="work_phone" data-align="center">Teléfono</th>
+                <th data-field="payslip_count" data-align="center">Nóminas</th>
+                <th data-field="contracts_count" data-align="center">Contratos</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+    </div>
+  </t>
+</template>

+ 232 - 0
static/src/reports/report_payslip.xml

@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportPayslip">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Análisis de Nóminas</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 structure filter-style">
+            <label>Estructura Salarial</label>
+            <select id="current-structure" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 state filter-style">
+            <label>Estado</label>
+            <select id="current-state" class="form-control form-control-sm">
+              <option value="9999999">Todos los estados</option>
+              <option value="done">Hecho</option>
+              <option value="cancel">Cancelado</option>
+              <option value="paid">Pagado</option>
+            </select>
+          </div>
+
+          <div class="col-lg-3 period filter-style">
+            <label>Período</label>
+            <select id="current-period" class="form-control form-control-sm"></select>
+          </div>
+        </div>
+
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf" id="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:95%;">
+          <table id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-classes="table table-condensed table-no-bordered"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" ">
+            <thead style="background:none;">
+              <tr>
+                <th class="hover" data-field="employee_name" data-width="100px" data-halign="center" data-align="left" data-footer-formatter="Totales">Funcionario</th>
+                <th data-field="number" data-width="70px" data-halign="center" data-align="left">Ref.</th>
+                <th class="hover" data-field="name" data-width="170px" data-halign="center" data-align="left">Nombre de nómina</th>
+                <th class="hover" data-field="contract_name" data-width="110px" data-halign="center" data-align="left">Contrato</th>
+                <th data-field="struct_id" data-width="120px" data-halign="center" data-align="left">Estructura salarial</th>
+                <th data-field="salary" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="salaryFormatter">Salario Base</th>
+                <th data-field="ips" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="ipsFormatter">IPS</th>
+                <th data-field="cash_advance" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="cash_advanceFormatter">Adelanto</th>
+                <th data-field="bonus" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="bonusFormatter">Comisión</th>
+                <th data-field="faltas" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="faltasFormatter">Faltas</th>
+                <th data-field="totsalary" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="totsalaryFormatter">Total a pagar</th>
+                <th data-field="neto" data-width="100px" data-halign="center" data-align="right" data-footer-formatter="netoFormatter">Total Neto</th>
+                <th data-field="state" data-width="60px" data-halign="center" data-align="center">Estado</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+          function salaryFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.salary_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function ipsFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.ips_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function cash_advanceFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.cash_advance_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function bonusFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.bonus_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function faltasFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.faltas_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function netoFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.neto_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function totsalaryFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.totsalary_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+           <!-- FOOTER STYLE -->
+
+          function footerStyle(row, index) {
+            return {
+              css: {
+                "font-weight": "bold",
+              }
+            };
+          };
+      </script>
+    </div>
+  </t>
+</template>

+ 132 - 0
static/src/reports/report_payslip_egreso.xml

@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportPayslipEgreso">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Egresos con egresos y nóminas</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="text-center" style="padding-top:20px;">
+                        <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                            Generar
+                        </button>
+                    </div>
+                    <br/>
+                </div>
+            </div>
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="print-report oe_button myButton" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:95%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-classes="table table-condensed"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button myButton"
+                        data-show-pagination-switch="true"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-pagination-v-align="top"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                              <th data-field="name"
+                                    data-align="left"
+                                    >Origen</th>
+                                <th data-field="date"
+                                    data-align="left"
+                                    >Fecha de pago</th>
+                                <th data-field="total"
+                                    data-align="right"
+                                    data-footer-formatter="TotalFooter"
+                                    >Monto Pagado</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+
+            <script>
+                <!--
+                    TOTAL
+                -->
+
+                function TotalFooter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return item.total_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+            </script>
+        </div>
+    </t>
+</template>

+ 191 - 0
static/src/reports/report_payslip_run.xml

@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+  <t t-name="ReportPayslipRun">
+    <div class="report_view">
+      <div class="reporting_page_header">
+        <h1 class="report_title">Procesamiento de Nóminas</h1>
+      </div>
+
+      <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+        <div class="row">
+          <div class="col-lg-3 company filter-style">
+            <label>Empresa</label>
+            <select id="current-company" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 store filter-style">
+            <label>Sucursal</label>
+            <select id="current-store" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 employee filter-style">
+            <label>Funcionario</label>
+            <select id="current-employee" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 structure filter-style">
+            <label>Estructura Salarial</label>
+            <select id="current-structure" class="form-control form-control-sm"></select>
+          </div>
+
+          <div class="col-lg-3 state filter-style">
+            <label>Estado</label>
+            <select id="current-state" class="form-control form-control-sm">
+              <option value="9999999">Todos los estados</option>
+              <option value="done">Hecho</option>
+              <option value="paid">Pagado</option>
+            </select>
+          </div>
+
+          <div class="col-lg-3 period filter-style">
+            <label>Período</label>
+            <select id="current-period" class="form-control form-control-sm"></select>
+          </div>
+        </div>
+
+        <div class="row">
+          <div class="text-center" style="padding-top:20px;">
+            <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                Generar
+            </button>
+          </div>
+          <br/>
+        </div>
+      </div>
+
+      <div class="report-form" style="display:none;">
+        <div id="toolbar">
+          <button class="oe_button oe_form_button myButton" value="pdf" id="pdf">Imprimir Informe</button>
+        </div>
+        <div class="container" style="width:95%;">
+          <table id="table"
+            data-pagination="true"
+            data-toggle="table"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-classes="table table-condensed table-no-bordered"
+            data-search="true"
+            data-show-export="true"
+            data-show-toggle="true"
+            data-pagination-detail-h-align="left"
+            data-show-footer="true"
+            data-footer-style="footerStyle"
+            data-buttons-class="oe_button oe_form_button myButton"
+            data-show-pagination-switch="true"
+            data-page-size="10"
+            data-search-on-enter-key="true"
+            data-undefined-text=" "
+            data-detail-view="true">
+            <thead style="background:none;">
+              <tr>
+                <th class="hover" data-field="name" data-halign="left" data-align="left" data-footer-formatter="Totales">Nombre de nómina</th>
+                <th data-field="total_salary" data-align="right" data-footer-formatter="salaryFormatter">Total Salario</th>
+                <th data-field="total_ipse" data-align="right" data-footer-formatter="ipseFormatter">Total IPS Funcionarios</th>
+                <th data-field="total_ipsc" data-align="right" data-footer-formatter="ipscFormatter">Total IPS Patronal</th>
+                <th data-field="total_ips" data-align="right" data-footer-formatter="ipsFormatter">Total IPS</th>
+                <th data-field="total_neto" data-align="right" data-footer-formatter="netoFormatter">Total Salario - IPS Funcionario</th>
+              </tr>
+            </thead>
+          </table>
+        </div>
+      </div>
+      <script>
+
+          function salaryFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.salary_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function ipseFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.ipse_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function ipscFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.IPSC_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function ipsFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.ips_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+          function netoFormatter(rowsTable) {
+            var decimal_places = 0;
+            var thousands_separator = '.';
+            var decimal_separator = ',';
+            if (rowsTable.length > 0) {
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+            }
+            var amount = _.reduce(_.map(rowsTable, function(item) {
+              return (item.neto_no_format);
+            }), function(memo, num) {
+              return memo + num;
+            }, 0)
+            return accounting.formatNumber(amount, decimal_places, thousands_separator, decimal_separator);
+          };
+
+           <!-- FOOTER STYLE -->
+
+          function footerStyle(row, index) {
+            return {
+              css: {
+                "font-weight": "bold",
+              }
+            };
+          };
+      </script>
+    </div>
+  </t>
+</template>

+ 5 - 0
static/src/xml/eiru_reporting.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 5 - 0
static/src/xml/eiru_reporting_base.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 43 - 0
templates.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+  <data>
+    <template id="eiru_reports_rrhh_assets" inherit_id="eiru_assets.assets">
+      <xpath expr="." position="inside">
+        <link rel="stylesheet" href="/eiru_reports_rrhh/static/src/css/custom.css"/>
+
+        <!-- configuration < main > -->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/main.js"/>
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reporting_base.js"/>
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/pdf.js" />
+
+        <!-- ================================= RRHH ========================================= -->
+
+        <!--============================= Lista de funcionarios ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_employee_list.js"/>
+
+        <!--============================= Analisis de nominas ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_payslip.js"/>
+
+        <!--============================= Procesamiento de nominas ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_payslip_run.js"/>
+
+        <!--============================= Analisis de adelantos ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_cash_advance.js"/>
+
+        <!--============================= Analisis de comision ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_bonus.js"/>
+
+        <!--============================= Analisis de ausencia ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_absence.js"/>
+
+        <!--============================= Lista de Contractos ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_contract_list.js"/>
+
+        <!--============================= Nominas/Egresos ==============================-->
+        <script type="text/javascript" src="/eiru_reports_rrhh/static/src/js/reports/report_payslip_egreso.js"/>
+
+
+      </xpath>
+    </template>
+  </data>
+</openerp>

+ 46 - 0
views/actions.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+
+		<record id="employee_list_action" model="ir.actions.client">
+			<field name="name">Lista de Funcionarios</field>
+			<field name="tag">eiru_reports_rrhh.employee_list_action</field>
+		</record>
+
+		<record id="payslip_action" model="ir.actions.client">
+			<field name="name">Análisis de Nóminas</field>
+			<field name="tag">eiru_reports_rrhh.payslip_action</field>
+		</record>
+
+		<record id="payslip_run_action" model="ir.actions.client">
+			<field name="name">Procesamiento de Nóminas</field>
+			<field name="tag">eiru_reports_rrhh.payslip_run_action</field>
+		</record>
+
+		<record id="cash_advance_action" model="ir.actions.client">
+			<field name="name">Histórico de Adelantos</field>
+			<field name="tag">eiru_reports_rrhh.cash_advance_action</field>
+		</record>
+
+		<record id="bonus_action" model="ir.actions.client">
+			<field name="name">Histórico de Comisión</field>
+			<field name="tag">eiru_reports_rrhh.bonus_action</field>
+		</record>
+
+		<record id="absence_action" model="ir.actions.client">
+			<field name="name">Histórico de Ausencias</field>
+			<field name="tag">eiru_reports_rrhh.absence_action</field>
+		</record>
+
+		<record id="contract_list_action" model="ir.actions.client">
+			<field name="name">Lista de Contratos</field>
+			<field name="tag">eiru_reports_rrhh.contract_list_action</field>
+		</record>
+
+		<record id="payslip_egreso_action" model="ir.actions.client">
+			<field name="name">Resumen de egresos con nóminas</field>
+			<field name="tag">eiru_reports_rrhh.payslip_egreso_action</field>
+		</record>
+
+	</data>
+</openerp>

+ 15 - 0
views/hr_employee.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+    <record model="ir.ui.view" id="view_employee_form2">
+      <field name="name">hr.view_employee_form</field>
+      <field name="model">hr.employee</field>
+      <field name="inherit_id" ref="hr.view_employee_form"/>
+      <field name="arch" type="xml">
+          <field name="company_id"  position="after">
+            <field name="store_id"/>
+          </field>
+      </field>
+    </record>
+  </data>
+</openerp>

+ 26 - 0
views/menus.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+  <data>
+    <!-- main menu name -->
+    <menuitem id="hr_parent_menu" name="Informes" parent="hr.menu_hr_root" sequence="200"/>
+
+    <!-- sub menu -->
+
+    <menuitem id="employee_list_menu" parent="hr_parent_menu" name="Lista de Funcionarios" action="employee_list_action" sequence="1"/>
+
+    <menuitem id="contract_list_menu" parent="hr_parent_menu" name="Lista de Contratos" action="contract_list_action" sequence="2"/>
+
+    <menuitem id="payslip_menu" parent="hr_parent_menu" name="Análisis de Nóminas" action="payslip_action" sequence="3"/>
+
+    <menuitem id="payslip_run_menu" parent="hr_parent_menu" name="Procesamiento de Nóminas" action="payslip_run_action" sequence="4"/>
+
+    <menuitem id="cash_advance_menu" parent="hr_parent_menu" name="Histórico de Adelantos" action="cash_advance_action" sequence="5"/>
+
+    <menuitem id="bonus_menu" parent="hr_parent_menu" name="Histórico de Comisiones" action="bonus_action" sequence="6"/>
+
+    <menuitem id="absence_menu" parent="hr_parent_menu" name="Histórico de Ausencias" action="absence_action" sequence="7"/>
+
+    <menuitem id="payslip_egreso_menu" parent="hr_parent_menu" name="Resumen de egresos con nóminas" action="payslip_egreso_action" sequence="8"/>
+
+  </data>
+</openerp>