Exemplo n.º 1
0
        public JournalViewModel GetjournalEntry(Guid?accountId, Guid?costCenterId, DateTimeOffset?from, DateTimeOffset?fromReleaseDate, DateTimeOffset?toReleaseDate, DateTimeOffset?to, JournalOptions options)
        {
            var dataQurey = _entryRep.NativeGetAll();

            if (from.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.Date.Date.Date >= from);
            }

            if (to.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.Date.Date <= to);
            }

            if (fromReleaseDate.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.CreatedDateTime.Date.Date >= fromReleaseDate);
            }

            if (toReleaseDate.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.CreatedDateTime.Date <= toReleaseDate);
            }

            if (accountId.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.Items.Any(I => I.AccountId == accountId));
            }

            if (costCenterId.HasValue)
            {
                dataQurey = dataQurey.Where(e => e.Items.Any(I => I.CostCenterId == costCenterId));
            }

            if (!options.ShowNotPostedEntries)
            {
                dataQurey = dataQurey.Where(e => e.IsPosted);
            }

            var journalViewModel = new JournalViewModel();

            journalViewModel.Items = dataQurey.Select(e => _modelFactory.CreateJournalEntryViewModel(e, options)).ToList();

            return(journalViewModel);
        }