Example #1
0
        /// <summary>
        /// Get Accounts/Lines AccessList By UserId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <AccountAccessListUnitDto> > GetAccountAccessList(GetUserSecuritySettingsInputUnit input)
        {
            List <AccountCacheItem> accountCacheItems = new List <AccountCacheItem>();

            var accountCache = await _accountCache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            var user = await _userManager.GetUserByIdAsync(input.UserId);

            var organizationUnits = await _organizationExtendedUnitManager.GetExtendedOrganizationUnitsAsync(user, input.EntityClassificationId);

            var organizationUnitIds = organizationUnits.Select(ou => ou.Id);
            var strOrgIds           = string.Join(",", organizationUnitIds.ToArray());

            if (!string.IsNullOrEmpty(strOrgIds))
            {
                if (ReferenceEquals(input.Filters, null))
                {
                    input.Filters = new List <Filters>();
                }
                var orgfilter = new Filters()
                {
                    Property   = "OrganizationUnitId",
                    Comparator = 6,//In Operator
                    SearchTerm = strOrgIds,
                    DataType   = DataTypes.Text
                };
                input.Filters.Add(orgfilter);
            }

            if (!ReferenceEquals(input.Filters, null))
            {
                Func <AccountCacheItem, bool> multiRangeExp = null;
                var multiRangeFilters = input.Filters.Where(u => u.IsMultiRange == true).ToList();
                if (multiRangeFilters.Count != 0)
                {
                    multiRangeExp = ExpressionBuilder.GetExpression <AccountCacheItem>(Helper.GetMultiRangeFilters(multiRangeFilters), SearchPattern.Or).Compile();
                    input.Filters.RemoveAll(u => u.IsMultiRange == true);
                }

                var filterCondition = ExpressionBuilder.GetExpression <AccountCacheItem>(input.Filters).Compile();
                accountCacheItems = accountCache.ToList().Where(u => u.ChartOfAccountId == input.ChartOfAccountId)
                                    .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                    .Where(filterCondition).ToList();
            }

            return(accountCacheItems.Select(item =>
            {
                var dto = new AccountAccessListUnitDto();
                dto.AccountNumber = item.AccountNumber;
                dto.Caption = item.Caption;
                dto.OrganizationUnitId = item.OrganizationUnitId;
                dto.AccountId = item.AccountId;
                return dto;
            }).ToList());
        }
Example #2
0
        /// <summary>
        /// Get SubAccountRestrictions By SubAccountId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <SubAccountRestrictionUnitDto> > GetAccountList(GetAccountRestrictionInput input)
        {
            var cacheItem = await _accountCache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            var subaccountRestrictioncacheItem = await _subAccountRestrictionCache.GetSubAccountRestrictionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountRestrictionKey, Convert.ToInt32(_customAppSession.TenantId)));

            List <SubAccountRestrictionCacheItem> subaccountRestrictions = new List <SubAccountRestrictionCacheItem>();

            if (!ReferenceEquals(subaccountRestrictioncacheItem, null))
            {
                subaccountRestrictions = subaccountRestrictioncacheItem.ToList().Where(
                    p => p.IsActive == true && p.SubAccountId == input.SubAccountId.Value).ToList();
            }

            var result = cacheItem.ToList().Where(p => subaccountRestrictions.All(p2 => p2.AccountId != p.AccountId) && p.IsCorporate).ToList();

            return(result.Select(item =>
            {
                var dto = new SubAccountRestrictionUnitDto();
                dto.AccountId = item.AccountId;
                dto.SubAccountId = input.SubAccountId.Value;
                dto.AccountNumber = item.AccountNumber;
                dto.SubAccountRestrictionId = 0;
                dto.Caption = item.Caption;
                dto.Description = item.Description;
                return dto;
            }).ToList());
        }
Example #3
0
        /// <summary>
        /// Get the ProjectCoa AccountList
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <AccountCacheItem> > GetAccountsList(AutoSearchInput input)
        {
            var accountList = await _accountCache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(accountList.ToList().WhereIf(!string.IsNullOrEmpty(input.Query),
                                                p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) || p.AccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                                p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).Where(p => p.IsCorporate == input.Value).ToList());
        }
Example #4
0
        /// <summary>
        /// Get accounts based on Job and chartofAccountId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <AccountCacheItem> > GetAccountsList(AutoSearchInput input)
        {
            Func <AccountCacheItem, bool> expAccountCache = null;

            var chartOfAccountId = (from job in _jobUnitRepository.GetAll().Where(p => p.Id == input.JobId)
                                    select job.ChartOfAccountId).FirstOrDefault();

            var accountList = await _accountCache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            //apply User have restrictions
            if (_customAppSession.HasGLRestrictions || _customAppSession.HasLineRestrictions)
            {
                var strEntityClassification = string.Join(",", new string[] { EntityClassification.Account.ToDescription(), EntityClassification.Line.ToDescription() });
                expAccountCache = ExpressionBuilder.GetExpression <AccountCacheItem>(await GetEntityAccessFilter(strEntityClassification)).Compile();
            }

            return(accountList.ToList().WhereIf(!string.IsNullOrEmpty(input.Query),
                                                p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) || p.AccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                                p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).Where(p => p.ChartOfAccountId == chartOfAccountId)
                   .WhereIf(!ReferenceEquals(expAccountCache, null), expAccountCache).ToList());
        }