public async Task <IActionResult> GetPayed([FromBody] ReportRequestDTO liter) { DateTime start = liter.Start; DateTime end = liter.End; var diffMonths = DiffMonths(start, end); var whereGetFuelSupply = WhereGetFuelSupply(start, end); var fuelSupply = await _reportContext.FuelsSuplly. Where(whereGetFuelSupply).ToListAsync(); dynamic report = new ExpandoObject(); var reportDic = (IDictionary <string, object>)report; for (int i = 0; i <= diffMonths; i++) { var fuelSupplyMonth = fuelSupply.Where(fs => fs.DateOfSupply.Month == start.AddMonths(i).Month); decimal payed = 0; foreach (var fs in fuelSupplyMonth) { payed += fs.ValuePay; } reportDic.Add(start.AddMonths(i).ToString("MMMM"), payed); } return(Ok(reportDic)); }
public ReportRequestDTO GetBusinessObject() { ReportRequestDTO result = new ReportRequestDTO { Id = this.Id, CreationDate = this.CreationDate, Tag = this.Tag, ReportDate = this.ReportDate, Status = this.Status, DownloadFormat = this.DownloadFormat, DownloadURL = this.DownloadURL, CallbackURL = this.CallbackURL, ReportType = this.ReportType, Preview = this.Preview, ResultCode = this.ResultCode, ResultMessage = this.ResultMessage, Sort = this.Sort }; if (Columns != null) { result.Columns = this.Columns.ToList <string>(); } if (Filters != null) { result.Filters = this.Filters != null?this.Filters.GetBusinessObject() : null; } return(result); }
public void Test_Report_Transactions_Filtered_Create() { try { ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS); string johnsId = this.GetJohn().Id; string walletId = this.GetJohnsWallet().Id; var minDebitedFunds = new Money() { Amount = 111, Currency = CurrencyIso.EUR }; var maxDebitedFunds = new Money() { Amount = 222, Currency = CurrencyIso.EUR }; var minFees = new Money() { Amount = 3, Currency = CurrencyIso.JPY }; var maxFees = new Money() { Amount = 4, Currency = CurrencyIso.JPY }; reportPost.Filters.AuthorId = johnsId; reportPost.Filters.WalletId = walletId; reportPost.Filters.MinDebitedFundsAmount = minDebitedFunds.Amount; reportPost.Filters.MinDebitedFundsCurrency = minDebitedFunds.Currency; reportPost.Filters.MaxDebitedFundsAmount = maxDebitedFunds.Amount; reportPost.Filters.MaxDebitedFundsCurrency = maxDebitedFunds.Currency; reportPost.Filters.MinFeesAmount = minFees.Amount; reportPost.Filters.MinFeesCurrency = minFees.Currency; reportPost.Filters.MaxFeesAmount = maxFees.Amount; reportPost.Filters.MaxFeesCurrency = maxFees.Currency; ReportRequestDTO report = this.Api.Reports.Create(reportPost); Assert.IsNotNull(report); Assert.AreEqual(ReportType.TRANSACTIONS, report.ReportType); Assert.IsNotNull(report.Filters); Assert.IsNotNull(report.Filters.AuthorId); Assert.AreEqual(johnsId, report.Filters.AuthorId); Assert.IsNotNull(report.Filters.WalletId); Assert.AreEqual(walletId, report.Filters.WalletId); Assert.AreEqual(minDebitedFunds.Amount, reportPost.Filters.MinDebitedFundsAmount); Assert.AreEqual(minDebitedFunds.Currency, reportPost.Filters.MinDebitedFundsCurrency); Assert.AreEqual(maxDebitedFunds.Amount, reportPost.Filters.MaxDebitedFundsAmount); Assert.AreEqual(maxDebitedFunds.Currency, reportPost.Filters.MaxDebitedFundsCurrency); Assert.AreEqual(minFees.Amount, reportPost.Filters.MinFeesAmount); Assert.AreEqual(minFees.Currency, reportPost.Filters.MinFeesCurrency); Assert.AreEqual(maxFees.Amount, reportPost.Filters.MaxFeesAmount); Assert.AreEqual(maxFees.Currency, reportPost.Filters.MaxFeesCurrency); Assert.IsTrue(report.Id.Length > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_Report_Transactions_Get() { try { ReportRequestDTO report = this.GetJohnsReport(ReportType.TRANSACTIONS); ReportRequestDTO getReport = this.Api.Reports.Get(report.Id); Assert.AreEqual(getReport.Id, report.Id); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_Report_Wallets_Get() { try { ReportRequestDTO report = this.GetJohnsReport(ReportType.WALLETS); ReportRequestDTO getReport = this.Api.Reports.Get(report.Id); Assert.AreEqual(getReport.Id, report.Id); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task Test_Reports_All() { try { ReportRequestDTO report = await this.GetJohnsReport(ReportType.TRANSACTIONS); Pagination pagination = new Pagination(1, 10); Sort sort = new Sort(); sort.AddField("CreationDate", SortDirection.desc); ListPaginated <ReportRequestDTO> list = await this.Api.Reports.GetAllAsync(pagination, null, sort); var exist = false; for (int i = 0; i < pagination.ItemsPerPage; i++) { if (report.Id == list[i].Id) { exist = true; break; } } Assert.IsNotNull(list[0]); Assert.IsTrue(exist); Assert.AreEqual(pagination.Page, 1); Assert.IsTrue(pagination.ItemsPerPage <= 10); FilterReportsList filters = new FilterReportsList(); filters.AfterDate = list[0].CreationDate; filters.BeforeDate = DateTime.Today; list = await this.Api.Reports.GetAllAsync(pagination, filters, sort); Assert.IsNotNull(list); Assert.IsTrue(list.Count == 0); filters.BeforeDate = filters.AfterDate; filters.AfterDate = DateTime.Today.AddYears(-10); list = await this.Api.Reports.GetAllAsync(pagination, filters, sort); Assert.IsNotNull(list); Assert.IsTrue(list.Count > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_Report_Transactions_Create() { try { ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS); ReportRequestDTO report = this.Api.Reports.Create(reportPost); Assert.IsNotNull(report); Assert.AreEqual(ReportType.TRANSACTIONS, report.ReportType); Assert.IsTrue(report.Id.Length > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task Test_Report_Wallets_Create() { try { ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.WALLETS); ReportRequestDTO report = await this.Api.Reports.Create(reportPost); Assert.IsNotNull(report); Assert.AreEqual(ReportType.WALLETS, report.ReportType); Assert.IsTrue(report.Id.Length > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public List <ReportResponseDTO> GetReports(ReportRequestDTO requestDto) { var reports = _planRepository.GetReports(requestDto.CompanyId, requestDto.FromDate, requestDto.ToDate); var response = new List <ReportResponseDTO>(); foreach (var report in reports) { response.Add(new ReportResponseDTO { Date = report.Date, MealName = report.MealName, Shift = PlanHelper.GetShiftName(report.Shift), TotalOrders = report.TotalOrders }); } return(response); }
public IActionResult GetReports([FromBody] ReportRequestDTO planDto) { try { var claimRole = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Role); if (claimRole == null || claimRole.Value != "Administrator") { var claimCompanyId = _httpContextAccessor.HttpContext.User.FindFirst("CompanyId"); var companyId = (claimCompanyId == null) ? 0 : Int32.Parse(claimCompanyId.Value); planDto.CompanyId = companyId; } return(Ok(_planManager.GetReports(planDto))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task Test_Report_Wallets_Filtered_Create() { try { ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.WALLETS); var temp = await this.GetJohn(); string johnsId = temp.Id; var minBalance = new Money() { Amount = 1, Currency = CurrencyIso.EUR }; var maxBalance = new Money() { Amount = 1000, Currency = CurrencyIso.EUR }; var currency = CurrencyIso.EUR; reportPost.Filters.OwnerId = johnsId; reportPost.Filters.MinBalanceAmount = minBalance.Amount; reportPost.Filters.MinBalanceCurrency = minBalance.Currency; reportPost.Filters.MaxBalanceAmount = maxBalance.Amount; reportPost.Filters.MaxBalanceCurrency = maxBalance.Currency; reportPost.Filters.Currency = currency; ReportRequestDTO report = await this.Api.Reports.Create(reportPost); Assert.IsNotNull(report); Assert.AreEqual(ReportType.WALLETS, report.ReportType); Assert.IsNotNull(report.Filters); Assert.IsNotNull(report.Filters.OwnerId); Assert.AreEqual(johnsId, report.Filters.OwnerId); Assert.AreEqual(minBalance.Amount, reportPost.Filters.MinBalanceAmount); Assert.AreEqual(minBalance.Currency, reportPost.Filters.MinBalanceCurrency); Assert.AreEqual(maxBalance.Amount, reportPost.Filters.MaxBalanceAmount); Assert.AreEqual(maxBalance.Currency, reportPost.Filters.MaxBalanceCurrency); Assert.AreEqual(currency, reportPost.Filters.Currency); Assert.IsTrue(report.Id.Length > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task <IActionResult> GetMileageWalked([FromBody] ReportRequestDTO liter) { DateTime start = liter.Start; DateTime end = liter.End; var diffMonths = DiffMonths(start, end); var whereGetFuelSupply = WhereGetFuelSupply(start, end); var fuelSupply = await _reportContext.FuelsSuplly. Where(whereGetFuelSupply).ToListAsync(); var vechilesIds = fuelSupply.Select(fs => fs.VehicleId).ToList(); var vehiclesFueldMonths = await _reportContext.Vehicles.Where(v => vechilesIds.Contains(v.Id)).ToListAsync(); decimal sumMileage = 0; dynamic report = new ExpandoObject(); var reportDic = (IDictionary <string, object>)report; for (int j = 0; j <= diffMonths; j++) { var fuelSupplyMonth = fuelSupply.Where(fs => fs.DateOfSupply.Month == start.AddMonths(j).Month).ToList(); sumMileage = 0; if (fuelSupplyMonth.Count() > 0) { foreach (var vehicle in vehiclesFueldMonths) { var fuelSupplyMonthThisVehicle = fuelSupplyMonth.Where(fs => fs.VehicleId == vehicle.Id) .OrderBy(fs => fs.DateOfSupply).ToList(); int tamFSThisVehicle = fuelSupplyMonthThisVehicle.Count(); if (tamFSThisVehicle > 1) { var fsAux = _reportContext.FuelsSuplly.Where(fs => fs.VehicleId == vehicle.Id && fs.DateOfSupply < fuelSupplyMonthThisVehicle[0].DateOfSupply) .OrderBy(fs => fs.DateOfSupply).Take(1).ToList(); if (fsAux.Count() == 0) { sumMileage += fuelSupplyMonthThisVehicle[0].SupplyedMileage - vehicle.Mileage; } else { sumMileage += fuelSupplyMonthThisVehicle[0].SupplyedMileage - fsAux[0].SupplyedMileage; } for (int i = 0; i < tamFSThisVehicle - 1; i++) { sumMileage += fuelSupplyMonthThisVehicle[i + 1].SupplyedMileage - fuelSupplyMonthThisVehicle[i].SupplyedMileage; } } else { if (tamFSThisVehicle != 0) { var fsAux = _reportContext.FuelsSuplly.Where(fs => fs.VehicleId == vehicle.Id && fs.DateOfSupply < fuelSupplyMonthThisVehicle[0].DateOfSupply) .OrderBy(fs => fs.DateOfSupply).Take(1).ToList(); if (fsAux.Count() == 0) { sumMileage += fuelSupplyMonthThisVehicle[0].SupplyedMileage - vehicle.Mileage; } else { sumMileage += fuelSupplyMonthThisVehicle[0].SupplyedMileage - fsAux[0].SupplyedMileage; } } } } } reportDic.Add(start.AddMonths(j).ToString("MMMM"), sumMileage); } return(Ok(reportDic)); }