Esempio n. 1
0
        public ActionResult FilterInvoice(InvoiceFilters filters)
        {
            try
            {
                var invoices = _invoiceService.GetFilteredInvoices(filters);
                ViewBag.InvoicesReport = invoices.Result.Items;

                ViewBag.Status = "";

                string result = "";
                if (filters.DocAction == "Create" && filters.Email != null && filters.Email != "")
                {
                    result = CreateInvoiceDocument((List <InvoiceReport>)invoices.Result.Items, filters.Email, filters.Interval).Result;
                }
                else if (filters.DocAction == "Update" && filters.Email != null && filters.Email != "")
                {
                    filters = FormatFilters(filters);
                    result  = UpdateInvoiceDocument((List <InvoiceReport>)invoices.Result.Items, filters.Email, filters.Interval, filters).Result;
                }

                if (result == "OK")
                {
                    ViewBag.Status = "El documento se ha enviado a " + filters.Email + ". " +
                                     "Puede tardar alrededor de un minuto en recibir el correo.";
                }
            }
            catch
            {
                throw new RequestErrorException("Error obteniendo las facturas");
            }
            return(View("Invoice", filters));
        }
Esempio n. 2
0
 public Task <PackedList <T> > GetInvoices <T>(IProviderAgencyOwner ao, InvoiceFilters filters)
     where T : AgencyOwnerProjectInvoiceOutput, new()
 {
     return(Repository.Queryable()
            .ForAgencyOwner(ao)
            .ApplyWhereFilters(filters)
            .PaginateProjection <ProjectInvoice, T>(filters, ProjectionMapping));
 }
Esempio n. 3
0
        public async Task <IActionResult> Get([FromRoute] Guid organizationId, [FromQuery] InvoiceFilters filters)
        {
            var invoices =
                await _invoiceService.GetInvoices <AccountManagerProjectInvoiceOutput>(_accountManager, filters);

            AddPagination(filters, invoices.Total);
            return(Ok(invoices.Data));
        }
Esempio n. 4
0
 public Task <PackedList <T> > GetInvoices <T>(IOrganizationAccountManager am,
                                               InvoiceFilters filters)
     where T : AccountManagerProjectInvoiceOutput, new()
 {
     return(Repository.Queryable()
            .ForOrganizationAccountManager(am)
            .ApplyWhereFilters(filters)
            .PaginateProjection <ProjectInvoice, T>(filters, ProjectionMapping));
 }
Esempio n. 5
0
        /// <summary>
        /// Returns a list of sent invoices. Filter by an invoice filter.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public async Task <Invoice[]> GetInvoicesWithFilter(InvoiceFilters filter)
        {
            var request = new RestRequest(ResourceInvoices, HttpMethod.Get, ContentTypes.Json);

            request.AddQueryString("filter", Enum.GetName(typeof(InvoiceFilters), filter).ToLowerInvariant());

            var result = await _httpClient.ExecuteWithPolicyAsync <Invoice[]>(this, request);

            return(result);
        }
Esempio n. 6
0
 public Task <PackedList <T> > GetInvoices <T>(IOrganizationCustomer cu, InvoiceFilters filters)
     where T : CustomerProjectInvoiceOutput, new()
 {
     return(Repository.Queryable()
            .Include(x => x.Invoice)
            .ForOrganizationCustomer(cu)
            .Where(x => x.Invoice.Status == "open" || x.Invoice.Status == "paid")
            .ApplyWhereFilters(filters)
            .PaginateProjection <ProjectInvoice, T>(filters, ProjectionMapping));
 }
Esempio n. 7
0
        public ActionResult Invoice()
        {
            var model = new InvoiceFilters();

            try
            {
                var invoices = _invoiceService.GetFilteredInvoices(model);
                ViewBag.InvoicesReport = invoices.Result.Items;
            }
            catch
            {
                throw new RequestErrorException("Error obteniendo las facturas");
            }
            return(View(model));
        }
Esempio n. 8
0
        public async Task <PaginatedList <InvoiceReport> > GetFilteredInvoices(InvoiceFilters filters)
        {
            var uri      = API.Invoice.GetFilteredInvoices(_remoteServiceBaseUrl, filters);
            var response = await _httpClient.GetAsync(uri);

            if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                throw new Exception("Error obteniendo las facturas");
            }

            response.EnsureSuccessStatusCode();
            var jsonResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <PaginatedList <InvoiceReport> >(jsonResult);

            return(result);
        }
Esempio n. 9
0
            public static string GetFilteredInvoices(string baseUri, InvoiceFilters filters)
            {
                var id    = filters.Id != null ? filters.Id : 0;
                var price = filters.Price != null ? filters.Price : 0;

                string from = filters.From.HasValue  ? EscapeDataString(filters.From.Value.ToString("o")) : string.Empty;
                string to   = filters.To.HasValue ? EscapeDataString(filters.To.Value.ToString("o")) : string.Empty;

                return($"{baseUri}/Summary?" +
                       $"CreationDateFrom={from}" +
                       $"&CreationDateTo={to}" +
                       $"&id={id}" +
                       $"&price={price}" +
                       $"&currency={HttpUtility.UrlEncode(filters.Currency)}" +
                       $"&buyereu={filters.BuyerEU}" +
                       $"&buyerid={HttpUtility.UrlEncode(filters.BuyerID)}");
            }
Esempio n. 10
0
            public static string GetFilteredInvoicesLA(string baseUri, InvoiceFilters filters)
            {
                var id    = filters.Id != null ? filters.Id : 0;
                var price = filters.Price != null ? filters.Price : 0;

                string from = filters.From.HasValue  ? filters.From.Value.Date.ToString("yyyy-MM-dd") : string.Empty;
                string to   = filters.To.HasValue ? filters.To.Value.Date.ToString("yyyy-MM-dd") : string.Empty;

                return($"" +
                       $"CreationDateFrom_{from}" +
                       $"1sep1CreationDateTo_{to}" +
                       $"1sep1id_{id}" +
                       $"1sep1price_{price}" +
                       $"1sep1currency_{HttpUtility.UrlEncode(filters.Currency)}" +
                       $"1sep1buyereu_{filters.BuyerEU}" +
                       $"1sep1buyerid_{HttpUtility.UrlEncode(filters.BuyerID)}");
            }
Esempio n. 11
0
        private static Expression <Func <ProjectInvoice, bool> > WhereFilter(InvoiceFilters filters)
        {
            var expr = PredicateBuilder.True <ProjectInvoice>();

            if (filters.AccountManagerId.HasValue)
            {
                expr = expr.And(x => x.AccountManagerId == filters.AccountManagerId);
            }

            if (filters.AccountManagerOrganizationId.HasValue)
            {
                expr = expr.And(x => x.ProviderOrganizationId == filters.AccountManagerOrganizationId);
            }

            if (filters.ProjectManagerId.HasValue)
            {
                expr = expr.And(x => x.ProjectManagerId == filters.ProjectManagerId);
            }

            if (filters.ProjectManagerOrganizationId.HasValue)
            {
                expr = expr.And(x => x.ProviderOrganizationId == filters.ProjectManagerOrganizationId);
            }



            if (filters.CustomerId.HasValue)
            {
                expr = expr.And(x => x.CustomerId == filters.CustomerId);
            }

            if (filters.CustomerOrganizationId.HasValue)
            {
                expr = expr.And(x => x.BuyerOrganizationId == filters.CustomerOrganizationId);
            }



            expr.And(x => x.Invoice.IsDeleted == false);

            return(expr);
        }
Esempio n. 12
0
 public InvoiceFilters FormatFilters(InvoiceFilters filters)
 {
     if (filters.Id == null)
     {
         filters.Id = 0;
     }
     if (filters.Price == null)
     {
         filters.Price = 0;
     }
     if (filters.BuyerID == null)
     {
         filters.BuyerID = "";
     }
     if (filters.Currency == null)
     {
         filters.Currency = "";
     }
     return(filters);
 }
        public static string BuildUrlFilter(this InvoiceFilters filters)
        {
            if (filters == null)
            {
                return(string.Empty);
            }

            var str = new StringBuilder();

            Type type = typeof(InvoiceFilters);

            if (filters.DocumentType.Count > 0)
            {
                string nameOf = nameof(InvoiceFilters.DocumentType);
                string qsName = type.GetAttributeValue <UrlFilterAttribute, string>(nameOf, attr => attr.Name);
                foreach (DocumentType dt in filters.DocumentType)
                {
                    string qsValue = dt.GetAttributeValue <UrlFilterAttribute, string>(attr => attr.Name);
                    if (!string.IsNullOrWhiteSpace(qsValue))
                    {
                        str.Append($"&{qsName}={qsValue}");
                    }
                }
            }
            if (filters.DocumentStatus.Count > 0)
            {
                string nameOf = nameof(InvoiceFilters.DocumentStatus);
                string qsName = type.GetAttributeValue <UrlFilterAttribute, string>(nameOf, attr => attr.Name);
                foreach (DocumentStatus ds in filters.DocumentStatus)
                {
                    string qsValue = ds.GetAttributeValue <UrlFilterAttribute, string>(attr => attr.Name);
                    if (!string.IsNullOrWhiteSpace(qsValue))
                    {
                        str.Append($"&{qsName}={qsValue}");
                    }
                }
            }

            if (!string.IsNullOrEmpty(filters.Text))
            {
                str.Append($"&text={filters.Text.ToUrl()}");
            }

            if (filters.DueDateTo.HasValue)
            {
                str.Append($"&due_date[to]={filters.DateTo.ToUrl()}");
            }
            if (filters.DueDateFrom.HasValue)
            {
                str.Append($"&due_date[from]={filters.DueDateFrom.ToUrl()}");
            }

            if (filters.DateTo.HasValue)
            {
                str.Append($"&date[to]={filters.DateTo.ToUrl()}");
            }
            if (filters.DateFrom.HasValue)
            {
                str.Append($"&date[from]={filters.DateFrom.ToUrl()}");
            }

            if (filters.TotalBeforeTaxesFrom.HasValue)
            {
                str.Append($"&total_before_taxes[from]={filters.TotalBeforeTaxesFrom.ToUrl()}");
            }
            if (filters.TotalBeforeTaxesTo.HasValue)
            {
                str.Append($"&total_before_taxes[to]={filters.TotalBeforeTaxesTo.ToUrl()}");
            }

            if (filters.NonArchived ?? false)
            {
                str.Append($"&non_archived={filters.NonArchived.ToUrl()}");
            }

            if (filters.Archived ?? false)
            {
                str.Append($"&archived={filters.Archived.ToUrl()}");
            }

            return(str.ToString());
        }
Esempio n. 14
0
            public static HttpResponseInfo Rest_List(string apiKey, string accountName, int?page = 1, int?perPage = 10, InvoiceFilters filters = null)
            {
                string filterSrt = filters.BuildUrlFilter() ?? "";
                string url       = String.Format("https://{1}.app.invoicexpress.com/invoices.xml?api_key={0}{4}&page={2}&per_page={3}", apiKey, accountName, page, perPage, filterSrt);

                Trace.WriteLine(url);

                var result = url.HttpGet();

                if ((int)result.StatusCode != 200)
                {
                    throw new Exception(String.Format("Invalid HttpStatusCode. Expected {0}", (HttpStatusCode)200)
                                        , new Exception(result.Text));
                }
                return(result);
            }
Esempio n. 15
0
 public IEnumerable <Invoice> List(InvoiceFilters invoiceFilters)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
        public static Expression <Func <ProjectInvoice, bool> > FromFilter(InvoiceFilters filters)
        {
            var expr = PredicateBuilder.True <ProjectInvoice>();

            return(expr);
        }
Esempio n. 17
0
        public async Task <string> UpdateInvoiceDocument(List <InvoiceReport> results, string email, string interval, InvoiceFilters filters)
        {
            try
            {
                var report = new InvoiceReportToEmail
                {
                    Items    = results,
                    Email    = email,
                    Interval = interval,
                    Filters  = filters
                };

                var result = await _reportToEmail.UpdateInvoiceReportToEmail(report);


                if (result == "OK")
                {
                    return(result);
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new RequestErrorException("Error actualizando el documento de recepciones");
            }
        }
Esempio n. 18
0
            /// <summary>
            /// InvoiceXpress <a href="https://invoicexpress.com/api/invoices/list">Invoices List</a> Method
            /// </summary>
            public static InvoicesDto List(string apiKey, string accountName, int?page = 1, int?perPage = 10, InvoiceFilters filters = null)
            {
                HttpResponseInfo result = Rest_List(apiKey, accountName, page, perPage, filters);

                return(result.Text.DeserializeXml <InvoicesDto>());
            }
Esempio n. 19
0
 public IEnumerable <Invoice> List(InvoiceFilters invoiceFilters) => _repositoryFlow.List(invoiceFilters);
Esempio n. 20
0
 public static IQueryable <ProjectInvoice> ApplyWhereFilters(this IQueryable <ProjectInvoice> entities,
                                                             InvoiceFilters filters)
 {
     return(entities.Where(WhereFilter(filters)));
 }