Пример #1
0
        /// <summary>
        /// 根据采购订单转化财务账目记录
        /// 1000: 账务记录生成成功
        /// 1001:采购订单不存在
        /// 1002:已经生成账务记录,不要重复操作
        /// 1003:账务记录生成异常
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public string ToFiance(string SnNum)
        {
            PurchaseEntity entity = new PurchaseEntity();

            entity.SnNum = SnNum;
            entity       = this.GetOrder(entity);
            if (entity == null)
            {
                return("1001");
            }
            if (entity.AuditeStatus == (int)EBool.Yes)
            {
                return("1002");
            }
            FinanceBillEntity bill = new FinanceBillEntity();

            bill.SnNum       = ConvertHelper.NewGuid();
            bill.CateNum     = "";
            bill.CateName    = "";
            bill.BillType    = (int)EFinanceType.Payable;
            bill.FromNum     = "";
            bill.FromName    = "公司";
            bill.ToName      = entity.SupName;
            bill.ToNum       = entity.SupSnNum;
            bill.Amount      = entity.Amount;
            bill.Title       = string.Format("[采购][{0}]{1}", entity.CreateTime.ToString("yyyy-MM-dd"), entity.SupName);
            bill.ContractSn  = entity.SnNum;
            bill.ContractNum = entity.OrderNum;
            bill.Status      = (int)EAudite.Wait;
            bill.IsDelete    = (int)EIsDelete.NotDelete;
            bill.CreateTime  = DateTime.Now;
            bill.CreateUser  = entity.CreateUser;
            bill.Remark      = string.Empty;
            bill.CompanyID   = this.CompanyID;

            FinanceBillProvider provider = new FinanceBillProvider(this.CompanyID);
            int line = provider.Add(bill);

            if (line > 0)
            {
                entity.AuditeStatus = (int)EBool.Yes;
                entity.IncludeAuditeStatus(true);
                entity.Where(a => a.SnNum == entity.SnNum);
                line += this.Purchase.Update(entity);
            }
            return(line > 0 ? "1000" : "1003");
        }
Пример #2
0
        /// <summary>
        /// 新增财务应收应付
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string              CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            FinanceBillEntity   entity    = WebUtil.GetFormObject <FinanceBillEntity>("Entity");
            FinanceBillProvider provider  = new FinanceBillProvider(CompanyID);
            int line = provider.Add(entity);

            DataResult result = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }