コード例 #1
0
        /// <summary>
        /// Get SubAccounts List based on OrganizationUnitId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <SubAccountCacheItem> > GetSubAccountList(AutoSearchInput input)
        {
            var cacheItem = await _subAccountCache.GetSubAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

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

            if (input.AccountId == 0 || subaccountRestrictioncacheItem.Count == 0)
            {
                return
                    (cacheItem.ToList()
                     .WhereIf(!string.IsNullOrEmpty(input.Query),
                              p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.SubAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.SearchNo.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
            }
            else
            {
                var res = from subaccount in cacheItem.ToList()
                          join subAccountRestriction in subaccountRestrictioncacheItem.Where(p => p.AccountId == input.AccountId)
                          on subaccount.SubAccountId equals subAccountRestriction.SubAccountId
                          select subaccount;
                return(res.ToList().WhereIf(!string.IsNullOrEmpty(input.Query),
                                            p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.SubAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.SearchNo.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
            }
        }
コード例 #2
0
        /// <summary>
        /// Get Project/Division AccessList By UserId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <ProjectAccessListUnitDto> > GetProjectAccessList(GetUserSecuritySettingsInputUnit input)
        {
            List <DivisionCacheItem> divisionCacheItems = new List <DivisionCacheItem>();

            AutoSearchInput cacheInput = new AutoSearchInput()
            {
                OrganizationUnitId = input.OrganizationUnitId
            };
            var divisionCache = await _divisionCache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, 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 <DivisionCacheItem, bool> multiRangeExp = null;
                var multiRangeFilters = input.Filters.Where(u => u.IsMultiRange == true).ToList();
                if (multiRangeFilters.Count != 0)
                {
                    multiRangeExp = ExpressionBuilder.GetExpression <DivisionCacheItem>(Helper.GetMultiRangeFilters(multiRangeFilters), SearchPattern.Or).Compile();
                    input.Filters.RemoveAll(u => u.IsMultiRange == true);
                }

                var filterCondition = ExpressionBuilder.GetExpression <DivisionCacheItem>(input.Filters).Compile();
                divisionCacheItems = divisionCache.ToList()
                                     .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                     .Where(filterCondition).ToList();
            }

            return(divisionCacheItems.Select(item =>
            {
                var dto = new ProjectAccessListUnitDto();
                dto.JobNumber = item.JobNumber;
                dto.Caption = item.Caption;
                dto.OrganizationUnitId = item.OrganizationUnitId;
                dto.JobId = item.JobId;
                return dto;
            }).ToList());
        }
コード例 #3
0
        /// <summary>
        /// Get Vendors List by using vendor Numbers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <List <NameValueDto> > GetVendorsListByNames(NameValueInputList input)
        {
            var vendorsList = await _vendorCache.GetVendorsCacheItemAsync(CacheKeyStores.CalculateCacheKey(CacheKeyStores.VendorKey, Convert.ToInt32(_customAppSession.TenantId)));

            var strVendorNames = input.NameValueList.Select(u => u.Name).ToArray();

            var vendorFirstNameList = vendorsList.ToList().Where(u => strVendorNames.Contains(u.FirstName))
                                      .Select(u => new NameValueDto()
            {
                Name  = u.FirstName,
                Value = u.VendorId.ToString()
            }).ToList();

            var vendorLastNameList = vendorsList.ToList().Where(u => strVendorNames.Contains(u.LastName))
                                     .Select(u => new NameValueDto()
            {
                Name  = u.LastName,
                Value = u.VendorId.ToString()
            }).ToList();

            var vendorList = vendorFirstNameList.Union(vendorLastNameList).DistinctBy(u => u.Name);
            var result     = (from vendorNames in input.NameValueList
                              join vendors in vendorList on vendorNames.Name equals vendors.Name
                              select new NameValueDto()
            {
                Name = vendorNames.Name,
                Value = vendors?.Value ?? ""
            }).ToList();

            return(result);
        }
コード例 #4
0
        /// <summary>
        /// Get Bank Accounts List which is not in BankAccountsAccessList
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <BankAccountAccessListUnitDto> > GetBankAccountList(GetUserSecuritySettingsInputUnit input)
        {
            List <BankAccountCacheItem> bankAccountCacheItems;
            AutoSearchInput             cacheInput = new AutoSearchInput()
            {
                OrganizationUnitId = input.OrganizationUnitId
            };

            var values = Enum.GetValues(typeof(TypeOfBankAccount)).Cast <TypeOfBankAccount>().Select(x => x)
                         .ToDictionary(u => u.ToDescription(), u => (int)u).Where(u => u.Value >= 1 && u.Value <= 10)
                         .Select(u => u.Key).ToArray();

            var strTypeOfbankAccount = string.Join(",", values);

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

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

            var bankAccountCache = await _bankAccountCache.GetBankAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.BankAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

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

                bankAccountCacheItems = bankAccountCache.ToList().Where(u => strTypeOfbankAccount.Contains(u.TypeOfBankAccountId.ToString()))
                                        .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                        .WhereIf(otherFilters.Count != 0, filterCondition)
                                        .Where(p => !organizationUnits.Any(p2 => p2.Id == p.OrganizationUnitId)).ToList();
            }
            else
            {
                bankAccountCacheItems = bankAccountCache.ToList()
                                        .Where(p => !organizationUnits.Any(p2 => p2.Id == p.OrganizationUnitId)).ToList();
            }


            return(bankAccountCacheItems.Select(item =>
            {
                var dto = new BankAccountAccessListUnitDto();
                dto.BankAccountNumber = item.BankAccountNumber;
                dto.BankName = item.Description;
                dto.AccountName = item.BankAccountName;
                dto.OrganizationUnitId = item.OrganizationUnitId;
                dto.BankAccountId = item.BankAccountId;
                return dto;
            }).ToList());
        }
コード例 #5
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());
        }
