using Contracts.Mappers; using Contracts.Repositories; using Contracts.SearchModels; using Contracts.Services; using Contracts.ViewModels; using Services.Support.Exceptions; namespace Services.Reports; public class ReportOffsetFromPlanService : IReportOffsetFromPlanService { private readonly ISpendingGroupRepo _spendingGroupRepo; public ReportOffsetFromPlanService(ISpendingGroupRepo spendingGroupRepo) { _spendingGroupRepo = spendingGroupRepo; } public async Task GetReportData(SpendingPlanSearch search) { var group = await _spendingGroupRepo.GetByPlan(search); if (group == null) { throw new EntityNotFoundException("Не удалось найти группу по такому плану"); } if (!group.ChangeRecords.Any()) { throw new ReportDataNotFoundException("Данные об изменении баланса отсутствуют"); } return group.ToView(); } }