Exemplo n.º 1
0
 public void CreateRefundBill(RefundBillModel pFeeBill)
 {
     //var document = pFeeBill.ToBsonDocument();
     //获取最大单号自动给号
     pFeeBill.BillNo = GenerateMaxBillNo();
     MongoDBHelper.RefundBill.InsertOne(pFeeBill);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 编辑单据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string EditRefundBill(RefundBillModel model)
        {
            var filter = Builders <RefundBillModel> .Filter.Eq("BillNo", model.BillNo);

            var result = MongoDBHelper.RefundBill.FindOneAndReplace(filter, model);

            return(result != null ? "Success" : "Fail");
        }
Exemplo n.º 3
0
 public void CreateRefundBill(RefundBillModel pFeeBill)
 {
     //if (pFeeBill.RefundType.ToUpper() == "FEEBILL")
     //{
     //    pFeeBill.BillNo = new FeeBill().GenerateMaxBillNo();
     //}
     //else
     //{
     //    pFeeBill.BillNo = GenerateMaxBillNo();
     //}
     MongoDBHelper.RefundBill.InsertOne(pFeeBill);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 处理还款操作(费用报销单可以超出欠款额度)
        /// </summary>
        /// <param name="model"></param>
        public string DealUnualRefundBill(RefundBillModel model)
        {
            try
            {
                var BorrowModel = MongoDBHelper.BorrowBill.Find(c => c.BillNo == model.BorrowBillNo && c.Status == 0).FirstOrDefault();
                if (model.RefundType.ToUpper() == "FEEBILL" && model.RealRefundMoney > BorrowModel.SurplusMoney)//还钱大于欠钱
                {
                    ////1往还款单里面插入一个反向现金单
                    //model.Id = MongoDB.Bson.ObjectId.Empty;
                    //model.OffsetBillNo = model.BillNo;
                    //model.RefundType = "Cash";
                    //model.Remark = "总部现金冲账";
                    //model.Items = null;
                    //model.RealRefundMoney = BorrowModel.SurplusMoney - model.RealRefundMoney;
                    //model.WorkFlowID = ""; //将WorkFlowID置空
                    //model.Flag = 1;  //冲账
                    //model.ApprovalStatus = 2;//已经通过
                    //model.CreateTime = DateTime.Now;
                    //new RefundBill().CreateRefundBill(model);

                    var filter = Builders <RefundBillModel> .Filter.Eq("BillNo", model.BillNo);

                    var update = Builders <RefundBillModel> .Update.Set("OutDebt", 1).Set("DebtMoney", BorrowModel.SurplusMoney);

                    var result = MongoDBHelper.RefundBill.UpdateOne(filter, update);

                    //2跟新原来的费用还款单还款额度(让其等于0)
                    var filter1 = Builders <BorrowBillModel> .Filter.Eq("BillNo", model.BorrowBillNo);

                    var update1 = Builders <BorrowBillModel> .Update.Set("SurplusMoney", 0);

                    var result1 = MongoDBHelper.BorrowBill.UpdateOne(filter1, update1);
                    return(result.ModifiedCount > 0 ? "Success" : "Fail");
                }
                else
                {
                    var filter = Builders <BorrowBillModel> .Filter.Eq("BillNo", model.BorrowBillNo);

                    var update = Builders <BorrowBillModel> .Update.Set("SurplusMoney", BorrowModel.SurplusMoney - model.RealRefundMoney);

                    var result = MongoDBHelper.BorrowBill.UpdateOne(filter, update);
                    return(result != null && result.ModifiedCount > 0 ? "Success" : "Fail");
                }
            }
            catch (Exception ex)
            {
                Marisfrolg.Public.Logger.Write("拆分单据失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name);
                return("Fail");
            }
        }
        public string CreateRefundBill(RefundBillModel postRefundBill)
        {
            this.Request.Url.AbsoluteUri.ToString();
            string result = "Fail";
            //费用报销单还款

            var obj = GetBrandFromCosterCenterNew(postRefundBill.PersonInfo.CostCenter);

            if (postRefundBill.RefundType.ToUpper() == "FEEBILL")
            {
                //检查
                if (string.IsNullOrEmpty(postRefundBill.COST_ACCOUNT))
                {
                    result = "成本中心为空";
                    return(result);
                }

                if (postRefundBill.Items == null || postRefundBill.Items.Count < 1)
                {
                    result = "缺少报销项";
                    return(result);
                }
                else
                {
                    postRefundBill.RealRefundMoney = postRefundBill.Items.Sum(all => all.money) + postRefundBill.Items.Sum(all => all.taxmoney);
                }
                if (postRefundBill.Photos == null || postRefundBill.Photos.Count < 1)
                {
                    result = "缺少发票照片";
                    return(result);
                }

                foreach (var item in postRefundBill.Items)
                {
                    var value = DbContext.FEE_ACCOUNT.Where(c => c.NAME == item.name || c.OLDNAME == item.name).Select(c => c.IS_MARKET).FirstOrDefault();
                    if (value == null)
                    {
                        item.IsMarket = 0;
                    }
                    else
                    {
                        item.IsMarket = Convert.ToInt32(item.IsMarket);
                    }
                }

                if (postRefundBill.PersonInfo.IsHeadOffice == 0)
                {
                    var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postRefundBill.BillsType && c.BRAND == obj.NAME).FirstOrDefault();
                    if (DicModel != null)
                    {
                        if (DicModel.PARTBRAND == 1)
                        {
                            if (postRefundBill.PersonInfo.Brand == null || postRefundBill.PersonInfo.Brand.Count < 1)
                            {
                                result = "记账品牌至少选择一项!";
                                return(result);
                            }
                            int brandcount = 0;
                            foreach (var item in postRefundBill.PersonInfo.Brand)
                            {
                                if (DicModel.BRANDLIST.Contains(item))
                                {
                                    brandcount++;
                                }
                            }
                            if (brandcount >= 2)
                            {
                                result = DicModel.BRANDLIST + "只能选择一项!";
                                return(result);
                            }
                        }
                    }

                    //增加店柜品牌属性
                    if (!string.IsNullOrEmpty(postRefundBill.PersonInfo.ShopCode))
                    {
                        postRefundBill.ShopLogo = DbContext.SHOP.Where(c => c.CODE == postRefundBill.PersonInfo.ShopCode).Select(x => x.SHOPLOGO).FirstOrDefault();
                    }
                }
            }
            //现金还款
            else
            {
                if (postRefundBill.RealRefundMoney < 0)
                {
                    result = "还款金额错误";
                    return(result);
                }
            }
            try
            {
                var BorrowModel = new BorrowBill().GetBillModel(postRefundBill.BorrowBillNo);
                //费用还款可以还款超出欠款额度,只须拆成两单
                if (postRefundBill.RealRefundMoney > BorrowModel.SurplusMoney && postRefundBill.RefundType.ToUpper() != "FEEBILL")
                {
                    result = "还款金额超出";
                    return(result);
                }
                WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy();

                string MaxNumber = string.Empty;

                if (postRefundBill.RefundType.ToUpper() == "CASH")
                {
                    postRefundBill.BillsType = "HK1";
                    MaxNumber = new RefundBill().GenerateMaxBillNo();
                }
                else
                {
                    MaxNumber = new FeeBill().GenerateMaxBillNo();
                }

                var lable = PublicDemand(postRefundBill.PersonInfo.IsHeadOffice, postRefundBill.BillsType, postRefundBill.PersonInfo.DepartmentCode, obj, postRefundBill.Items, postRefundBill.SpecialAttribute, postRefundBill.DepartmentName);

                //PackClass PackString = new PackClass() { Creator = postRefundBill.Creator, BillsType = postRefundBill.BillsType, Brand = postRefundBill.PersonInfo.Brand, CompanyCode = postRefundBill.PersonInfo.CompanyCode, CostCenter = postRefundBill.PersonInfo.CostCenter, Department = postRefundBill.PersonInfo.Department, DepartmentCode = postRefundBill.PersonInfo.DepartmentCode, IsHeadOffice = postRefundBill.PersonInfo.IsHeadOffice, Items = postRefundBill.Items == null ? null : postRefundBill.Items.Select(x => x.name).ToList() };

                //Dictionary<string, string> dic = new Dictionary<string, string>();

                //string pack = Public.JsonSerializeHelper.SerializeToJson(PackString);

                //dic.Add("pack", pack);

                //string dicString = Public.JsonSerializeHelper.SerializeToJson(dic);

                Dictionary <string, string> dic = new Dictionary <string, string>();
                string dicString = Public.JsonSerializeHelper.SerializeToJson(dic);

                try
                {
                    string sql = " insert into FEE_BILLNO (BILLNO) values('" + MaxNumber + "')";
                    int    num = DbContext.Database.ExecuteSqlCommand(sql);
                    if (num < 1)
                    {
                        DeleteInvalidBillNo(MaxNumber);
                        result = "服务器繁忙!请重新提交";
                        return(result);
                    }
                }
                catch
                {
                    result = "服务器繁忙!请重新提交";
                    return(result);
                }

                string objectID = string.Empty;

                try
                {
                    objectID = proxy.NewWorkFlowInstance(lable.CODE, postRefundBill.Creator, MaxNumber, dicString);
                }
                catch
                {
                    DeleteInvalidBillNo(MaxNumber);
                    result = "服务内部出错,请联系数控中心";
                    return(result);
                }

                postRefundBill.CreateTime = DateTime.Now;
                postRefundBill.Status     = 0;
                postRefundBill.WorkFlowID = objectID;
                postRefundBill.BillsItems = postRefundBill.Items;
                postRefundBill.BillNo     = MaxNumber;

                new RefundBill().CreateRefundBill(postRefundBill);

                result = MaxNumber;
            }
            catch
            {
                result = "Fail";
            }


            return(result);
        }
        public string EditRefundBillContent(RefundBillModel postRefundBill)
        {
            this.Request.Url.AbsoluteUri.ToString();
            string result = "Fail";
            var    obj    = GetBrandFromCosterCenterNew(postRefundBill.PersonInfo.CostCenter);

            if (postRefundBill.RefundType.ToUpper() == "FEEBILL")
            {
                if (string.IsNullOrEmpty(postRefundBill.COST_ACCOUNT))
                {
                    result = "成本中心为空";
                    return(result);
                }

                if (postRefundBill.Items == null || postRefundBill.Items.Count < 1)
                {
                    result = "缺少报销项";
                    return(result);
                }
                else
                {
                    postRefundBill.RealRefundMoney = postRefundBill.Items.Sum(all => all.money) + postRefundBill.Items.Sum(all => all.taxmoney);
                }
                if (postRefundBill.Photos == null || postRefundBill.Photos.Count < 1)
                {
                    result = "缺少发票照片";
                    return(result);
                }

                var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postRefundBill.BillsType && c.BRAND == obj.NAME).FirstOrDefault();
                if (postRefundBill.PersonInfo.IsHeadOffice == 0)
                {
                    if (DicModel != null)
                    {
                        if (DicModel.PARTBRAND == 1)
                        {
                            if (postRefundBill.PersonInfo.Brand == null || postRefundBill.PersonInfo.Brand.Count < 1)
                            {
                                result = "记账品牌至少选择一项!";
                                return(result);
                            }
                            int brandcount = 0;
                            foreach (var item in postRefundBill.PersonInfo.Brand)
                            {
                                if (DicModel.BRANDLIST.Contains(item))
                                {
                                    brandcount++;
                                }
                            }
                            if (brandcount >= 2)
                            {
                                result = DicModel.BRANDLIST + "只能选择一项!";
                                return(result);
                            }
                        }
                    }
                }
            }
            //现金还款
            else
            {
                if (postRefundBill.RealRefundMoney < 0)
                {
                    result = "还款金额错误";
                    return(result);
                }
            }
            try
            {
                var BorrowModel = new BorrowBill().GetBillModel(postRefundBill.BorrowBillNo);
                //费用还款可以还款超出欠款额度,只须拆成两单
                if (postRefundBill.RealRefundMoney > BorrowModel.SurplusMoney && postRefundBill.RefundType.ToUpper() != "FEEBILL")
                {
                    result = "还款金额超出";
                    return(result);
                }

                WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy();
                if (postRefundBill.RefundType.ToUpper() == "CASH")
                {
                    postRefundBill.BillsType = "HK1";
                }

                var lable = PublicDemand(postRefundBill.PersonInfo.IsHeadOffice, postRefundBill.BillsType, postRefundBill.PersonInfo.DepartmentCode, obj, postRefundBill.Items, postRefundBill.SpecialAttribute, postRefundBill.DepartmentName);

                Dictionary <string, string> dic = new Dictionary <string, string>();

                string dicString = Public.JsonSerializeHelper.SerializeToJson(dic);

                var    oldModel = new RefundBill().GetBillModel(postRefundBill.BillNo);
                string objectID = proxy.NewWorkFlowInstance(lable.CODE, postRefundBill.Creator, oldModel.BillNo, dicString);


                postRefundBill.BillNo         = oldModel.BillNo;
                postRefundBill.Id             = oldModel.Id;
                postRefundBill.WorkFlowID     = objectID;
                postRefundBill.CreateTime     = oldModel.CreateTime;
                postRefundBill.Status         = oldModel.Status;
                postRefundBill.ApprovalPost   = oldModel.ApprovalPost;
                postRefundBill.ApprovalStatus = oldModel.ApprovalStatus;
                postRefundBill.ApprovalTime   = oldModel.ApprovalTime;
                postRefundBill.BillsItems     = postRefundBill.Items;

                string status = new RefundBill().EditRefundBill(postRefundBill);
                if (status != "Success")
                {
                    result = "编辑失败";
                    return(result);
                }

                result = "Success";
            }
            catch
            {
                result = "Fail";
            }


            return(result);
        }
        /// <summary>
        /// 还款界面
        /// </summary>
        /// <param name="BorrowNo">借款单号</param>
        /// <param name="RefundType">还款类型</param>
        /// <returns></returns>
        public ActionResult RefundOperate(string BorrowNo = "", string RefundType = "", string BillNo = "", string Mode = "", string IsCopy = null)
        {
            RefundBill RB_Bl = new BLL.RefundBill();

            RefundBillModel oldModel = new RefundBillModel();

            if (string.IsNullOrEmpty(BorrowNo) && !string.IsNullOrEmpty(BillNo))
            {
                oldModel = RB_Bl.GetBillModel(BillNo);
                BorrowNo = oldModel.BorrowBillNo;
            }
            var             BorrowModel = new BorrowBill().GetBillModel(BorrowNo);
            FeeBillModelRef model       = new FeeBillModelRef();

            model.PageName     = "Refund";
            model.CommitType   = CommitType.还款单;
            model.RefundType   = RefundType;
            model.SurplusMoney = BorrowModel.SurplusMoney;
            model.Owner        = BorrowModel.Owner;
            model.WorkNumber   = BorrowModel.WorkNumber;
            model.BorrowBillNo = BorrowModel.BillNo;
            model.Currency     = BorrowModel.Currency;

            model.PersonInfo = new PersonInfo()
            {
                Company        = BorrowModel.PersonInfo.Company,
                CompanyCode    = BorrowModel.PersonInfo.CompanyCode,
                Department     = BorrowModel.PersonInfo.Department,
                DepartmentCode = BorrowModel.PersonInfo.DepartmentCode,
                IsHeadOffice   = BorrowModel.PersonInfo.IsHeadOffice,
                CostCenter     = BorrowModel.PersonInfo.CostCenter,
                Shop           = BorrowModel.PersonInfo.Shop,
                ShopCode       = BorrowModel.PersonInfo.ShopCode
            };

            model.ModelString = Public.JsonSerializeHelper.SerializeToJson(model);
            if (!string.IsNullOrEmpty(BillNo))
            {
                model.BillNo           = BillNo;
                model.BillsItems       = oldModel.BillsItems;
                model.PersonInfo.Brand = oldModel.PersonInfo.Brand;
                model.SpecialAttribute = oldModel.SpecialAttribute;
                model.Remark           = oldModel.Remark;
                model.CountTime        = oldModel.CountTime;
                model.Photos           = oldModel.Photos;
                model.RefundType       = oldModel.RefundType;
                model.TransactionDate  = oldModel.TransactionDate;
                if (!string.IsNullOrEmpty(IsCopy))
                {
                    model.IsCopy = 1;

                    //复制即累加次数
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("CopyCount", (model.CopyCount + 1).ToString());
                    var status = RB_Bl.PublicEditMethod(model.BillNo, dic);
                }
                model.ModelString = Public.JsonSerializeHelper.SerializeToJson(oldModel);
            }

            return(View(model));
        }
Exemplo n.º 8
0
 public void InsertOneData(RefundBillModel Model)
 {
     MongoDBHelper.RefundBill.InsertOne(Model);
 }