コード例 #6
0
        /// <summary>
        /// Get Accounts List By CoaId for autofills
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <AccountCacheItem> > GetAccountListByCoaId(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.ChartOfAccountId == input.Id).ToList());
        }
コード例 #7
0
        /// <summary>
        /// Get DivisionsList
        /// </summary>
        /// <returns></returns>
        public async Task <List <DivisionCacheItem> > GetDivisionList(AutoSearchInput input)
        {
            var cacheItem = await _divisioncache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(cacheItem.ToList().Where(p => p.IsDivision == true)
                   .WhereIf(!string.IsNullOrEmpty(input.Query), p => p.JobNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                            p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }
コード例 #8
0
        /// <summary>
        /// Get Customers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <CustomerCacheItem> > GetCustomersList(AutoSearchInput input)
        {
            var customerList = await _customercache.GetCustomersCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.CustomerKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(customerList.ToList().WhereIf(!string.IsNullOrEmpty(input.Query),
                                                 p => p.LastName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) || p.FirstName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                                 p.CustomerNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }
コード例 #9
0
        /// <summary>
        /// Get Vendors list by Classification
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <VendorCacheItem> > GetVendorsListByClassification(VendorSearchInput input)
        {
            var vendorCacheItemList = await _vendorCache.GetVendorsCacheItemAsync(CacheKeyStores.CalculateCacheKey(CacheKeyStores.VendorKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(vendorCacheItemList.ToList().Where(u => u.TypeofVendorId == input.TypeofVendorId)
                   .WhereIf(!string.IsNullOrEmpty(input.Query), p => p.LastName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                            p.FirstName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                            p.VendorAccountInfo.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                            p.VendorNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }
コード例 #10
0
        /// <summary>
        /// Get Accounts/Lines List which is not in AccountAccessList
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <AccountAccessListUnitDto> > GetAccountList(GetUserSecuritySettingsInputUnit input)
        {
            List <AccountCacheItem> accountCacheItems = new List <AccountCacheItem>();
            AutoSearchInput         cacheInput        = new AutoSearchInput()
            {
                OrganizationUnitId = input.OrganizationUnitId
            };

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

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

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


            if (!ReferenceEquals(input.Filters, null))
            {
                Func <AccountCacheItem, bool> multiRangeExp   = null;
                Func <AccountCacheItem, bool> filterCondition = 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 otherFilters = input.Filters.Where(u => u.IsMultiRange == false).ToList();
                if (otherFilters.Count != 0)
                {
                    filterCondition = ExpressionBuilder.GetExpression <AccountCacheItem>(otherFilters).Compile();
                }
                accountCacheItems = accountCache.ToList()
                                    .Where(u => u.ChartOfAccountId == input.ChartOfAccountId)
                                    .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                    .WhereIf(otherFilters.Count != 0, filterCondition)
                                    .Where(p => !organizationUnits.Any(p2 => p2.Id == p.OrganizationUnitId)).ToList();
            }
            else
            {
                accountCacheItems = accountCache.ToList().Where(u => u.ChartOfAccountId == input.ChartOfAccountId)
                                    .Where(p => !organizationUnits.Any(p2 => p2.Id == p.OrganizationUnitId)).ToList();
            }


            return(accountCacheItems.Select(item =>
            {
                var dto = new AccountAccessListUnitDto();
                dto.AccountId = item.AccountId;
                dto.AccountNumber = item.AccountNumber;
                dto.Caption = item.Caption;
                dto.OrganizationUnitId = item.OrganizationUnitId;
                return dto;
            }).ToList());
        }
コード例 #11
0
        /// <summary>
        /// Get Jobs or Divisions List by using Job Numbers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <List <NameValueDto> > GetJobOrDivisionListByNames(NameValueInputList input)
        {
            var jobOrDivisionList = await _divisionCache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(_customAppSession.TenantId)));

            var result = (from jobNames in input.NameValueList
                          join jobOrdivision in jobOrDivisionList.ToList() on jobNames.Name equals jobOrdivision.JobNumber
                          select new NameValueDto()
            {
                Name = jobNames.Name,
                Value = jobOrdivision?.JobId.ToString() ?? ""
            }).ToList();

            return(result);
        }
コード例 #12
0
        /// <summary>
        /// Get accounts List by using Account Numbers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <List <NameValueDto> > GetAccountsListByNames(NameValueInputList input)
        {
            var accountList = await _accountCache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            var result = (from accNames in input.NameValueList
                          join account in accountList.ToList() on accNames.Name equals account.AccountNumber
                          select new NameValueDto()
            {
                Name = accNames.Name,
                Value = account?.AccountId.ToString() ?? ""
            }).ToList();

            return(result);
        }
コード例 #13
0
        public async Task <List <NameValueDto> > GetEmployeeList(AutoSearchInput input)
        {
            var cacheItem = await _empCache.GetEmployeeCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.EmployeeKey, Convert.ToInt32(_customAppSession.TenantId)));

            var res = cacheItem.ToList()
                      .WhereIf(input.Property == "isDirector", p => p.IsDirector)
                      .WhereIf(input.Property == "isProducer", p => p.IsProducer)
                      .WhereIf(input.Property == "isDirPhoto", p => p.IsArtDirector)
                      .WhereIf(input.Property == "isArtDirector", p => p.IsArtDirector)
                      .WhereIf(input.Property == "isSetDesigner", p => p.IsSetDesigner)
                      .WhereIf(!string.IsNullOrEmpty(input.Query), p => p.LastName.ToUpper().Contains(input.Query.ToUpper()) || p.FirstName.ToUpper().Contains(input.Query.ToUpper()))
                      .Select(u => new NameValueDto {
                Name = u.FirstName + " " + u.LastName, Value = u.EmployeeId.ToString()
            }).ToList();

            return(res);
        }
コード例 #14
0
        /// <summary>
        /// Get Jobs or Divisions List by using OrganizationUnitId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <DivisionCacheItem> > GetJobListByStatus(AutoSearchInput input)
        {
            Func <DivisionCacheItem, bool> expDivisionCache = null;
            var cacheItem = await _divisionCache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(_customAppSession.TenantId)));

            //apply User have restrictions
            if (_customAppSession.HasProjectRestriction || _customAppSession.HasDivisionRestriction)
            {
                var strEntityClassification = string.Join(",", new string[] { EntityClassification.Division.ToDescription(), EntityClassification.Project.ToDescription() });
                expDivisionCache = ExpressionBuilder.GetExpression <DivisionCacheItem>(await GetEntityAccessFilter(strEntityClassification)).Compile();
            }

            return(cacheItem.ToList().WhereIf(!ReferenceEquals(expDivisionCache, null), expDivisionCache)
                   .Where(p => p.IsDivision == false && p.TypeOfJobStatusId != ProjectStatus.Closed && p.TypeOfJobStatusId != ProjectStatus.WrLockedap)
                   .WhereIf(!string.IsNullOrEmpty(input.Query), p => p.JobNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                            p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }
コード例 #15
0
        /// <summary>
        /// Checking DuplicateRecords
        /// </summary>
        /// <param name="divisionsList"></param>
        ///  <param name="coaId"></param>
        /// <returns></returns>
        private async Task <List <JobUnitDto> > ValidateDuplicateRecords(List <CreateJobUnitInput> divisionsList, int coaId)
        {
            var divisionNumberList = string.Join(",", divisionsList.Select(p => p.JobNumber).ToArray());
            //Geting all divisions from cache
            var duplicatedivisions = await _divisioncache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(AbpSession.GetTenantId())));

            var duplicatedivisionItems = duplicatedivisions.Where(p => p.IsDivision == true).ToList();

            //get duplicate division list
            var duplicatedivisionList =
                duplicatedivisionItems.Where(
                    p => divisionNumberList.Contains(p.JobNumber)).ToList();


            //duplicatedivisionNumbers of divisionList
            var duplicatedivisionsdivisionNumberList = (from p in divisionsList
                                                        join p2 in duplicatedivisionList on p.JobNumber equals p2.JobNumber
                                                        select new { division = p, ErrorMesage = L("DuplicatedivisionNumber") + p.JobNumber }).ToList();

            //invalid divisionList
            var errordivisions = duplicatedivisionsdivisionNumberList.Where(u => u.ErrorMesage.Trim().Length > 0).ToList();

            return(errordivisions.Select(division => new JobUnitDto
            {
                JobNumber = division.division.JobNumber, Caption = division.division.Caption,
                RollupCenterId = division.division.RollupCenterId,
                IsCorporateDefault = division.division.IsCorporateDefault,
                ChartOfAccountId = coaId, RollupAccountId = division.division.RollupAccountId,
                TypeOfCurrencyId = division.division.TypeOfCurrencyId, RollupJobId = division.division.RollupJobId,
                TypeOfJobStatusId = division.division.TypeOfJobStatusId,
                TypeOfBidSoftwareId = division.division.TypeOfBidSoftwareId,
                IsActive = division.division.IsActive,
                IsApproved = division.division.IsApproved,
                IsICTDivision = division.division.IsICTDivision,
                TypeofProjectId = division.division.TypeofProjectId,
                TaxRecoveryId = division.division.TaxRecoveryId,
                TypeOfCurrency = division.division.TypeOfCurrency,
                ErrorMessage = division.ErrorMesage.TrimEnd(',').TrimStart(',')
            }).ToList());
        }
コード例 #16
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());
        }
コード例 #17
0
        /// <summary>
        /// Checking DuplicateRecords
        /// </summary>
        /// <param name="accountsList"></param>
        /// <returns></returns>
        private async Task <List <AccountUnitDto> > ValidateDuplicateRecords(List <CreateAccountUnitInput> accountsList)
        {
            var accountunitDtoList = new List <AccountUnitDto>();
            //making commaseperated string of AccountNumbers
            var accountNumberList = string.Join(",", accountsList.Select(p => p.AccountNumber).ToArray());
            //Get the Accounts from Cache
            var duplicateAccounts = await _accountcache.GetAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            //filtering acconts with Corporate COA
            var duplicateAccountItems =
                duplicateAccounts.Where(p => p.ChartOfAccountId == accountsList[0].ChartOfAccountId).ToList();

            //Getting Duplicate AccountList
            var duplicateAccountList =
                duplicateAccountItems.Where(
                    p => accountNumberList.Contains(p.AccountNumber)).ToList();

            //Constructing Duplicate AccountEntity List with Error
            var duplicateAccountsAccountNumberList = (from p in accountsList
                                                      join p2 in duplicateAccountList on p.AccountNumber equals p2.AccountNumber
                                                      select new { account = p, ErrorMesage = L("DuplicateAccountNumber") + p.AccountNumber }).ToList();

            //Constructing OutPutDto with ErrorMessage
            foreach (var account in duplicateAccountsAccountNumberList)
            {
                var accountdto = account.account.MapTo <AccountUnit>().MapTo <AccountUnitDto>();
                accountdto.TypeOfAccount        = account.account.TypeOfAccount;
                accountdto.TypeOfCurrency       = account.account.TypeOfCurrency;
                accountdto.TypeofConsolidation  = account.account.TypeofConsolidation;
                accountdto.TypeOfCurrencyRate   = account.account.TypeOfCurrencyRate;
                accountdto.RollUpDivision       = account.account.RollUpDivision;
                accountdto.RollUpAccountCaption = account.account.RollUpAccountCaption;
                accountdto.ErrorMessage         = account.ErrorMesage.TrimEnd(',').TrimStart(',');
                accountunitDtoList.Add(accountdto);
            }
            return(accountunitDtoList);
        }
コード例 #18
0
        /// <summary>
        /// Get SubAccounts List by using SubAccount Numbers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task <List <NameValueDto> > GetSubAccountsListByNames(NameValueInputList input)
        {
            var cacheItem = await _subAccountCache.GetSubAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

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

            var subAccountRestrictionList = from subaccount in cacheItem.ToList()
                                            join subAccountRestriction in subAccountRestrictioncacheItem
                                            on subaccount.SubAccountId equals subAccountRestriction.SubAccountId
                                            select subaccount;

            var result = (from subaccountNumber in input.NameValueList
                          join subAccount in subAccountRestrictionList.ToList() on subaccountNumber.Name equals subAccount.SubAccountNumber
                          select new NameValueDto()
            {
                Name = subaccountNumber.Name,
                Value = subAccount?.SubAccountId.ToString() ?? ""
            }).ToList();

            return(result);
        }
コード例 #19
0
        /// <summary>
        /// Inserting BulkAccount
        /// </summary>
        /// <param name="listAccountUnitDtos"></param>
        /// <returns></returns>

        public async Task <List <AccountUnitDto> > BulkAccountInsert(CreateAccountListInput listAccountUnitDtos)
        {
            List <AccountUnit> accountList = new List <AccountUnit>();
            var createAccountList          = listAccountUnitDtos.AccountList.Select((item, index) => { item.ExcelRowNumber = index; return(item); }).ToList();

            //ErrorAccountList
            var erroredAccountList = await ValidateDuplicateRecords(createAccountList);

            //ValidAccountList
            var accounts    = listAccountUnitDtos.AccountList.Where(p => erroredAccountList.All(p2 => p2.AccountNumber != p.AccountNumber)).ToList();
            int accountCode = Convert.ToInt32(await _accountUnitManager.GetNextChildCodeAsync(parentId: null, coaId: listAccountUnitDtos.AccountList[0].ChartOfAccountId));

            foreach (var accountUnit in accounts)
            {
                accountUnit.ParentId = accountUnit.ParentId != 0 ? accountUnit.ParentId : null;
                var account = accountUnit.MapTo <AccountUnit>();
                account.TenantId      = AbpSession.GetTenantId();
                account.CreatorUserId = AbpSession.GetUserId();
                account.Code          = AccountUnit.CreateCode(accountCode);
                accountList.Add(account);
                accountCode++;
            }
            if (accountList.Count > 0)
            {
                await _customAccountRepository.BulkInsertAccountUnits(accountList : accountList);

                _cacheManager.GetCacheItem(CacheStoreName: CacheKeyStores.CacheAccountStore).Remove(CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(AbpSession.GetTenantId())));
            }
            return(erroredAccountList);
        }
コード例 #20
0
 public override void HandleEvent(EntityChangedEventData <JobUnit> eventData)
 {
     CacheManager.GetCacheItem(CacheStoreName: CacheKeyStores.CacheDivisionStore).Remove(CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(_customAppSession.TenantId)));
 }
コード例 #21
0
        /// <summary>
        /// Checking DuplicateRecords
        /// </summary>
        /// <param name="jobsList"></param>
        /// <returns></returns>
        private async Task <List <JobCommercialUnitDto> > ValidateDuplicateRecords(List <CreateJobCommercialInput> jobsList)
        {
            var jobNumberList = string.Join(",", jobsList.Select(p => p.JobNumber).ToArray());
            //  var descriptionList = string.Join(",", jobsList.Select(p => p.Caption).ToArray());

            var duplicatejobs = await _divisioncache.GetDivisionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(AbpSession.GetTenantId())));

            var duplicatejobItems = duplicatejobs.Where(p => p.IsDivision == false).ToList();

            var duplicatejobList =
                duplicatejobItems.Where(
                    p => jobNumberList.Contains(p.JobNumber)).ToList();


            //duplicateJobNumbers of JobList
            var duplicatejobsjobNumberList = (from p in jobsList
                                              join p2 in duplicatejobList on p.JobNumber equals p2.JobNumber
                                              select new { jobNumber = p.JobNumber, RowNumber = p.ExcelRowNumber, ErrorMesage = L("DuplicateJobNumber") + p.JobNumber }).ToList();
            //Get Joblist of unassigned BudgetFormat.
            var requiredcoaJobList = (from p in jobsList
                                      where (p.ChartOfAccountId == 0 || p.ChartOfAccountId == null)
                                      select new { jobNumber = string.Empty, RowNumber = p.ExcelRowNumber, ErrorMesage = L("BudgetFormatRequired") }).ToList();

            var jobUnits = (from job in jobsList
                            join duplicatenum in duplicatejobsjobNumberList
                            on job.ExcelRowNumber equals duplicatenum.RowNumber
                            into duplicatejobnumber
                            from duplicatejobnumberunit in duplicatejobnumber.DefaultIfEmpty()

                            join requiredcoajob in requiredcoaJobList
                            on job.ExcelRowNumber equals requiredcoajob.RowNumber
                            into requiredcoajobs
                            from requiredcoajobunit in requiredcoajobs.DefaultIfEmpty()
                            select new
            {
                job,
                ErrorMesage =
                    (!ReferenceEquals(duplicatejobnumberunit, null) ? duplicatejobnumberunit.ErrorMesage : "") +
                    (!ReferenceEquals(requiredcoajobunit, null) ? requiredcoajobunit.ErrorMesage : "")
            }).Distinct().ToList();

            //invalid JobList
            var errorjobs = jobUnits.Where(u => u.ErrorMesage.Trim().Length > 0).ToList();


            return(errorjobs.Select(job => new JobCommercialUnitDto
            {
                JobId = job.job.JobId,
                BidDate = job.job.BidDate,
                AwardDate = job.job.AwardDate,
                ShootingDate = job.job.ShootingDate,
                WrapDate = job.job.WrapDate,
                RoughCutDate = job.job.RoughCutDate,
                AirDate = job.job.AirDate,
                DateClosed = job.job.DateClosed,
                FinalShootDate = job.job.FinalShootDate,
                ProductOwner = job.job.ProductOwner,
                ProductName = job.job.ProductName,
                ExecutiveProducerId = job.job.ExecutiveProducerId,
                DirectorEmployeeId = job.job.DirectorEmployeeId,
                ProducerEmployeeId = job.job.ProducerEmployeeId,
                SetDesignerEmployeeId = job.job.SetDesignerEmployeeId,
                EditorEmployeeId = job.job.EditorEmployeeId,
                ArtDirectorEmployeeId = job.job.ArtDirectorEmployeeId,
                SalesRepId = job.job.SalesRepId,
                AgencyId = job.job.AgencyId,
                AgencyClientCustomerId = job.job.AgencyClientCustomerId,
                ThirdPartyCustomerId = job.job.ThirdPartyCustomerId,
                AgencyProducer = job.job.AgencyProducer,
                AgencyProducerContactInfo = job.job.AgencyProducerContactInfo,
                AgencyArtDirector = job.job.AgencyArtDirector,
                AgencyArtDirContactInfo = job.job.AgencyArtDirContactInfo,
                AgencyWriter = job.job.AgencyWriter,
                AgencyBusinessManager = job.job.AgencyBusinessManager,
                AgencyBusMgrContactInfo = job.job.AgencyBusMgrContactInfo,
                AgencyJobNumber = job.job.AgencyJobNumber,
                AgencyPONumber = job.job.AgencyPONumber,
                AgencyName = job.job.AgencyName,
                AgencyAddress = job.job.AgencyAddress,
                AgencyPhone = job.job.AgencyPhone,
                CommercialTitle1 = job.job.CommercialTitle1,
                CommercialTitle2 = job.job.CommercialTitle2,
                CommercialTitle3 = job.job.CommercialTitle3,
                JobNumber = job.job.JobNumber,
                Caption = job.job.Caption,
                RollupCenterId = job.job.RollupCenterId,
                IsCorporateDefault = job.job.IsCorporateDefault,
                ChartOfAccountId = job.job.ChartOfAccountId.Value,
                RollupAccountId = job.job.RollupAccountId,
                TypeOfCurrencyId = job.job.TypeOfCurrencyId,
                RollupJobId = job.job.RollupJobId,
                TypeOfJobStatusId = job.job.TypeOfJobStatusId,
                TypeOfBidSoftwareId = job.job.TypeOfBidSoftwareId,
                IsActive = job.job.IsActive,
                IsApproved = job.job.IsApproved,
                IsICTDivision = job.job.IsICTDivision,
                TypeofProjectId = job.job.TypeofProjectId,
                TaxRecoveryId = job.job.TaxRecoveryId,
                DivisionJobNumber = job.job.DivisionJobNumber,
                JobStatusName = job.job.DivisionJobNumber,
                TypeOfCurrency = job.job.TypeOfCurrency,
                TypeofProjectName = job.job.TypeofProjectName,
                BudgetFormatCaption = job.job.BudgetFormatCaption,
                ErrorMessage = job.ErrorMesage.TrimEnd(',').TrimStart(','),
                TaxCreditName = job.job.TaxCreditName
            }).ToList());
        }
