示例#1
0
        /// <summary>
        /// 新增财务实收实付
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(FinancePayEntity entity)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                entity.SnNum      = ConvertHelper.NewGuid();
                entity.PayNum     = new SequenceProvider(this.CompanyID).GetSequence(typeof(FinancePayEntity));
                entity.CreateTime = DateTime.Now;
                entity.CompanyID  = this.CompanyID;
                entity.IncludeAll();
                int line = this.FinancePay.Add(entity);


                FinancePayEntity pay = new FinancePayEntity();
                pay.IncludeAll();
                pay.Where(a => a.BillSnNum == entity.BillSnNum)
                .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
                .And(a => a.CompanyID == this.CompanyID)
                ;
                List <FinancePayEntity> listResult = this.FinancePay.GetList(pay);
                if (!listResult.IsNullOrEmpty())
                {
                    int    RealPayCount = listResult.Count();
                    double TotalAmount  = listResult.Sum(a => a.Amount);

                    FinanceBillEntity bill = new FinanceBillEntity();
                    bill.IncludeAll();
                    bill.Where(a => a.SnNum == entity.BillSnNum)
                    .And(a => a.CompanyID == this.CompanyID)
                    ;
                    bill = this.FinanceBill.GetSingle(bill);

                    if (bill != null)
                    {
                        FinanceBillEntity finance = new FinanceBillEntity();
                        finance.RealPayCount  = RealPayCount;
                        finance.RealPayAmount = TotalAmount;
                        if (TotalAmount == 0)
                        {
                            finance.Status = (int)EFinanceStatus.InProgress;
                        }
                        else if (TotalAmount > 0 && TotalAmount < bill.Amount)
                        {
                            finance.Status = (int)EFinanceStatus.PayPart;
                        }
                        else if (TotalAmount >= bill.Amount)
                        {
                            finance.Status = (int)EFinanceStatus.PayFull;
                        }
                        finance.Where(a => a.SnNum == bill.SnNum)
                        .And(a => a.CompanyID == this.CompanyID)
                        ;
                        finance.Include(a => new { a.RealPayAmount, a.RealPayCount, a.Status });
                        line += this.FinanceBill.Update(finance);
                    }
                }
                ts.Complete();

                return(line);
            }
        }
示例#2
0
        /// <summary>
        /// 新增应收应付
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(FinanceBillEntity entity)
        {
            entity.SnNum      = ConvertHelper.NewGuid();
            entity.BillNum    = entity.BillNum.IsEmpty() ? DateTime.Now.ToString("yyyyMMdd") + new TNumProvider(this.CompanyID).GetSwiftNumByDay(typeof(FinanceBillEntity), 4) : entity.BillNum;
            entity.CreateTime = DateTime.Now;
            entity.IsDelete   = (int)EIsDelete.NotDelete;
            entity.Status     = (int)EFinanceStatus.Wait;
            entity.CompanyID  = this.CompanyID;
            if (entity.CateNum.IsNotEmpty())
            {
                List <FinanceCateEntity> listCate = new FinanceCateProvider(this.CompanyID).GetList();
                if (!listCate.IsNullOrEmpty())
                {
                    FinanceCateEntity cate = listCate.FirstOrDefault(a => a.SnNum == entity.CateNum);
                    entity.CateName = cate != null ? cate.CateName : string.Empty;
                }
            }
            entity.IncludeAll();
            int line = this.FinanceBill.Add(entity);

            return(line);
        }
示例#3
0
        /// <summary>
        /// 查询财务应收应付
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public FinanceBillEntity GetSingle(string SnNum)
        {
            FinanceBillEntity entity = new FinanceBillEntity();

            entity.IncludeAll();
            entity.Where(a => a.SnNum == SnNum)
            .And(a => a.CompanyID == this.CompanyID)
            .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
            ;

            AdminEntity admin = new AdminEntity();

            admin.Include(a => new { CreateUserName = a.UserName });
            entity.Left <AdminEntity>(admin, new Params <string, string>()
            {
                Item1 = "CreateUser", Item2 = "UserNum"
            });

            entity            = this.FinanceBill.GetSingle(entity);
            entity.LeavAmount = entity.Amount - entity.RealPayAmount;
            return(entity);
        }
