コード例 #1
0
ファイル: S_C_Receipt.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        ///
        /// </summary>
        /// <param name="invoice"></param>
        public void RemoveInvoiceRelation(S_C_PlanReceipt invoice)
        {
            var marketEntities = this.GetMarketContext();
            var relationPlan   = this.S_C_InvoiceReceiptRelation.FirstOrDefault(d => d.InvoiceID == invoice.ID);

            if (relationPlan == null)
            {
                return;
            }
            marketEntities.S_C_InvoiceReceiptRelation.Remove(relationPlan);
            if (this.S_C_ManageContract != null)
            {
                this.S_C_ManageContract.SummaryInvoiceData();
            }
        }
コード例 #2
0
ファイル: S_C_Receipt.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 清除所有计划收款关联
        /// </summary>
        public void ClearPlanReceipt()
        {
            var marketEntities = this.GetMarketContext();
            var testentity     = new S_C_PlanReceipt();

            foreach (var item in this.S_C_ReceiptPlanRelation.ToList())
            {
                var plan = item.S_C_PlanReceipt;
                marketEntities.S_C_ReceiptPlanRelation.Remove(item);
                plan.Reset();
            }
            if (this.S_C_ManageContract != null)
            {
                this.S_C_ManageContract.SummaryReceiptData();
            }
        }
コード例 #3
0
ファイル: S_C_Receipt.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 移除收款与计划的绑定关系
        /// </summary>
        /// <param name="plan">计划对象</param>
        public void RemovePlanRelation(S_C_PlanReceipt plan)
        {
            var marketEntities = this.GetMarketContext();
            var relationPlan   = this.S_C_ReceiptPlanRelation.FirstOrDefault(d => d.PlanID == plan.ID);

            if (relationPlan == null)
            {
                return;
            }
            marketEntities.S_C_ReceiptPlanRelation.Remove(relationPlan);
            plan.Reset();
            if (this.S_C_ManageContract != null)
            {
                this.S_C_ManageContract.SummaryReceiptData();
            }
        }
コード例 #4
0
ファイル: S_C_ManageContract.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 保存收款项信息
        /// </summary>
        /// <param name="receiptObject">收款项对象</param>
        public void SaveReceiptObject(S_C_ManageContract_ReceiptObj receiptObject)
        {
            var marketEntities = this.GetMarketContext();
            var receiptObj     = this.S_C_ManageContract_ReceiptObj.SingleOrDefault(d => d.ID == receiptObject.ID);
            var receiptValue   = this.S_C_ManageContract_ReceiptObj.Where(d => d.ID != receiptObject.ID).Sum(d => d.ReceiptValue);

            if (receiptValue > this.ContractRMBAmount)
            {
                throw new Formula.Exceptions.BusinessException("收款项金额合计不能大于合同金额");
            }
            if (receiptObj == null)
            {
                receiptObj       = new S_C_ManageContract_ReceiptObj();
                receiptObject.ID = FormulaHelper.CreateGuid();
                FormulaHelper.UpdateModel(receiptObj, receiptObject);
                receiptObj.MileStoneState = false.ToString();
                this.S_C_ManageContract_ReceiptObj.Add(receiptObj);
                var plan = new S_C_PlanReceipt();
                receiptObj.S_C_ManageContract = this;
                //新增合同收款项的同时,新建计划收款项
                plan.Name             = receiptObj.Name;
                plan.PlanReceiptDate  = receiptObj.PlanFinishDate;
                plan.PlanReceiptValue = Convert.ToDecimal(receiptObj.ReceiptValue);
                receiptObj.AddReceiptPlan(plan);
            }
            else
            {
                if (receiptObj.FactInvoiceValue > 0 || receiptObj.FactReceiptValue > 0 || receiptObj.FactBadValue > 0)
                {
                    receiptObj.SummaryReceiptObjectData();
                    receiptObj.ProjectInfo     = receiptObject.ProjectInfo;
                    receiptObj.ProjectInfoName = receiptObject.ProjectInfoName;
                }
                else
                {
                    FormulaHelper.UpdateModel(receiptObj, receiptObject);
                    receiptObj.ResetPlan();
                }
            }
            receiptObj.SummaryReceiptObjectData();
            if (receiptObj.ReceiptValue < receiptObj.FactInvoiceValue)
            {
                throw new Formula.Exceptions.BusinessException("【" + receiptObj.Name + "】收款项金额不能小于该收款项的已开票金额:【" + receiptObj.FactInvoiceValue + "】");
            }
            if (receiptObj.ReceiptValue < receiptObj.FactReceiptValue)
            {
                throw new Formula.Exceptions.BusinessException("【" + receiptObj.Name + "】收款项金额不能小于该收款项的已到款金额:【" + receiptObj.FactReceiptValue + "】");
            }
            if (receiptObj.ReceiptValue < receiptObj.FactReceiptValue)
            {
                throw new Formula.Exceptions.BusinessException("【" + receiptObj.Name + "】收款项金额不能小于该收款项的坏账金额:【" + receiptObj.FactBadValue + "】");
            }
            receiptObj.SetPlanFinishDate();
            if (!receiptObj.OriginalPlanFinishDate.HasValue)
            {
                receiptObj.OriginalPlanFinishDate = receiptObj.PlanFinishDate;
            }
            if (this.S_C_ManageContract_ProjectRelation.Count == 1)
            {
                var projectRelation = this.S_C_ManageContract_ProjectRelation.FirstOrDefault();
                if (String.IsNullOrEmpty(receiptObj.ProjectInfo))
                {
                    receiptObj.ProjectInfo     = projectRelation.ProjectID;
                    receiptObj.ProjectInfoName = projectRelation.ProjectName;
                }
            }

            if (!String.IsNullOrEmpty(receiptObj.ProjectInfo))
            {
                if (this.S_C_ManageContract_ProjectRelation.Count(d => d.ProjectID == receiptObj.ProjectInfo) == 0 &&
                    !String.IsNullOrEmpty(receiptObj.MileStoneID))
                {
                    throw new Formula.Exceptions.BusinessException("已经绑定里程碑的收款项不能绑定其它项目,请重新添加项目【" + receiptObj.ProjectInfoName + "】");
                }
                else if (receiptObj.FactReceiptValue > 0 && this.S_C_ManageContract_ProjectRelation.Count(d => d.ProjectID == receiptObj.ProjectInfo) == 0)
                {
                    throw new Formula.Exceptions.BusinessException("已经有过到款的收款项不能绑定其它项目,请重新添加项目【" + receiptObj.ProjectInfoName + "】");
                }
            }
            else
            {
            }
            receiptObj.SchyorPlanRecipet();
        }
コード例 #5
0
ファイル: S_C_Receipt.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 将收款对象关联到计划收款对象
        /// </summary>
        /// <param name="plan">计划收款对象</param>
        /// <param name="relateValue">关联金额</param>
        /// <param name="offSet">是否冲销关联</param>
        public void RelateToPlanReceipt(S_C_PlanReceipt plan, decimal relateValue = 0, bool offSet = false)
        {
            if (relateValue == 0)
            {
                relateValue = Convert.ToDecimal(plan.PlanReceiptValue);
            }
            if (plan.State != PlanReceiptState.UnReceipt.ToString())
            {
                throw new Formula.Exceptions.BusinessException("只能关联状态为【未到款】的计划收款对象");
            }
            if (!offSet)
            {
                if (relateValue > plan.PlanReceiptValue)
                {
                    throw new Formula.Exceptions.BusinessException("收款对应到计划的金额,不能高于计划收款金额");
                }
                if (relateValue > this.MaxPlanReceiptWriteoff)
                {
                    throw new Formula.Exceptions.BusinessException("收款对应到计划的金额,不能高于收款可对应金额,请先拆分收款项");
                }
            }
            else
            {
                if (relateValue > plan.PlanReceiptValue)
                {
                    relateValue = Convert.ToDecimal(plan.PlanReceiptValue);
                }
                if (relateValue > this.MaxPlanReceiptWriteoff)
                {
                    relateValue = Convert.ToDecimal(this.MaxPlanReceiptWriteoff);
                }
            }

            if (relateValue <= 0)
            {
                return;
            }
            var userInfo       = FormulaHelper.GetUserInfo();
            var marketEntities = this.GetMarketContext();
            var relation       = this.S_C_ReceiptPlanRelation.FirstOrDefault(d => d.PlanID == plan.ID);

            if (relation == null)
            {
                relation                 = marketEntities.S_C_ReceiptPlanRelation.Create();
                relation.ID              = FormulaHelper.CreateGuid();
                relation.PlanID          = plan.ID;
                relation.ReceiptID       = this.ID;
                relation.ReceiptObjectID = plan.ReceiptObjectID;
                relation.RelateParentID  = plan.RelateParentID;
                relation.ModifyDate      = DateTime.Now;
                relation.ModifyUser      = userInfo.UserName;
                relation.ModifyUserID    = userInfo.UserID;
                marketEntities.S_C_ReceiptPlanRelation.Add(relation);
            }
            if (this.ContractInfoID != plan.ContractInfoID)
            {
                throw new Formula.Exceptions.BusinessException("非同一合同下的计划收款和收款不能进行关联");
            }
            if (this.S_C_ManageContract == null)
            {
                this.S_C_ManageContract = marketEntities.S_C_ManageContract.SingleOrDefault(d => d.ID == this.ContractInfoID);
            }
            if (this.S_C_ManageContract == null)
            {
                throw new Formula.Exceptions.BusinessException("收款对象未关联到合同信息,无法与计划收款关联");
            }
            this.S_C_ManageContract.SummaryContractData();

            if (relateValue <= 0)
            {
                throw new Formula.Exceptions.BusinessException("收款与计划的对账金额不能小于0");
            }

            relation.RelationValue = relateValue;
            plan.FactReceiptValue  = relateValue;
            plan.ReceiptDate       = this.ArrivedDate;

            //如果关联金额小于计划收款金额,则表示计划收款未全额到款,需要进行计划拆分
            if (relateValue < plan.PlanReceiptValue)
            {
                var splitValue = plan.PlanReceiptValue - relateValue;
                plan.Split(splitValue, plan.PlanReceiptDate, true);
                plan.State = PlanReceiptState.PartReceipted.ToString();
            }
            else
            {
                plan.State = PlanReceiptState.Receipted.ToString();
            }

            if (plan.S_C_ManageContract_ReceiptObj == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到计划所对应的收款项,无法进行收款与计划的关联");
            }
            plan.S_C_ManageContract_ReceiptObj.SummaryReceiptValue();
        }
コード例 #6
0
        /// <summary>
        /// 新增收款计划
        /// </summary>
        /// <param name="plan">收款计划对象</param>
        public void AddReceiptPlan(S_C_PlanReceipt plan)
        {
            var entitites = this.GetMarketContext();

            if (entitites.Entry <S_C_PlanReceipt>(plan).State != System.Data.EntityState.Added && entitites.Entry <S_C_PlanReceipt>(plan).State != System.Data.EntityState.Detached)
            {
                throw new Formula.Exceptions.BusinessException("只有新增的计划收款对象能够调用AddReceiptPlan方法");
            }
            var userInfo = FormulaHelper.GetUserInfo();

            plan.ID             = FormulaHelper.CreateGuid();
            plan.ContractInfoID = this.S_C_ManageContractID;
            plan.ContractCode   = this.S_C_ManageContract.SerialNumber;
            plan.ContractName   = this.S_C_ManageContract.Name;
            plan.CreateDate     = DateTime.Now;
            plan.CreateUser     = userInfo.UserName;
            plan.CreateUserID   = userInfo.UserID;
            plan.RelateParentID = plan.ID;
            if (!string.IsNullOrEmpty(this.S_C_ManageContract.ProductionManager))
            {
                plan.ProduceMasterID   = this.S_C_ManageContract.ProductionManager.Split(',')[0];
                plan.ProduceMasterName = this.S_C_ManageContract.ProductionManagerName.Split(',')[0];
            }
            if (!string.IsNullOrEmpty(this.S_C_ManageContract.BusinessManager))
            {
                plan.MasterID   = this.S_C_ManageContract.BusinessManager.Split(',')[0];
                plan.MasterName = this.S_C_ManageContract.BusinessManagerName.Split(',')[0];
            }
            if (!string.IsNullOrEmpty(this.S_C_ManageContract.BusinessDept))
            {
                plan.MasterUnitID = this.S_C_ManageContract.BusinessDept.Split(',')[0];
                plan.MasterUnit   = this.S_C_ManageContract.BusinessDeptName.Split(',')[0];
            }
            if (!string.IsNullOrEmpty(this.S_C_ManageContract.ProductionDept))
            {
                plan.ProductionUnitID   = this.S_C_ManageContract.ProductionDept.Split(',')[0];
                plan.ProductionUnitName = this.S_C_ManageContract.ProductionDeptName.Split(',')[0];
            }
            plan.State = PlanReceiptState.UnReceipt.ToString();
            if (plan.PlanReceiptDate.HasValue)
            {
                var date = Convert.ToDateTime(plan.PlanReceiptDate);
                plan.BelongYear    = date.Year;
                plan.BelongMonth   = date.Month;
                plan.BelongQuarter = MarketHelper.GetQuarter(date);
                if (date.Month >= 10)
                {
                    plan.PlanReceiptYearMonth = date.Year.ToString() + date.Month.ToString();
                }
                else
                {
                    plan.PlanReceiptYearMonth = date.Year.ToString() + "0" + date.Month.ToString();
                }
            }
            //plan.FirstDutyManID = this.S_C_ManageContract.BusinessManager;
            //plan.FirstDutyManName = this.S_C_ManageContract.BusinessManagerName;
            plan.ProjectCode     = this.ProjectInfo;
            plan.ProjectID       = this.ProjectInfo;
            plan.ProjectName     = this.ProjectInfoName;
            plan.CustomerID      = this.S_C_ManageContract.PartyA;
            plan.CustomerName    = this.S_C_ManageContract.PartyAName;
            plan.ReceiptObjectID = this.ID;
            entitites.S_C_PlanReceipt.Add(plan);
            plan.S_C_ManageContract = this.S_C_ManageContract;
        }