public async Task <(bool hasReport, object report, string message)> PreProcessingSalesPunctuation(FilterDto filterDto) { var sales = await _saleRepository.CustomFind(x => !x.Activated && !x.Processed && x.CurrentMonth == filterDto.CurrentMonth && x.CurrentYear == filterDto.CurrentYear, x => x.Network); if (!sales.Any()) { return(false, null, "Nenhum registro encontrado no parametro informado"); } var networks = await _networkRepository.GetAll(); networks = networks.OrderBy(x => x.Name); var report = networks.Select(x => new { Network = x.Name, Salesman = sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation), RegionManager = sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation) * (decimal)0.05, Manager = sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation) * (decimal)0.1, Total = sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation) + (sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation) * (decimal)0.05) + (sales.Where(s => s.Network.Id == x.Id).Sum(s => s.Punctuation) * (decimal)0.1) }).ToList(); return(true, report, "Relatório gerado com sucesso"); }
public async Task ProcessesPunctuation() { var sales = await _saleRepository.CustomFind(x => x.Activated && !x.Processed, x => x.User, x => x.Shop); var punctuationList = new List <UserPunctuation>(); if (sales.Any()) { await ProcessesSalesman(sales); await ProcessesManagers(sales); await ProcessesRegionManagers(sales); await _unitOfWork.CommitAsync(); } }
public async Task <IEnumerable <Sale> > GetUserSales(int userId, int currentMonth, int currentYear) => await _saleRepository.CustomFind(x => x.User.Id == userId && x.CurrentMonth == currentMonth && x.CurrentYear == currentYear, x => x.Product, x => x.Product.CategoryProduct);