Exemple #1
0
        private void ValidarCabecera(Presupuestos model)
        {
            if (model.fechadocumento == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestos.Fechadocumento));
            }
            if (model.fechavalidez == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestos.Fechavalidez));
            }
            if (model.fkclientes == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestos.Fkclientes));
            }
            if (!model.fkmonedas.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestos.Fkmonedas));
            }
            if (!model.fkformaspago.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPedidos.Fkformaspago));
            }

            var        clienteObj   = _db.Clientes.SingleOrDefault(f => f.empresa == model.empresa && f.fkcuentas == model.fkclientes);
            Prospectos prospectoObj = null;

            if (clienteObj == null)
            {
                prospectoObj = _db.Prospectos.Single(f => f.empresa == model.empresa && f.fkcuentas == model.fkclientes);
            }
            var fkmonedacliente = clienteObj?.fkmonedas ?? Funciones.Qint(prospectoObj.fkmonedas);
            var serieObj        =
                _db.Series.Single(f => f.empresa == model.empresa && f.tipodocumento == "PRE" && f.id == model.fkseries);

            if (serieObj.fkmonedas.HasValue && serieObj.fkmonedas != fkmonedacliente)
            {
                throw new ValidationException(RPresupuestos.ErrorMonedaClienteSerie);
            }

            if (!FlagActualizarCantidadesPedidas && !ValidaRangoEjercicio(model))
            {
                throw new ValidationException(RPresupuestos.ErrorFechaEjercicio);
            }
            if (!FlagActualizarCantidadesPedidas)
            {
                if (!ValidarLineasPresupuesto(model))
                {
                    throw new ValidationException(RPresupuestos.ErrorLineasAsociadasAPedidos);
                }
            }
        }
Exemple #2
0
        public async Task <IActionResult> OnPostLlenarConsultaAsync([FromBody] RequestPagination pag)
        {
            var token = HttpContext.Session.GetString("token");

            Participant = User.Claims.Where(x => x.Type == "Participant").Select(x => x.Value).SingleOrDefault();
            Confirmant  = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            Owner       = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();
            Country     = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();
            var Estados = await _globalService.ConsultaIdentificationsAndCitiesTF(new ParamCountry { Id = Int32.Parse(Country) });

            filterInvoice currencyAccountInvoiceFilter = new filterInvoice();

            if (pag.Filter != null)
            {
                currencyAccountInvoiceFilter = pag.Filter;
            }
            Prospectos ListaClientesBanco = new Prospectos();
            List <ListAccountantsInvoices> listaFinanciedInvoices = new List <ListAccountantsInvoices>();

            if (Estados != null)
            {
                if (Estados.Currencies != null)
                {
                    if (pag.Filter.AmountRiskFrom == null)
                    {
                        pag.Filter.AmountRiskFrom = 0;
                    }
                    if (pag.Filter.Abbreviation == null)
                    {
                        pag.Filter.Abbreviation = "CREDIT";
                    }
                    ListaClientesBanco = await _peopleService.GetConsultaFinaciamientoConfirmant(new ParamClienteOFConfirmant { Bank_id = Confirmant, Filter = pag.Filter, Pagination = pag.Pagination }, token);

                    var ListaAccountantsInvoices = await _invoiceService.GetFinanciablesBankInvoices(new ParamAccountantsInvoices { Country = Int32.Parse(Country), Confirmant = Confirmant }, currencyAccountInvoiceFilter, token);

                    ListaAccountantsInvoices.Currency = pag.Filter.Currency_id;
                    listaFinanciedInvoices.Add(ListaAccountantsInvoices);
                }
            }

            return(new JsonResult(new { lista = ListaClientesBanco, estado = Estados, listaFinanciedInvoices = listaFinanciedInvoices }));
        }