private double DescuentoInasistencia(string codigoEmpleado) { try { double descuentoInasistencia = 0.0; double sueldoMinimo = 0.0; int diasMes = 0; int horasDia = 0; using (var beParametros = new BE.Parametros()) { sueldoMinimo = beParametros.SueldoMinimo; diasMes = beParametros.BaseDias; horasDia = beParametros.BaseHoras; } double costoMinuto = ((sueldoMinimo / diasMes) / horasDia) / 60; double penalidadNormal = costoMinuto * 3; double penalidadFeriado = costoMinuto * 5; var lnPlanilla = new LN.Planilla(this.Anho, this.Mes); var uiAsistenciaResumen = lnPlanilla.ObtenerResumenAsistenciaEmpleado(codigoEmpleado); if (uiAsistenciaResumen != null) { double descuentoInasistenciaNormal = uiAsistenciaResumen.CantidadInasistenciasNormales * penalidadNormal; double descuentoInasistenciaFeriado = uiAsistenciaResumen.CantidadInasistenciasFeriados * penalidadFeriado; double descuentoInasistenciaPlanilla = 0.0; var uiPlanillDetalle = lnPlanilla.ObtenerPlantillaDetalle(codigoEmpleado); if (uiPlanillDetalle != null) { descuentoInasistenciaPlanilla = uiPlanillDetalle.DescuentoInasistenciaTotal; } descuentoInasistencia = descuentoInasistenciaNormal + descuentoInasistenciaFeriado - descuentoInasistenciaPlanilla; } //else //{ // DateTime fechaPeriodo = new DateTime(this.Anho, this.Mes, 1); // string mensajeError = $"No encuentra calculo de planilla para el periodo {fechaPeriodo.ToString("yyyy/MM")}"; // throw new Exception(mensajeError); //} uiAsistenciaResumen = null; return(descuentoInasistencia); } catch (Exception ex) { throw ex; } }
private void btnBuscar_Click(object sender, EventArgs e) { try { #region Validar if (this.cboPeriodoFiltro.SelectedIndex == 0) { this.cboPeriodoFiltro.Focus(); throw new Exception("Seleccione un periodo"); } if (this.cboEmpleadoFiltro.SelectedIndex == 0) { this.cboEmpleadoFiltro.Focus(); throw new Exception("Seleccione un empleado"); } #endregion #region Cargar en memoria var beRecord = (BE.Record) this.cboEmpleadoFiltro.SelectedItem; this.uiGratificacion.EmpleadoCodigo = beRecord.Codigo; this.uiGratificacion.EmpleadoNombres = beRecord.Nombre; var beEmpleado = new LN.Empleado().Obtener(beRecord.Codigo); this.uiGratificacion.SueldoBase = beEmpleado.Recurso.Sueldo; this.uiGratificacion.DescuentoRetencioJudicial = 0.0; var beSueldoMinimo = new LN.SueldoMinimo().Actual(DateTime.Now); var beParametros = new BE.Parametros(beSueldoMinimo.Monto); this.uiGratificacion.AsignacionFamiliar = beParametros.AsignacionFamiliar; #endregion #region Resumen y Detalle this.txtPeriodo.Text = this.uiGratificacion.Periodo; this.txtDias.Text = this.uiGratificacion.Dias.ToString(); this.txtFechaInicial.Text = this.uiGratificacion.FechaInicial.ToString("dd/MM/yyyy"); this.txtFechaFinal.Text = this.uiGratificacion.FechaFinal.ToString("dd/MM/yyyy"); this.txtEmpleadoCodigo.Text = this.uiGratificacion.EmpleadoCodigo; this.txtEmpleadoNombres.Text = this.uiGratificacion.EmpleadoNombres; this.txtSueldoBase.Text = this.uiGratificacion.SueldoBase.ToString("N2"); this.txtSueldoAsigFam.Text = this.uiGratificacion.AsignacionFamiliar.ToString("N2"); int anho = this.uiGratificacion.Anho; int mesIni = this.uiGratificacion.FechaInicial.Month; int mesFin = this.uiGratificacion.FechaFinal.Month; string codEmpleado = this.uiGratificacion.EmpleadoCodigo; double bonoNocturnoTotal = 0; double bonoHorasExtrasTotal = 0; int diasCalculo = 0; this.uiGratificacion.Detalle = new List <BE.UI.GratificacionDetalle>(); for (int mes = mesIni; mes <= mesFin; mes++) { double bonoNocturno = 0; double bonoHorasExtras = 0; int diasMes = DateTime.DaysInMonth(anho, mes); int diasInasistencias = 0; var uiPlantillaDetalle = new LN.Planilla(anho, mes).ObtenerPlantillaDetalle(codEmpleado); if (uiPlantillaDetalle != null) { bonoNocturno = uiPlantillaDetalle.BonoNocturnoTotal; bonoHorasExtras = uiPlantillaDetalle.BonoHorasExtrasTotal; double inasistencias = uiPlantillaDetalle.DescuentoInasistenciaCantidad; switch (uiPlantillaDetalle.CalcularPor) { case "M": diasInasistencias = (int)inasistencias / 360; break; case "H": diasInasistencias = (int)inasistencias / 60; break; default: diasInasistencias = (int)inasistencias; break; } } bonoNocturnoTotal += bonoNocturno; bonoHorasExtrasTotal += bonoHorasExtras; diasCalculo += diasMes - diasInasistencias; var uiGratificacionDetalle = new BE.UI.GratificacionDetalle(); uiGratificacionDetalle.Anho = anho; uiGratificacionDetalle.MesId = mes; uiGratificacionDetalle.MesNombre = Util.GetNameOfMonth(mes); uiGratificacionDetalle.EmpleadoCodigo = codEmpleado; uiGratificacionDetalle.BonoNocturno = bonoNocturno; uiGratificacionDetalle.BonoHorasExtras = bonoHorasExtras; uiGratificacionDetalle.DiasMes = DateTime.DaysInMonth(anho, mes); uiGratificacionDetalle.DiasInasistencias = diasInasistencias; uiGratificacionDetalle.DiasCalculo = uiGratificacionDetalle.DiasMes - uiGratificacionDetalle.DiasInasistencias; this.uiGratificacion.Detalle.Add(uiGratificacionDetalle); } var source = new BindingSource(); source.DataSource = this.uiGratificacion.Detalle; this.dgvDetalleGratificaciones.DataSource = source; this.FormatoDetalleGratificacion(); this.txtDetalleBonoNocturno.Text = bonoNocturnoTotal.ToString("N2"); this.txtDetalleBonoHorasExtras.Text = bonoHorasExtrasTotal.ToString("N2"); this.txtDetalleDiasCalculo.Text = diasCalculo.ToString(); this.uiGratificacion.BonoNocturno = bonoNocturnoTotal / 6; this.uiGratificacion.BonoHorasExtras = bonoHorasExtrasTotal / 6; this.uiGratificacion.DiasCalculo = diasCalculo; this.txtBonoNocturno.Text = this.uiGratificacion.BonoNocturno.ToString("N2"); this.txtBonoExtra.Text = this.uiGratificacion.BonoHorasExtras.ToString("N2"); this.txtDescuentoRJ.Text = this.uiGratificacion.DescuentoRetencioJudicial.ToString("N2"); this.txtDescuentoImpuesto.Text = this.uiGratificacion.DescuentoImpuestos.ToString("N2"); double gratificacionBruta = this.uiGratificacion.BonoNocturno + this.uiGratificacion.BonoHorasExtras + this.uiGratificacion.SueldoBase + this.uiGratificacion.AsignacionFamiliar; this.uiGratificacion.GratificacionBruta = (gratificacionBruta / this.uiGratificacion.Dias) * this.uiGratificacion.DiasCalculo; this.txtGratificacionBruta.Text = this.uiGratificacion.GratificacionBruta.ToString("N2"); this.uiGratificacion.GratificacionBono = gratificacionBruta * beParametros.EsSaludFactor; this.txtGratificacionBonificacion.Text = this.uiGratificacion.GratificacionBono.ToString("N2"); this.uiGratificacion.GratificacionNeta = this.uiGratificacion.GratificacionBruta + this.uiGratificacion.GratificacionBono; this.txtGratificacionNeta.Text = this.uiGratificacion.GratificacionNeta.ToString("N2"); this.uiGratificacion.GratificacionPago = this.uiGratificacion.GratificacionNeta - this.uiGratificacion.DescuentoRetencioJudicial - this.uiGratificacion.DescuentoImpuestos; this.txtGratificacionPago.Text = this.uiGratificacion.GratificacionPago.ToString("N2"); #endregion this.txtDescuentoImpuesto.ReadOnly = false; } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }