Пример #1
0
        public IList <ExpenseLineConfirmHistoryExportDto> GetExpenseHistory(int expenseType, string period)
        {
            //根据不同的费用类型,进行适配转换
            ITarget adapter  = new Adapter.Adapter(_crmDbContext, _mapper, expenseType, period);
            var     entities = adapter.Transform();

            var models = _mapper.Map <List <ExpenseLineConfirmHistoryExportDto> >(entities);

            return(models);

            //var models = _expenseHistoryRepository.Where(s => s.Period == period).Select(s => _mapper.Map<ExpenseLineConfirmHistoryExportDto>(s)).ToList();
            //return models;
        }
Пример #2
0
        /// <summary>
        /// 获取核算 列表信息
        /// </summary>
        /// <param name="queryModel"></param>
        /// <returns></returns>
        public PagedResultDto <ExpenseOut> GetListDatas(ExpenseInput queryModel)
        {
            if (queryModel.Step == (int)CommonEnum.EnumCostAccountSplitStep.History)
            {
                //根据不同的费用类型,进行适配转换
                ITarget adapter  = new Adapter.Adapter(_crmDbContext, _mapper, queryModel.ExpenseType, queryModel.Period);
                var     entities = adapter.GetHistoryData(queryModel);
                return(entities);
            }

            var expression = Expression(queryModel);
            var data       = _expenseAccountRepository.PageList(expression, queryModel.CurrentPage,
                                                                queryModel.PageSize
                                                                , new Tuple <Expression <Func <ExpenseAccount, object> >, SortOrder>(s => s.ExpenseCode, SortOrder.Descending)
                                                                , new Tuple <Expression <Func <ExpenseAccount, object> >, SortOrder>(s => s.ExpenseLineNum, SortOrder.Ascending));
            var models = _mapper.Map <List <ExpenseOut> >(data.Items);
            var dic    = EnumHelper.GetValueAndDesc <CommonEnum.EnumCostAccountSplitStep>();

            models.ForEach(s => s.StepName = dic[s.Step]);
            return(new PagedResultDto <ExpenseOut>(data.Total, models));
        }
Пример #3
0
        /// <summary>
        /// 费用----添加---拆分前
        /// </summary>
        /// <param name="expenseType">费用类型</param>
        /// <param name="expenseCode"></param>
        /// <param name="period"></param>
        /// <returns></returns>
        public bool AddExpenseAccount(int expenseType, string expenseCode = "", string period = null)
        {
            //根据不同的费用类型,进行适配转换
            ITarget adapter  = new Adapter.Adapter(_crmDbContext, _mapper, expenseType, period, expenseCode);
            var     entities = adapter.Transform();

            //如果有部门为空
            var count = entities.Count(s => string.IsNullOrEmpty(s.DepartID));

            if (count > 0)
            {
                return(false);
            }

            entities.ToList().ForEach(s =>
            {
                s.Id             = 0;
                s.LastUpdateTime = DateTime.Now;
                s.CreateTime     = DateTime.Now;
                s.Step           = (int)CommonEnum.EnumCostAccountSplitStep.BeforeSplit;
            });

            using (var uow = _uowCrm.Create())
            {
                Expression <Func <ExpenseAccount, bool> > expTem = s => s.Status == 0 && s.Period == period && s.ExpenseType == expenseType;
                if (!string.IsNullOrEmpty(expenseCode))
                {
                    expTem = expTem.And(s => s.ExpenseCode == expenseCode);
                }

                var n = _expenseAccountRepository.UpdateWhere(expTem
                                                              , new ExpenseAccount()
                {
                    Status = -1, LastUpdateTime = DateTime.Now
                }, t => t.Status, t => t.LastUpdateTime);
                var i = _expenseAccountRepository.Add(entities);
                uow.SaveChanges();
                return(true);
            }
        }