Beispiel #1
0
        public Cotizacion SaveCotizacionRC(Cotizacion cotizacion)
        {
            //Grabar Cotizacion
            IUnitOfWork unitOfWork = _cotizacionRepository.UnitOfWork as IUnitOfWork;

            Cotizacion cotDatos = _cotizacionRepository.FindCotizacionRC(cotizacion.CotizacionID);

            cotDatos.bk_te_CotizacionRCActInm = cotizacion.bk_te_CotizacionRCActInm;
            //cotDatos.bk_te_CotizacionRCProducto = cotizacion.bk_te_CotizacionRCProducto;
            cotDatos.bk_te_CotizacionRCTrabajoTerm     = cotizacion.bk_te_CotizacionRCTrabajoTerm;
            cotDatos.bk_te_CotizacionRCTaller          = cotizacion.bk_te_CotizacionRCTaller;
            cotDatos.bk_te_CotizacionRCEstacionamiento = cotizacion.bk_te_CotizacionRCEstacionamiento;
            cotDatos.bk_te_CotizacionRCVehiculoExc     = cotizacion.bk_te_CotizacionRCVehiculoExc;
            cotDatos.bk_te_CotizacionRCConstruccion    = cotizacion.bk_te_CotizacionRCConstruccion;
            cotDatos.bk_te_CotizacionRCHoteleria       = cotizacion.bk_te_CotizacionRCHoteleria;
            cotDatos.bk_te_CotizacionRCAdicional       = cotizacion.bk_te_CotizacionRCAdicional;

            if (cotDatos.bk_te_CotizacionDeducible != null)
            {
                CotizacionDeducible cotDeduc;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 9).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.DeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.DeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.DeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.DeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.DeducibleUnidadIDMin;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 30).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.ArrendatarioDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.ArrendatarioDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.ArrendatarioDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.ArrendatarioDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.ArrendatarioDeducibleUnidadIDMin;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 31).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.BienesDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.BienesDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.BienesDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.BienesDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.BienesDeducibleUnidadIDMin;

                switch (cotDatos.bk_te_CotizacionRCActInm.RCActInmCruzadaID)
                {
                case 1: cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 24).FirstOrDefault(); break;

                case 2: cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 25).FirstOrDefault(); break;

                case 3: cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 26).FirstOrDefault(); break;

                case 4: cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 27).FirstOrDefault(); break;
                }

                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.CruzadaDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.CruzadaDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.CruzadaDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.CruzadaDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.CruzadaDeducibleUnidadIDMin;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 32).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.ContaminacionDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.ContaminacionDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.ContaminacionDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.ContaminacionDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.ContaminacionDeducibleUnidadIDMin;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 33).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.AsumidaDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.AsumidaDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.AsumidaDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.AsumidaDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.AsumidaDeducibleUnidadIDMin;

                cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.SubLineaNegocioID == 34).FirstOrDefault();
                cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCActInm.ContIndependienteDeducibleValorID;
                cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCActInm.ContIndependienteDeducibleUnidadID;
                cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCActInm.ContIndependienteDeducibleAplicaID;
                cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCActInm.ContIndependienteDeducibleValorIDMin;
                cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCActInm.ContIndependienteDeducibleUnidadIDMin;

                if (cotDatos.bk_te_CotizacionRCTrabajoTerm != null)
                {
                    cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 28).FirstOrDefault();
                    cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCTrabajoTerm.DeducibleValorID;
                    cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCTrabajoTerm.DeducibleUnidadID;
                    cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCTrabajoTerm.DeducibleAplicaID;
                    cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCTrabajoTerm.DeducibleValorIDMin;
                    cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCTrabajoTerm.DeducibleUnidadIDMin;

                    cotDeduc = cotDatos.bk_te_CotizacionDeducible.Where(x => x.TarifaID == 29).FirstOrDefault();
                    cotDeduc.DeducibleValorID        = cotDatos.bk_te_CotizacionRCTrabajoTerm.UnionMezclaDeducibleValorID;
                    cotDeduc.UnidadDeducibleID       = cotDatos.bk_te_CotizacionRCTrabajoTerm.UnionMezclaDeducibleUnidadID;
                    cotDeduc.DeducibleAplicaID       = cotDatos.bk_te_CotizacionRCTrabajoTerm.UnionMezclaDeducibleAplicaID;
                    cotDeduc.DeducibleValorIDMinimo  = cotDatos.bk_te_CotizacionRCTrabajoTerm.UnionMezclaDeducibleValorIDMin;
                    cotDeduc.UnidadDeducibleIDMinimo = cotDatos.bk_te_CotizacionRCTrabajoTerm.UnionMezclaDeducibleUnidadIDMin;
                }
            }

            _cotizacionRepository.Modify(cotDatos);

            unitOfWork.Commit();

            _cotizacionRepository.execProcesarRC(cotizacion.CotizacionID, false); //Procesamos para obtener cuota y prima

            if (cotDatos.bk_te_CotizacionRCAdicional.isPrimaMinima.Value)
            {
                _cotizacionRepository.execProcesarRC(cotizacion.CotizacionID, true);
            }

            if (cotDatos.bk_te_CotizacionRCActInm != null)
            {
                ResultadoPrima rcActInm = _cotizacionRepository.GetPrimaCuota((int)enumTableCotizacion.RCActInm, cotizacion.CotizacionID);
                cotDatos.bk_te_CotizacionRCActInm.Cuota = rcActInm.Cuota;
                cotDatos.bk_te_CotizacionRCActInm.Prima = rcActInm.Prima;
            }

            return(cotDatos);
        }