コード例 #22
0
        /// <summary>
        /// BulkInsert of Divisions
        /// </summary>
        /// <param name="listDivisionUnitDtos"></param>
        /// <returns></returns>

        public async Task <List <JobUnitDto> > BulkDivisionInsert(CreateDivisionListInput listDivisionUnitDtos)
        {
            List <JobUnit> divisionList   = new List <JobUnit>();
            var            chartofaccount = _coaUnitRepository.FirstOrDefault(p => p.IsCorporate == true);

            if (ReferenceEquals(chartofaccount, null))
            {
                throw new UserFriendlyException(L("Please setup chartofaccount"));
            }
            var createDividionList = listDivisionUnitDtos.DivisionList.Select((item, index) => { item.ExcelRowNumber = index; return(item); }).ToList();
            var errorjobList       = await ValidateDuplicateRecords(createDividionList, chartofaccount.Id);

            var divisions = listDivisionUnitDtos.DivisionList.Where(p => errorjobList.All(p2 => p2.JobNumber != p.JobNumber)).ToList();

            foreach (var accountUnit in divisions)
            {
                var account = accountUnit.MapTo <JobUnit>();
                account.ChartOfAccountId = chartofaccount.Id;
                account.TenantId         = AbpSession.GetTenantId();
                account.IsDivision       = true;
                account.CreatorUserId    = AbpSession.GetUserId();
                divisionList.Add(account);
            }
            if (divisionList.Count > 0)
            {
                await _customDivisionRepository.BulkInsertDivisionUnits(divisionList : divisionList);

                _cacheManager.GetCacheItem(CacheStoreName: CacheKeyStores.CacheDivisionStore).Remove(CacheKeyStores.CalculateCacheKey(CacheKeyStores.DivisionKey, Convert.ToInt32(AbpSession.GetTenantId())));
            }
            return(errorjobList);
        }
