Пример #1
0
        public async Task <IActionResult> OnGetAsync([FromBody] RequestPagination pag)
        {
            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            dataFilter = JsonConvert.SerializeObject(filter);

            Owner      = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();
            Confirmant = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            Country    = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var data = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(data));
            }
            List <Invoices> facturaCheck = new List <Invoices>();

            Currency_options = new List <SelectListItem>();
            Status_Options   = new List <SelectListItem>();
            Programs_Options = new List <SelectListItem>();

            foreach (var program in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Program)
            {
                if (!Programs_Options.Exists(x => x.Text == program.Abbreviation))
                {
                    Programs_Options.Add(new SelectListItem()
                    {
                        Value = "" + program.Abbreviation, Text = program.Abbreviation
                    });
                }
            }

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            var token = HttpContext.Session.GetString("token");

            Country = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var data = await _gS.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(data));
            }

            Currency_options = new List <SelectListItem>();

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }


            return(Page());
        }
Пример #3
0
        public async Task <IActionResult> OnGetAsync()
        {
            get = true;

            filter = new filterInvoice()
            {
                Financied = null,
            };

            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            dataFilter    = JsonConvert.SerializeObject(filter);
            financiedNull = null;

            Owner      = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();
            Confirmant = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            Country    = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();

            if (HttpContext.Session.GetString("CountryInvoicesProgram") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoicesProgram")).Id != Int32.Parse(Country))
            {
                var data = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoicesProgram", JsonConvert.SerializeObject(data));
            }
            List <Invoices> facturaCheck = new List <Invoices>();

            Supplier_Options = new List <SelectListItem>();
            Debtor_Options   = new List <SelectListItem>();
            Currency_options = new List <SelectListItem>();
            Status_Options   = new List <SelectListItem>();

            Programs_Options = new List <SelectListItem>();

            ListStatus();


            List <ResponseProveedores> clientes = null;

            clientes = await _peopleService.GetDeptors(Owner, token);

            if (clientes.Count > 0 && clientes[0].Errors == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }


            foreach (var cls in clientes)
            {
                if (!Debtor_Options.Exists(x => x.Value == cls.Id))
                {
                    Debtor_Options.Add(new SelectListItem()
                    {
                        Value = cls.Id, Text = cls.Name
                    });
                }
            }

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoicesProgram")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }


            foreach (var program in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoicesProgram")).Program)
            {
                if (!Programs_Options.Exists(x => x.Text == program.Abbreviation))
                {
                    Programs_Options.Add(new SelectListItem()
                    {
                        Value = "" + program.Abbreviation, Text = program.Abbreviation
                    });
                }
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync([FromBody] RequestPagination pag)
        {
            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            dataFilter = JsonConvert.SerializeObject(filter);

            Owner         = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();
            Confirmant    = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            Country       = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();
            Banks_Options = new List <SelectListItem>();

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var data = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(data));
            }
            if (HttpContext.Session.GetString("CountryBanks") == null || HttpContext.Session.GetString("CountryBanks") == "" || HttpContext.Session.GetString("CountryBanks") == "null")
            {
                Countries = await _globalService.ConsultaBanksTF(new ParamCountry { Id = Int32.Parse(Country) });

                HttpContext.Session.SetString("CountryBanks", JsonConvert.SerializeObject(Countries));
            }
            else
            {
                Countries = JsonConvert.DeserializeObject <ListCountry>(HttpContext.Session.GetString("CountryBanks"));
            }

            if (Countries.Entities != null)
            {
                foreach (var bank in Countries.Entities)
                {
                    Banks_Options.Add(new SelectListItem()
                    {
                        Value = bank.Id, Text = bank.Person.Name
                    });
                }
            }
            List <Invoices> facturaCheck = new List <Invoices>();

            Currency_options = new List <SelectListItem>();
            Status_Options   = new List <SelectListItem>();

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            Participant = User.Claims.Where(x => x.Type == "Participant").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();
            Country         PaisesBanks  = new Country();
            List <Receipts> dataFiltered = new List <Receipts>();

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var currencies = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (currencies.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(currencies));
            }

            Currency_options = new List <SelectListItem>();

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            var principalCurrency = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currency;

            if (HttpContext.Session.GetString("PaisesBanks") == null)
            {
                PaisesBanks = await _globalService.ConsultaBanksAsync(Int32.Parse(Country), token);

                if (PaisesBanks != null && PaisesBanks.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }
                HttpContext.Session.SetString("PaisesBanks", JsonConvert.SerializeObject(PaisesBanks));
            }
            else
            {
                PaisesBanks = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("PaisesBanks"));
            }
            //pagos.AlliedAccounts = await _paymentService.ConsultaBanksAsociadosAsync(Country);
            try
            {
                pagos.Entities = PaisesBanks.Entities;
                pagos.Settings = PaisesBanks.Settings.FindAll(x => x.Abbreviation == "REGEXP_ACCOUNT_NUMBER");

                if (PaisesBanks.Settings != null)
                {
                    var setti = PaisesBanks.Settings.First(x => x.Abbreviation == "MAXLEN_ACCOUNT_NUMBER");
                    this.maxLengthAccount = Int32.Parse(setti.Content);
                }
            }
            catch (Exception ex)
            {
                var msj = ex.Message;
                pagos.Entities = new List <Entity>();
            }
            // Data de la Subasta
            var dataAuction = await _auctionService.GetAuction(Int32.Parse(Country), token);

            /*
             * if (dataAuction.Count > 0)
             * {
             *  payDate = dataAuction[0].Date;
             *
             *  var fecha = Convert.ToDateTime(payDate, CultureInfo.InvariantCulture);
             *
             *  receiptsDate = fecha.ToString("yyyy-MM-dd'T'HH:mm:ssZ");
             * } else
             * {
             */
            DateTime currentTime = DateTime.UtcNow;

            var date = Convert.ToDateTime(currentTime, CultureInfo.InvariantCulture);

            receiptsDate = date.ToString("yyyy-MM-dd'T'HH:mm:ssZ");
            //}


            if (dataAuction.Count > 0 && dataAuction[0].Error == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            var data = await _paymentService.ConsultaFacturasAsync(Owner, Country, "SALE", "draft,processing,unpaid", receiptsDate, token);

            if (data.Count > 0 && data[0].Errors == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            for (int x = 0; x < data.Count; x++)
            {
                if (data[x].Publications[0].Discount != 0)
                {
                    dataFiltered.Add(data[x]);
                }
            }

            if (principalCurrency != null)
            {
                dataFiltered = dataFiltered.OrderBy(x => x.Currency.Id != principalCurrency.Id).ThenBy(y => y.Receiver.Name).ToList();
            }

            pagos.Subasta  = dataAuction;
            pagos.Facturas = dataFiltered;
            JsonPagos      = JsonConvert.SerializeObject(pagos);
            //Refresh Token
            var w  = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault();
            var l  = await this._authService.RefreshToken(id, CultureInfo.CurrentCulture.Name, "CONFIRMANT", token, w);

            if (l.Error == null)
            {
                HttpContext.Session.SetString("token", l.Token);
            }

            return(Page());
        }
Пример #6
0
        public async Task <IActionResult> OnGetAsync()
        {
            var token = HttpContext.Session.GetString("token");
            var c     = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            var o     = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(o))
            {
                var data = await _globalService.GetDataCountryInvoices(Int32.Parse(o), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(data));
            }

            Currency_options = new List <SelectListItem>();

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            var principalCurrency = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currency;

            var dataOverdue = await this._paymentService.GetAplicationPays(o, c, token, "OVERDUE");

            if (dataOverdue.Count > 0 && dataOverdue[0].Errors == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            if (principalCurrency != null)
            {
                dataOverdue = dataOverdue.OrderBy(x => x.Currency.Id != principalCurrency.Id).ThenBy(y => y.Receiver.Name).ThenBy(z => z.Person.Name).ToList();
            }

            JsonPagosOverdue = JsonConvert.SerializeObject(dataOverdue);

            //Refresh Token
            var w  = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault();
            var l  = await this._authService.RefreshToken(id, CultureInfo.CurrentCulture.Name, "CONFIRMANT", token, w);

            if (l.Error == null)
            {
                HttpContext.Session.SetString("token", l.Token);
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            filter = new filterInvoice()
            {
                Financied = null
            };

            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            dataFilter    = JsonConvert.SerializeObject(filter);
            financiedNull = null;

            Participant      = User.Claims.Where(x => x.Type == "Participant").Select(x => x.Value).SingleOrDefault();
            Owner            = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();
            Confirmant       = User.Claims.Where(x => x.Type == "Confirmant").Select(x => x.Value).SingleOrDefault();
            Country          = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();
            Discriminator    = User.Claims.Where(x => x.Type == "Discriminator").Select(x => x.Value).SingleOrDefault();
            TipoParticipante = Participant;
            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var data = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (data.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(data));
            }
            List <Invoices> facturaCheck = new List <Invoices>();

            Supplier_Options = new List <SelectListItem>();
            Debtor_Options   = new List <SelectListItem>();
            Currency_options = new List <SelectListItem>();
            Status_Options   = new List <SelectListItem>();

            //Provicional
            ListStatus(Participant);
            //Provicional

            //GetSupplierForFactor
            if (Participant == "DEBTOR")
            {
                var proveedores = await _peopleService.GetSuppliers(Country, Owner, token);

                if (proveedores.Count > 0 && proveedores[0].Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                foreach (var supplier in proveedores)
                {
                    if (!Supplier_Options.Exists(z => z.Value == supplier.Id))
                    {
                        Supplier_Options.Add(new SelectListItem()
                        {
                            Value = supplier.Id, Text = supplier.Name
                        });
                    }
                }
            }
            else if (Participant == "SUPPLIER")
            {
                var clientes = await _peopleService.GetDeptors(Owner, token);

                if (clientes.Count > 0 && clientes[0].Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                foreach (var cls in clientes)
                {
                    if (!Supplier_Options.Exists(x => x.Value == cls.Id))
                    {
                        Supplier_Options.Add(new SelectListItem()
                        {
                            Value = cls.Id, Text = cls.Name
                        });
                    }
                }
            }
            else if (Participant == "CONFIRMANT" || Participant == "BACKOFFICE")
            {
                List <ResponseProveedores> clientes    = null;
                List <ResponseProveedores> proveedores = null;

                if (Participant == "CONFIRMANT")
                {
                    clientes = await _peopleService.GetDeptorsForConfirmant(Confirmant, token);

                    proveedores = await _peopleService.GetSupplierForConfirmant(Confirmant, token);

                    if (proveedores.Count > 0 && proveedores[0].Errors == this.__notAuthorized)
                    {
                        return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                    }
                }
                else
                {
                    clientes = await _peopleService.GetDeptorsForConfirmant(Owner, token);

                    proveedores = await _peopleService.GetSupplierForConfirmant(Owner, token);

                    if (proveedores.Count > 0 && proveedores[0].Errors == this.__notAuthorized)
                    {
                        return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                    }
                }

                foreach (var prov in proveedores)
                {
                    if (!Supplier_Options.Exists(x => x.Value == prov.Id))
                    {
                        Supplier_Options.Add(new SelectListItem()
                        {
                            Value = prov.Id, Text = prov.Name
                        });
                    }
                }
                foreach (var cls in clientes)
                {
                    if (!Debtor_Options.Exists(x => x.Value == cls.Id))
                    {
                        Debtor_Options.Add(new SelectListItem()
                        {
                            Value = cls.Id, Text = cls.Name
                        });
                    }
                }
            }
            else
            {
                var proveedores = await _peopleService.GetSupplierForFactor(Owner, token);

                if (proveedores.Count > 0 && proveedores[0].Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                foreach (var supplier in proveedores)
                {
                    if (!Supplier_Options.Exists(z => z.Value == supplier.Id))
                    {
                        Supplier_Options.Add(new SelectListItem()
                        {
                            Value = supplier.Id, Text = supplier.Name
                        });
                    }
                }
            }


            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            var token = HttpContext.Session.GetString("token");

            if (token == null)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            Participant = User.Claims.Where(x => x.Type == "Participant").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();
            Country         PaisesBanks  = new Country();
            List <Receipts> dataFiltered = new List <Receipts>();

            if (HttpContext.Session.GetString("CountryInvoices") == null || JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Id != Int32.Parse(Country))
            {
                var currencies = await _globalService.GetDataCountryInvoices(Int32.Parse(Country), token);

                if (currencies.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("CountryInvoices", JsonConvert.SerializeObject(currencies));
            }

            Currency_options = new List <SelectListItem>();

            foreach (var currency in JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currencies)
            {
                Currency_options.Add(new SelectListItem()
                {
                    Value = "" + currency.Id.Value, Text = currency.Name
                });
            }

            var principalCurrency = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryInvoices")).Currency;

            if (HttpContext.Session.GetString("PaisesBanks") == null)
            {
                PaisesBanks = await _globalService.ConsultaBanksAsync(Int32.Parse(Country), token);

                if (PaisesBanks != null && PaisesBanks.Errors == this.__notAuthorized)
                {
                    return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
                }

                HttpContext.Session.SetString("PaisesBanks", JsonConvert.SerializeObject(PaisesBanks));
            }
            else
            {
                PaisesBanks = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("PaisesBanks"));
            }
            try
            {
                pagos.Settings = PaisesBanks.Settings.FindAll(x => x.Abbreviation == "REGEXP_ACCOUNT_NUMBER");


                if (PaisesBanks.Settings != null)
                {
                    var setti = PaisesBanks.Settings.First(x => x.Abbreviation == "MAXLEN_ACCOUNT_NUMBER");
                    this.maxLengthAccount = Int32.Parse(setti.Content);
                }
            }
            catch (Exception ex)
            {
                var msj = ex.Message;
                pagos.Entities = new List <Entity>();
            }

            var dataAuction = await _auctionService.GetAuction(Int32.Parse(Country), token);

            if (dataAuction.Count > 0 && dataAuction[0].Error == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }


            var data = await _paymentService.ConsultaFacturasAsyncFactor(Owner, Country, "SALE", "draft,processing,unpaid", token);

            if (data != null && data.Count > 0 && data[0].Errors == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }

            for (int x = 0; x < data.Count; x++)
            {
                if (data[x].Publications[0].Discount != 0)
                {
                    dataFiltered.Add(data[x]);
                }
            }

            var accounts = await this._peopleService.GetConsultaAccountsPeople(new ParamProspecto()
            {
                Country     = Int32.Parse(Country),
                Participant = Participant,
                Filter      = new filterInvoice()
                {
                    Id = Owner
                }
            }, token);

            if (accounts != null && accounts.Count > 0 && accounts[0].Errors == this.__notAuthorized)
            {
                return(RedirectToPage("/logout", "session expired", new { returnUrl = "~/index?error=sessionExpired" }));
            }


            accounts = accounts.FindAll(x => x.Status);


            pagos.Entities = new List <Entity>();

            if (accounts != null)
            {
                for (var i = 0; i < accounts.Count; i++)
                {
                    if (pagos.Entities.FirstOrDefault(x => x.Id == accounts[i].Entity.Id) == null)
                    {
                        pagos.Entities.Add(accounts[i].Entity);
                    }
                }
            }

            if (principalCurrency != null)
            {
                dataFiltered = dataFiltered.OrderBy(x => x.Currency.Id != principalCurrency.Id).ThenBy(y => y.Entity.Person.Name).ToList();
            }

            pagos.Subasta = dataAuction;

            pagos.Accounts = accounts;
            pagos.Facturas = dataFiltered;
            JsonPagos      = JsonConvert.SerializeObject(pagos);

            var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault();
            var l  = await this._aS.RefreshToken(id, CultureInfo.CurrentCulture.Name, "FACTOR", token);

            if (l.Error == null)
            {
                HttpContext.Session.SetString("token", l.Token);
            }

            return(Page());
        }