Esempio n. 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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑财务应收应付
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Edit(FinanceBillEntity entity)
        {
            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.Include(a => new { a.CateNum, a.CateName, a.BillType, a.FromNum, a.FromName, a.ToNum, a.ToName, a.Amount, a.PrePayCount, a.PrePayRate, a.RealPayCount, a.LastTime, a.Title, a.ContractSn, a.ContractNum, a.Remark });
            entity.Where(a => a.SnNum == entity.SnNum).And(a => a.CompanyID == this.CompanyID);
            int line = this.FinanceBill.Update(entity);

            return(line);
        }
Esempio n. 3
0
        /// <summary>
        /// 查询门店的流水记录
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <FinancePayEntity> GeAgencyBilltList(FinancePayEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID)
            ;

            FinanceBillEntity bill = new FinanceBillEntity();

            bill.Include(a => new
            {
                Title       = a.Title,
                FromName    = a.FromName,
                ToName      = a.ToName,
                TotalAmount = a.Amount,
                LastTime    = a.LastTime,
                ContractSn  = a.ContractSn,
                ContractNum = a.ContractNum,
                BillType    = a.BillType,
                CateName    = a.CateName,
                CateNum     = a.CateNum,
            });

            entity.Left <FinanceBillEntity>(bill, new Params <string, string>()
            {
                Item1 = "BillSnNum", Item2 = "SnNum"
            });


            if (entity.PayType > 0)
            {
                entity.And(a => a.PayType == entity.PayType);
            }
            if (entity.BankName.IsNotEmpty())
            {
                entity.Where("BankName", ECondition.Like, "%" + entity.BankName + "%");
            }
            if (entity.PayNum.IsNotEmpty())
            {
                entity.Where("PayNum", ECondition.Like, "%" + entity.PayNum + "%");
            }
            if (entity.CateNum.IsNotEmpty())
            {
                bill.And(a => a.CateNum == entity.CateNum);
            }
            if (entity.Title.IsNotEmpty())
            {
                bill.And("Title", ECondition.Like, "%" + entity.Title + "%");
            }

            if (entity.BeginTime.IsNotEmpty())
            {
                DateTime time = ConvertHelper.ToType <DateTime>(entity.BeginTime, DateTime.Now.AddDays(-7)).Date;
                entity.And(a => a.PayTime >= time);
            }
            if (entity.EndTime.IsNotEmpty())
            {
                DateTime time = ConvertHelper.ToType <DateTime>(entity.EndTime, DateTime.Now).AddDays(1).Date;
                entity.And(a => a.PayTime < time);
            }
            int rowCount = 0;
            List <FinancePayEntity> listResult = this.FinancePay.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;
            return(listResult);
        }