コード例 #23
0
        /// <summary>
        /// Get Bank Accounts Access List By UserId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <BankAccountAccessListUnitDto> > GetBankAccountAccessList(GetUserSecuritySettingsInputUnit input)
        {
            List <BankAccountCacheItem> bankAccountCacheItems = new List <BankAccountCacheItem>();

            AutoSearchInput cacheInput = new AutoSearchInput()
            {
                OrganizationUnitId = input.OrganizationUnitId
            };
            var bankAccountCache = await _bankAccountCache.GetBankAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.BankAccountKey, 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());


            var values = Enum.GetValues(typeof(TypeOfBankAccount)).Cast <TypeOfBankAccount>().Select(x => x)
                         .ToDictionary(u => u.ToDescription(), u => (int)u).Where(u => u.Value >= 1 && u.Value <= 10)
                         .Select(u => u.Key).ToArray();

            var strTypeOfbankAC = string.Join(",", values);

            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 <BankAccountCacheItem, bool> multiRangeExp = null;
                var multiRangeFilters = input.Filters.Where(u => u.IsMultiRange == true).ToList();
                if (multiRangeFilters.Count != 0)
                {
                    multiRangeExp = ExpressionBuilder.GetExpression <BankAccountCacheItem>(Helper.GetMultiRangeFilters(multiRangeFilters), SearchPattern.Or).Compile();
                    input.Filters.RemoveAll(u => u.IsMultiRange == true);
                }

                var filterCondition = ExpressionBuilder.GetExpression <BankAccountCacheItem>(input.Filters).Compile();
                bankAccountCacheItems = bankAccountCache.ToList()
                                        .Where(u => strTypeOfbankAC.Contains(u.TypeOfBankAccountId.ToString()))
                                        .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                        .Where(filterCondition).ToList();
            }

            return(bankAccountCacheItems.Select(item =>
            {
                var dto = new BankAccountAccessListUnitDto
                {
                    BankAccountNumber = item.BankAccountNumber,
                    BankName = item.Description,
                    AccountName = item.BankAccountName,
                    OrganizationUnitId = item.OrganizationUnitId,
                    BankAccountId = item.BankAccountId
                };
                return dto;
            }).ToList());
        }
コード例 #24
0
        /// <summary>
        /// Get BankAccountList
        /// </summary>
        /// <returns></returns>
        public async Task <List <BankAccountCacheItem> > GetBankAccountList(AutoSearchInput input)
        {
            var bankCacheItemList = await _bankAccountCache.GetBankAccountCacheItemAsync(CacheKeyStores.CalculateCacheKey(CacheKeyStores.BankAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(bankCacheItemList.WhereIf(!string.IsNullOrEmpty(input.Query), p => p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                             p.BankAccountName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                             p.BankAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }