public async Task <CustomerStatementDto> GetCustomerStatementAsync(CustomerStatementDto model)
        {
            //await _customerManager.SetOverdueStatus(model.CustomerId);
            var pagedResult = await _customerManager.GetCustomerStatementAsync(model);

            return(pagedResult);
        }
Пример #2
0
        public async Task <CustomerStatementDto> GetCustomerStatementAsync(CustomerStatementDto model)
        {
            var customerStatement = await(from i in _dataContext.Invoices
                                          join c in _dataContext.Customers
                                          on i.CustomerId equals c.Id
                                          where (i.CustomerId == model.CustomerId) && i.Status != Constants.InvoiceStatus.Deleted
                                          select new CustomerStatementDto
            {
                startDate      = model.startDate,
                endDate        = model.endDate,
                CustomerId     = model.CustomerId,
                openingBalance = model.openingBalance,
                Customer       = new CustomerDetailDto
                {
                    FirstName = c.FirstName,
                    LastName  = c.LastName,
                    Email     = c.Email,
                    Phone     = c.Phone,
                    Discount  = c.Discount,
                    Address   = new AddressDto
                    {
                        StreetNumber = c.Address.StreetNumber,
                        StreetName   = c.Address.StreetName,
                        City         = c.Address.City,
                        State        = c.Address.State,
                        CountryName  = c.Address.Country.Name,
                        PostalCode   = c.Address.PostalCode,
                        Phone        = c.Address.Phone
                    }
                },
                InvoiceList = c.Invoices.Select(x => new InvoiceListItemDto
                {
                    Id          = x.Id,
                    CustomerId  = x.CustomerId,
                    Description = x.Remark,
                    Discount    = x.Discount,
                    InvoiceDate = x.InvoiceDate,
                    DueDate     = x.DueDate,
                    //Amount = i.Services.Sum(x => x.Rate),
                    Tax           = x.Tax,
                    TotalAmount   = x.TotalAmount,
                    CreatedOn     = x.CreatedOn,
                    InvoiceNumber = x.InvoiceNumber,
                    Status        = x.Status
                })
            })
                                    .AsNoTracking().ToListAsync();

            return(customerStatement.FirstOrDefault());
        }
Пример #3
0
        public async Task <CustomerStatementDto> GetCustomerStatementAsync(CustomerStatementDto model)
        {
            if (model.Status == 1)
            {
                var data = await _customerRepository.GetOpeningBalance(model.startDate, model.CustomerId);

                model.openingBalance = data.Sum(x => x.Amount);
                var customerData = await _customerRepository.GetCustomerStatementAsync(model);

                customerData.InvoiceList = customerData.InvoiceList.Where(p => (p.InvoiceDate >= model.startDate && p.InvoiceDate <= model.endDate) && p.Status != Constants.InvoiceStatus.Deleted).ToList();
                return(customerData);
            }
            else
            {
                return(await _customerRepository.GetCustomerStatementAsync(model));
            }
        }