示例#4
0
        /// <summary>
        /// 查询财务应收应付分页列表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <FinanceBillEntity> GetList(FinanceBillEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);

            AdminEntity admin = new AdminEntity();

            admin.Include(a => new { CreateUserName = a.UserName });
            entity.Left <AdminEntity>(admin, new Params <string, string>()
            {
                Item1 = "CreateUser", Item2 = "UserNum"
            });

            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID)
            ;
            if (entity.BillNum.IsNotEmpty())
            {
                entity.Where("BillNum", ECondition.Like, "%" + entity.BillNum + "%");
            }
            if (entity.BillType > 0)
            {
                entity.And(a => a.BillType == entity.BillType);
            }
            if (entity.CateNum.IsNotEmpty())
            {
                entity.And(a => a.CateNum == entity.CateNum);
            }
            if (entity.Title.IsNotEmpty())
            {
                entity.And("Title", ECondition.Like, "%" + entity.Title + "%");
            }
            if (entity.ContractNum.IsNotEmpty())
            {
                entity.And("ContractNum", ECondition.Like, "%" + entity.ContractNum + "%");
            }
            if (entity.Status > 0)
            {
                entity.And(a => a.Status == entity.Status);
            }
            if (entity.BeginTime.IsNotEmpty())
            {
                DateTime dateTime = ConvertHelper.ToType <DateTime>(entity.BeginTime, DateTime.Now.AddDays(-1));
                entity.And(a => a.CreateTime >= dateTime);
            }
            if (entity.EndTime.IsNotEmpty())
            {
                DateTime dateTime = ConvertHelper.ToType <DateTime>(entity.EndTime, DateTime.Now).AddDays(1).Date;
                entity.And(a => a.CreateTime < dateTime);
            }
            if (entity.FromNum.IsNotEmpty())
            {
                entity.And(item => item.FromNum == entity.FromNum);
            }
            if (entity.FromName.IsNotEmpty())
            {
                entity.And("FromName", ECondition.Like, "%" + entity.FromName + "%");
            }
            if (entity.ToNum.IsNotEmpty())
            {
                entity.And(item => item.ToNum == entity.ToNum);
            }
            if (entity.ToName.IsNotEmpty())
            {
                entity.And("ToName", ECondition.Like, "%" + entity.ToName + "%");
            }
            int rowCount = 0;
            List <FinanceBillEntity> listResult = this.FinanceBill.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.LeavAmount = a.Amount - a.RealPayAmount;
                });
            }
            return(listResult);
        }
示例#5
0
        /// <summary>
        /// 删除实收实付
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public int Delete(string SnNum)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                FinancePayEntity entity = new FinancePayEntity();
                entity.SnNum = SnNum;
                entity.IncludeAll();
                entity.Where(a => a.SnNum == SnNum)
                .And(a => a.CompanyID == this.CompanyID)
                ;
                entity = this.FinancePay.GetSingle(entity);

                FinancePayEntity finEntity = new FinancePayEntity();
                finEntity.IsDelete = (int)EIsDelete.Deleted;
                finEntity.IncludeIsDelete(true);
                finEntity.Where(a => a.SnNum == SnNum)
                .And(a => a.CompanyID == this.CompanyID)
                ;
                int line = this.FinancePay.Update(finEntity);

                FinancePayEntity pay = new FinancePayEntity();
                pay.IncludeAll();
                pay.Where(a => a.BillSnNum == entity.BillSnNum)
                .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
                .And(a => a.CompanyID == this.CompanyID)
                ;
                List <FinancePayEntity> listResult = this.FinancePay.GetList(pay);
                if (!listResult.IsNullOrEmpty())
                {
                    int    RealPayCount = listResult.Count();
                    double TotalAmount  = listResult.Sum(a => a.Amount);

                    FinanceBillEntity bill = new FinanceBillEntity();
                    bill.IncludeAll();
                    bill.Where(a => a.SnNum == entity.BillSnNum)
                    .And(a => a.CompanyID == this.CompanyID)
                    ;
                    bill = this.FinanceBill.GetSingle(bill);

                    if (bill != null)
                    {
                        FinanceBillEntity finance = new FinanceBillEntity();
                        finance.RealPayCount = RealPayCount;

                        if (TotalAmount == 0)
                        {
                            finance.Status = (int)EFinanceStatus.InProgress;
                        }
                        else if (TotalAmount > 0 && TotalAmount < bill.Amount)
                        {
                            finance.Status = (int)EFinanceStatus.PayPart;
                        }
                        else if (TotalAmount >= bill.Amount)
                        {
                            finance.Status = (int)EFinanceStatus.PayFull;
                        }
                        finance.Where(a => a.SnNum == bill.SnNum)
                        .And(a => a.CompanyID == this.CompanyID)
                        ;
                    }
                }

                ts.Complete();

                return(line);
            }
        }