Ejemplo n.º 1
0
        public static RenewalAnalysisDTO InitPage(string projectId)
        {
            RenewalAnalysisDTO dto = new RenewalAnalysisDTO();
            var consInfo           = RenewalConsInfo.Get(projectId);
            var analysis           = Get(projectId);

            if (consInfo.HasReinvenstment)
            {
                var reinBasic = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                analysis.OperationSize = reinBasic.NewOperationSize;
            }
            dto.Info = RenewalInfo.Get(projectId);
            analysis.LastRemodeling = GetLastRemodeling(dto.Info.USCode);
            dto.Entity           = analysis;
            dto.HasReinvenstment = consInfo.HasReinvenstment;
            dto.StoreInfo        = PrepareStoreInfo(projectId, dto.Info.USCode);
            dto.Editable         = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Analysis);
            dto.Recallable       = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Analysis);
            dto.Savable          = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Analysis);
            return(dto);
        }
Ejemplo n.º 2
0
        public static RenewalGBMemo GetGBMemo(string projectId, string entityId = "")
        {
            var memo = (string.IsNullOrEmpty(entityId) ?
                        FirstOrDefault(e => e.ProjectId.Equals(projectId) && !e.IsHistory)
                : FirstOrDefault(e => e.Id.ToString().Equals(entityId))) ?? new RenewalGBMemo();

            memo.ProjectId = projectId;

            var rnInfo = RenewalInfo.Get(projectId);

            memo.Info   = rnInfo;
            memo.UsCode = rnInfo.USCode;

            memo.Store = StoreBasicInfo.GetStore(memo.UsCode);

            if (memo.Id == Guid.Empty)
            {
                memo.IsClosed      = (memo.Store.StoreBasicInfo.statusName == "Closed");
                memo.IsInOperation = false;
                var consInfo = new RenewalConsInfo();
                memo.ReinvestInfo = consInfo.GetReinvestmentBasicInfo(projectId);
                if (memo.ReinvestInfo != null)
                {
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.IsKiosk = true;
                    }
                    memo.IsMcCafe = memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value;
                    memo.IsMDS    = memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value;
                    memo.Is24Hour = memo.ReinvestInfo.NewTwientyFourHour.HasValue &&
                                    memo.ReinvestInfo.NewTwientyFourHour.Value;
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                    memo.ConstCompletionDate = memo.ReinvestInfo.ConsCompletionDate;
                    memo.ReopenDate          = memo.ReinvestInfo.ReopenDate;
                }
                memo.Save();
            }
            else
            {
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId &&
                                                             e.FlowCode == FlowCode.Renewal_GBMemo);

                if (projectInfo != null)
                {
                    if (ClientCookie.UserCode.Equals(rnInfo.PMAccount))
                    {
                        var isFlowFlinshed =
                            TaskWork.Any(e =>
                                         e.RefID == projectId && e.TypeCode == FlowCode.Renewal_GBMemo &&
                                         e.Status == TaskWorkStatus.K2ProcessApproved && e.ProcInstID == memo.ProcInstID);
                        var isExistTask = TaskWork.Any(e => e.RefID == projectId &&
                                                       e.TypeCode == FlowCode.Renewal_GBMemo &&
                                                       e.Status == TaskWorkStatus.UnFinish &&
                                                       e.ReceiverAccount == ClientCookie.UserCode &&
                                                       (e.ActivityName == WFMajorLeaseLegalReview.Act_Originator || e.ActivityName == WFMajorLeaseLegalReview.Act_Start));
                        memo.IsShowEdit   = isFlowFlinshed;
                        memo.IsShowRecall = !isFlowFlinshed && !isExistTask;
                    }
                }
            }
            //if (ClientCookie.UserCode.Equals(rnInfo.PMAccount))
            //    memo.IsShowSave = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_GBMemo);
            PopulateAppUsers(memo);
            return(memo);
        }
Ejemplo n.º 3
0
        public static RenewalToolDTO InitPage(string projectId, string id = null)
        {
            RenewalToolDTO dto       = new RenewalToolDTO();
            var            tool      = RenewalTool.Get(projectId, id);
            var            project   = ProjectInfo.Get(projectId, FlowCode.Renewal_Tool);
            var            info      = RenewalInfo.Get(projectId);
            var            isFinance = ClientCookie.UserCode == info.FinanceAccount;

            tool.IsProjectFreezed = tool.CheckIfFreezeProject(projectId);
            var    nextRefTableId    = new Guid(FlowInfo.GetRefTableId("RenewalAnalysis", projectId));
            var    nextFlowStarted   = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Analysis);
            var    haveTask          = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var    projectComment    = ProjectComment.GetSavedComment(tool.Id, "RenewalTool", ClientCookie.UserCode);
            var    projectNode       = NodeInfo.GetNodeInfo(project.NodeCode);
            var    packageStarted    = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            string selectedYearMonth = null;

            dto.Info              = info;
            dto.Entity            = tool;
            dto.TTMDataYearMonths = RenewalToolFinMeasureInput.GetYearMonths(projectId, out selectedYearMonth);
            dto.FinMeasureInput   = RenewalToolFinMeasureInput.Get(projectId, dto.Entity.Id);
            if (string.IsNullOrEmpty(dto.FinMeasureInput.FinanceYear) || string.IsNullOrEmpty(dto.FinMeasureInput.FinanceMonth))
            {
                var ym = selectedYearMonth.Split('-');
                dto.FinMeasureInput.FinanceYear  = ym[0];
                dto.FinMeasureInput.FinanceMonth = ym[1];
            }
            dto.FinMeasureInput.FinanceDataYearMonth = dto.FinMeasureInput.FinanceYear + "-" + dto.FinMeasureInput.FinanceMonth;
            //dto.FinMeasureInput.ContributionMargin = StoreCM.Get(dto.Info.USCode).ContributionMargin;
            McdAMEntities amdb  = new McdAMEntities();
            var           finfo = amdb.DataSync_LDW_AM_STFinanceData2.FirstOrDefault(f => f.UsCode == dto.Info.USCode &&
                                                                                     f.FinanceYear == dto.FinMeasureInput.FinanceYear && f.FinanceMonth == dto.FinMeasureInput.FinanceMonth);
            decimal cm = 0;

            if (finfo != null && !string.IsNullOrEmpty(finfo.contribution_marginPct))
            {
                cm = decimal.Parse(finfo.contribution_marginPct);
            }
            dto.FinMeasureInput.ContributionMargin = cm;
            var coninfo = RenewalConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
            var conProj = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId && e.FlowCode == "Renewal_ConsInfo");

            dto.WriteOffAndReinCost = RenewalToolWriteOffAndReinCost.Get(projectId, dto.Entity.Id, projectNode);
            if (coninfo != null && !coninfo.HasReinvenstment)
            {
                dto.WriteOffAndReinCost.REWriteOff   = null;
                dto.WriteOffAndReinCost.LHIWriteOff  = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.RECost       = null;
                dto.WriteOffAndReinCost.LHICost      = null;
                dto.WriteOffAndReinCost.ESSDCost     = null;
            }

            dto.Uploadable     = projectNode.Sequence >= 3 && ClientCookie.UserCode == dto.Info.AssetActorAccount && !packageStarted;
            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Tool);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Tool);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Tool) && string.IsNullOrEmpty(id);
            dto.IsFinished     =
                ProjectInfo.Any(
                    e =>
                    e.ProjectId == projectId && e.FlowCode == FlowCode.Renewal_Tool &&
                    e.Status == ProjectStatus.Finished);
            return(dto);
        }
Ejemplo n.º 4
0
        public void Save(bool pushOrNot)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var projectInfo = ProjectInfo.Get(Id);
                if (projectInfo == null)
                {
                    ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.Renewal, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot);

                    var renewalInfo = new RenewalInfo();
                    renewalInfo.Id                 = Guid.NewGuid();
                    renewalInfo.ProjectId          = ProjectId;
                    renewalInfo.USCode             = USCode;
                    renewalInfo.RenewalYears       = 0;
                    renewalInfo.NeedProjectCostEst = false;
                    renewalInfo.CreateTime         = DateTime.Now;
                    renewalInfo.CreateUserAccount  = ClientCookie.UserCode;
                    renewalInfo.Add();

                    var renewalConsInfo = new RenewalConsInfo();
                    renewalConsInfo.Id                = Guid.NewGuid();
                    renewalConsInfo.ProjectId         = ProjectId;
                    renewalConsInfo.HasReinvenstment  = false;
                    renewalConsInfo.IsHistory         = false;
                    renewalConsInfo.CreateTime        = DateTime.Now;
                    renewalConsInfo.CreateUserAccount = ClientCookie.UserCode;
                    renewalConsInfo.ProcInstId        = 0;
                    renewalConsInfo.Add();

                    var writeOffAmount = new WriteOffAmount();
                    writeOffAmount.Id            = Guid.NewGuid();
                    writeOffAmount.ConsInfoID    = renewalConsInfo.Id;
                    writeOffAmount.TotalWriteOff = Renewal_Total_WO_Proj;
                    writeOffAmount.TotalNBV      = Renewal_Total_WO_Act;
                    writeOffAmount.Add();

                    var reinvestmentCost = new ReinvestmentCost();
                    reinvestmentCost.Id                    = Guid.NewGuid();
                    reinvestmentCost.ConsInfoID            = renewalConsInfo.Id;
                    reinvestmentCost.TotalReinvestmentNorm = Renewal_Total_Reinvestment_Proj;
                    reinvestmentCost.LHINorm               = Renewal_Total_Reinvestment_Act;
                    reinvestmentCost.Add();

                    var renewalAnalysis = new RenewalAnalysis();
                    renewalAnalysis.Id                  = Guid.NewGuid();
                    renewalAnalysis.ProjectId           = ProjectId;
                    renewalAnalysis.CreateUserAccount   = ClientCookie.UserCode;
                    renewalAnalysis.CreateTime          = DateTime.Now;
                    renewalAnalysis.IsHistory           = false;
                    renewalAnalysis.FairMarketRentAgent = Fair_Market_Rent;
                    renewalAnalysis.DR1stTYAmount       = DR1stTYAmount;
                    renewalAnalysis.RentDeviation       = RentDeviation;
                    renewalAnalysis.DRMFLastTYSales     = DRMFLastTYSales;
                    renewalAnalysis.DRMF1stTY           = DRMF1stTY;
                    renewalAnalysis.Add();

                    var renewalTool = new RenewalTool();
                    renewalTool.Id                = Guid.NewGuid();
                    renewalTool.ProjectId         = ProjectId;
                    renewalTool.IsHistory         = false;
                    renewalTool.CreateTime        = DateTime.Now;
                    renewalTool.CreateUserAccount = ClientCookie.UserCode;
                    renewalTool.Add();

                    var renewalToolFinMeasureOutput = new RenewalToolFinMeasureOutput();
                    renewalToolFinMeasureOutput.Id                 = Guid.NewGuid();
                    renewalToolFinMeasureOutput.ToolId             = renewalTool.Id;
                    renewalToolFinMeasureOutput.RentAsProdSalesYr1 = SRMFLastTYSales;
                    renewalToolFinMeasureOutput.RentAsProdSalesAvg = SRMF1stTYSales;
                    renewalToolFinMeasureOutput.Add();

                    var projectContractInfo = new ProjectContractInfo();
                    projectContractInfo.Id                           = Guid.NewGuid();
                    projectContractInfo.ProjectId                    = ProjectId;
                    projectContractInfo.ContractInfoId               = Guid.Empty;
                    projectContractInfo.CreatedTime                  = DateTime.Now;
                    projectContractInfo.WriteBack                    = false;
                    projectContractInfo.EditMode                     = EditMode;
                    projectContractInfo.PartyAFullName               = PartyAFullName;
                    projectContractInfo.McDLegalEntity               = ContractEntityName;
                    projectContractInfo.McDOwnership                 = McdOwnership;
                    projectContractInfo.ContactPerson                = ContactPerson;
                    projectContractInfo.ContactMode                  = ContactMode;
                    projectContractInfo.RentType                     = RentType;
                    projectContractInfo.TotalLeasedArea              = RentSize;
                    projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                    projectContractInfo.LeasePurchase                = ContractType;
                    projectContractInfo.StartDate                    = ContractStartDate;
                    projectContractInfo.EndDate                      = ContraceEndDate;
                    projectContractInfo.StartYear                    = ContractStartYear;
                    projectContractInfo.EndYear                      = ContraceEndYear;
                    projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                    projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                    projectContractInfo.Changedafter2010             = ChangedAfter2010;
                    projectContractInfo.RentStructure                = RentStructure;
                    projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                    projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                    projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                    projectContractInfo.HasDeposit                   = Deposit;
                    projectContractInfo.DepositAmount                = DepositAmount;
                    projectContractInfo.RefundableDate               = WhenRefund;
                    projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                    projectContractInfo.HasBankGuarantee             = BankGuarantee;
                    projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                    projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                    projectContractInfo.BGCommencementDate           = BGCommencementDate;
                    projectContractInfo.BGEndDate                    = BGEndDate;
                    projectContractInfo.Add();
                }
                else
                {
                    ProjectId            = projectInfo.ProjectId;
                    projectInfo.IsPushed = pushOrNot;
                    projectInfo.Update();

                    var renewalInfo = RenewalInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (renewalInfo == null)
                    {
                        renewalInfo                    = new RenewalInfo();
                        renewalInfo.Id                 = Guid.NewGuid();
                        renewalInfo.ProjectId          = ProjectId;
                        renewalInfo.USCode             = USCode;
                        renewalInfo.RenewalYears       = 0;
                        renewalInfo.NeedProjectCostEst = false;
                        renewalInfo.CreateTime         = DateTime.Now;
                        renewalInfo.CreateUserAccount  = ClientCookie.UserCode;
                        renewalInfo.Add();
                    }

                    var renewalConsInfo = RenewalConsInfo.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (renewalConsInfo == null)
                    {
                        renewalConsInfo                   = new RenewalConsInfo();
                        renewalConsInfo.Id                = Guid.NewGuid();
                        renewalConsInfo.ProjectId         = ProjectId;
                        renewalConsInfo.HasReinvenstment  = false;
                        renewalConsInfo.IsHistory         = false;
                        renewalConsInfo.CreateTime        = DateTime.Now;
                        renewalConsInfo.CreateUserAccount = ClientCookie.UserCode;
                        renewalConsInfo.ProcInstId        = 0;
                        renewalConsInfo.Add();
                    }

                    var writeOffAmount = WriteOffAmount.FirstOrDefault(i => i.ConsInfoID == renewalConsInfo.Id);
                    if (writeOffAmount == null)
                    {
                        writeOffAmount               = new WriteOffAmount();
                        writeOffAmount.Id            = Guid.NewGuid();
                        writeOffAmount.ConsInfoID    = renewalConsInfo.Id;
                        writeOffAmount.TotalWriteOff = Renewal_Total_WO_Proj;
                        writeOffAmount.TotalNBV      = Renewal_Total_WO_Act;
                        writeOffAmount.Add();
                    }
                    else
                    {
                        writeOffAmount.TotalWriteOff = Renewal_Total_WO_Proj;
                        writeOffAmount.TotalNBV      = Renewal_Total_WO_Act;
                        writeOffAmount.Update();
                    }

                    var reinvestmentCost = ReinvestmentCost.FirstOrDefault(i => i.ConsInfoID == renewalConsInfo.Id);
                    if (reinvestmentCost == null)
                    {
                        reinvestmentCost                       = new ReinvestmentCost();
                        reinvestmentCost.Id                    = Guid.NewGuid();
                        reinvestmentCost.ConsInfoID            = renewalConsInfo.Id;
                        reinvestmentCost.TotalReinvestmentNorm = Renewal_Total_Reinvestment_Proj;
                        reinvestmentCost.LHINorm               = Renewal_Total_Reinvestment_Act;
                        reinvestmentCost.Add();
                    }
                    else
                    {
                        reinvestmentCost.TotalReinvestmentNorm = Renewal_Total_Reinvestment_Proj;
                        reinvestmentCost.LHINorm = Renewal_Total_Reinvestment_Act;
                        reinvestmentCost.Update();
                    }

                    var renewalAnalysis = RenewalAnalysis.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (renewalAnalysis == null)
                    {
                        renewalAnalysis                     = new RenewalAnalysis();
                        renewalAnalysis.Id                  = Guid.NewGuid();
                        renewalAnalysis.ProjectId           = ProjectId;
                        renewalAnalysis.CreateUserAccount   = ClientCookie.UserCode;
                        renewalAnalysis.CreateTime          = DateTime.Now;
                        renewalAnalysis.IsHistory           = false;
                        renewalAnalysis.FairMarketRentAgent = Fair_Market_Rent;
                        renewalAnalysis.DR1stTYAmount       = DR1stTYAmount;
                        renewalAnalysis.RentDeviation       = RentDeviation;
                        renewalAnalysis.DRMFLastTYSales     = DRMFLastTYSales;
                        renewalAnalysis.DRMF1stTY           = DRMF1stTY;
                        renewalAnalysis.Add();
                    }
                    else
                    {
                        renewalAnalysis.FairMarketRentAgent = Fair_Market_Rent;
                        renewalAnalysis.DR1stTYAmount       = DR1stTYAmount;
                        renewalAnalysis.RentDeviation       = RentDeviation;
                        renewalAnalysis.DRMFLastTYSales     = DRMFLastTYSales;
                        renewalAnalysis.DRMF1stTY           = DRMF1stTY;
                        renewalAnalysis.Update();
                    }

                    var renewalTool = RenewalTool.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (renewalTool == null)
                    {
                        renewalTool                   = new RenewalTool();
                        renewalTool.Id                = Guid.NewGuid();
                        renewalTool.ProjectId         = ProjectId;
                        renewalTool.IsHistory         = false;
                        renewalTool.CreateTime        = DateTime.Now;
                        renewalTool.CreateUserAccount = ClientCookie.UserCode;
                        renewalTool.Add();
                    }

                    var renewalToolFinMeasureOutput = RenewalToolFinMeasureOutput.FirstOrDefault(i => i.ToolId == renewalTool.Id);
                    if (renewalToolFinMeasureOutput == null)
                    {
                        renewalToolFinMeasureOutput                    = new RenewalToolFinMeasureOutput();
                        renewalToolFinMeasureOutput.Id                 = Guid.NewGuid();
                        renewalToolFinMeasureOutput.ToolId             = renewalTool.Id;
                        renewalToolFinMeasureOutput.RentAsProdSalesYr1 = SRMFLastTYSales;
                        renewalToolFinMeasureOutput.RentAsProdSalesAvg = SRMF1stTYSales;
                        renewalToolFinMeasureOutput.Add();
                    }
                    else
                    {
                        renewalToolFinMeasureOutput.RentAsProdSalesYr1 = SRMFLastTYSales;
                        renewalToolFinMeasureOutput.RentAsProdSalesAvg = SRMF1stTYSales;
                        renewalToolFinMeasureOutput.Update();
                    }

                    var projectContractInfo = ProjectContractInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (projectContractInfo != null)
                    {
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Update();
                    }
                    else
                    {
                        projectContractInfo                              = new ProjectContractInfo();
                        projectContractInfo.Id                           = Guid.NewGuid();
                        projectContractInfo.ProjectId                    = ProjectId;
                        projectContractInfo.ContractInfoId               = Guid.Empty;
                        projectContractInfo.CreatedTime                  = DateTime.Now;
                        projectContractInfo.WriteBack                    = false;
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Add();
                    }
                }
                tranScope.Complete();
            }
        }
Ejemplo n.º 5
0
        private static RenewalAnalysisStoreInfo PrepareStoreInfo(string projectId, string usCode)
        {
            var store         = StoreBasicInfo.GetStorInfo(usCode);
            var storeMMInfo   = StoreMMInfo.Get(usCode);
            var storeContract = StoreContractInfo.Get(usCode);
            var ta            = StoreSTLocation.GetStoreSTLocation(usCode);
            var tool          = RenewalTool.Get(projectId);
            var finOutput     = RenewalToolFinMeasureOutput.GetByToolId(tool.Id) ?? new RenewalToolFinMeasureOutput();
            var consInfo      = RenewalConsInfo.Get(projectId);
            var toolWriteOff  = RenewalToolWriteOffAndReinCost.Get(projectId, tool.Id);
            var floors        = string.Join("/", new[] {
                string.Join(",", new[] {
                    ta.Floor1,
                    ta.Floor2,
                    ta.Floor3,
                    ta.Floor4,
                    ta.Floor5
                }.Where(e => !string.IsNullOrEmpty(e)).ToArray()),
                string.Join(",", new[] {
                    ta.FrontCounterFloor1,
                    ta.FrontCounterFloor2
                }.Where(e => !string.IsNullOrEmpty(e)).ToArray())
            }.Where(e => !string.IsNullOrEmpty(e)).ToArray());

            var seats = string.Join("/", new[] {
                new[] { ta.Seats1, ta.Seats2, ta.Seats3, ta.Seats4, ta.Seats5, ta.FrontCounterSeats }.Select(e => {
                    var val = 0;
                    int.TryParse(e, out val);
                    return(val);
                }).Sum(),
                string.IsNullOrEmpty(ta.OutsideSeats)?0:int.Parse(ta.OutsideSeats)
            });

            var beTypes = string.Join(",", StoreBEInfo.Search(e => e.StoreCode == usCode && e.BETypeName != "FC" && e.BETypeName != "DT").Select(e => e.BETypeName).ToArray());

            var leaseTenureAndTerm = string.Concat(storeContract.LeasePurchaseTerm, " years,from ",
                                                   storeContract.StartDate.HasValue ? storeContract.StartDate.Value.ToString("yyyy-MM-dd") : " / ",
                                                   "to",
                                                   storeContract.EndDate.HasValue ? storeContract.EndDate.Value.ToString("yyyy-MM-dd") : " / "
                                                   );

            return(new RenewalAnalysisStoreInfo
            {
                UsCode = store.StoreCode,
                NameZHCN = store.NameZHCN,
                NameENUS = store.NameENUS,
                MinimarketPriority = storeMMInfo.Priority,
                TADesrability = storeMMInfo.Desirability,
                SitePortfolioType = storeMMInfo.PortfolioTypeName,
                SiteRerating = storeMMInfo.LocationRatingPP,
                LeasedArea = storeContract.TotalLeasedArea,
                OperationSize = ta.TotalArea,
                Floors = floors,
                Seats = seats,
                BEType = beTypes,
                LeaseTenureAndTerm = leaseTenureAndTerm,
                FreeRentalPeriod = storeContract.FreeRentalPeriod,
                RentStructure = storeContract.RentStructure,
                DRMFLastTY = finOutput.AnnualRentExpenseLY,
                DRMFLastTYSales = finOutput.RentAsProdSalesLY,
                SRMFLastTY = finOutput.AnnualRentExpenseYr1,
                SRMFLastTYSales = finOutput.RentAsProdSalesYr1,
                SRMF1stTY = finOutput.AnnualRentExpenseAvg,
                SRMF1stTYSales = finOutput.RentAsProdSalesAvg,
                AnnualSOILastTY = finOutput.SOIProdSalesLY,
                AnnualSOIAvg = finOutput.SOIProdSalesAvg,
                CashROIAvg = finOutput.CashROIAvg,
                CashROILastTY = finOutput.CashROILY,
                OriginalInvestment = (toolWriteOff.REII + toolWriteOff.LHIII + toolWriteOff.ESSDII).ToString(),
                NBV = (toolWriteOff.RENBV + toolWriteOff.LHINBV + toolWriteOff.ESSDNBV).ToString(),
                AdditionalInvestmentCost = (toolWriteOff.RECost + toolWriteOff.LHICost + toolWriteOff.ESSDCost).ToString(),
                ExclusivityClause = storeContract.ExclusivityClause,
                McDsEarlyTerminationRight = storeContract.WithEarlyTerminationClause == null || storeContract.WithEarlyTerminationClause == 0 ? "N" : "Y",
                LandlordEntity = storeContract.PartyAFullName,
                LastRemodeling = store.ReImageDate.HasValue ? store.ReImageDate.Value.ToString("yyyy-MM-dd") : ""
            });
        }
Ejemplo n.º 6
0
        public static void Create(PostCreateWorkflow <RenewalInfo> postCreateRenewal)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var usCode    = postCreateRenewal.Entity.USCode;
                var store     = StoreBasicInfo.GetStorInfo(usCode);
                var projectId = ProjectInfo.CreateMainProject(FlowCode.Renewal, usCode, NodeCode.Start, ClientCookie.UserCode);
                postCreateRenewal.Entity.Id = Guid.NewGuid();
                postCreateRenewal.Entity.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Entity.CreateTime        = DateTime.Now;
                postCreateRenewal.Entity.StoreNameENUS     = store.NameENUS;
                postCreateRenewal.Entity.StoreNameZHCN     = store.NameZHCN;

                postCreateRenewal.Entity.AssetRepAccount  = postCreateRenewal.Team.AssetRep.UserAccount;
                postCreateRenewal.Entity.AssetRepNameENUS = postCreateRenewal.Team.AssetRep.UserNameENUS;
                postCreateRenewal.Entity.AssetRepNameZHCN = postCreateRenewal.Team.AssetRep.UserNameZHCN;

                postCreateRenewal.Entity.AssetActorAccount  = postCreateRenewal.Team.AssetActor.UserAccount;
                postCreateRenewal.Entity.AssetActorNameENUS = postCreateRenewal.Team.AssetActor.UserNameENUS;
                postCreateRenewal.Entity.AssetActorNameZHCN = postCreateRenewal.Team.AssetActor.UserNameZHCN;

                postCreateRenewal.Entity.FinanceAccount  = postCreateRenewal.Team.Finance.UserAccount;
                postCreateRenewal.Entity.FinanceNameENUS = postCreateRenewal.Team.Finance.UserNameENUS;
                postCreateRenewal.Entity.FinanceNameZHCN = postCreateRenewal.Team.Finance.UserNameZHCN;

                postCreateRenewal.Entity.PMAccount  = postCreateRenewal.Team.PM.UserAccount;
                postCreateRenewal.Entity.PMNameENUS = postCreateRenewal.Team.PM.UserNameENUS;
                postCreateRenewal.Entity.PMNameZHCN = postCreateRenewal.Team.PM.UserNameZHCN;

                postCreateRenewal.Entity.LegalAccount  = postCreateRenewal.Team.Legal.UserAccount;
                postCreateRenewal.Entity.LegalNameENUS = postCreateRenewal.Team.Legal.UserNameENUS;
                postCreateRenewal.Entity.LegalNameZHCN = postCreateRenewal.Team.Legal.UserNameZHCN;

                postCreateRenewal.Entity.AssetManagerAccount  = postCreateRenewal.Team.AssetMgr.UserAccount;
                postCreateRenewal.Entity.AssetManagerNameENUS = postCreateRenewal.Team.AssetMgr.UserNameENUS;
                postCreateRenewal.Entity.AssetManagerNameZHCN = postCreateRenewal.Team.AssetMgr.UserNameZHCN;

                postCreateRenewal.Entity.CMAccount  = postCreateRenewal.Team.CM.UserAccount;
                postCreateRenewal.Entity.CMNameENUS = postCreateRenewal.Team.CM.UserNameENUS;
                postCreateRenewal.Entity.CMNameZHCN = postCreateRenewal.Team.CM.UserNameZHCN;

                postCreateRenewal.Entity.ProjectId = projectId;
                postCreateRenewal.Entity.Add();
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Letter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LLNegotiation, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLLNegotiation.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConsInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalConsInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount, postCreateRenewal.Entity.NeedProjectCostEst);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Tool, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.Finance.UserAccount);
                var tool = RenewalTool.Create(projectId, postCreateRenewal.Team.Finance.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ClearanceReport, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalClearanceReport.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConfirmLetter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalConfirmLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Analysis, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                var analysis = RenewalAnalysis.Create(postCreateRenewal.Entity);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LegalApproval, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLegalApproval.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Package, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalPackage.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount, analysis.Id, tool.Id);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ContractInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalContractInfo.Create(projectId);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_SiteInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalSiteInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Renewal_GBMemo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);

                List <ProjectUsers> projectUsers = new List <ProjectUsers>();

                postCreateRenewal.Team.AssetRep.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetRep.ProjectId         = projectId;
                postCreateRenewal.Team.AssetRep.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetRep.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetRep.RoleCode          = ProjectUserRoleCode.AssetRep;
                postCreateRenewal.Team.AssetRep.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetRep.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetRep);

                postCreateRenewal.Team.AssetActor.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetActor.ProjectId         = projectId;
                postCreateRenewal.Team.AssetActor.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetActor.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetActor.RoleCode          = ProjectUserRoleCode.AssetActor;
                postCreateRenewal.Team.AssetActor.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetActor.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetActor);

                postCreateRenewal.Team.Finance.Id                = Guid.NewGuid();
                postCreateRenewal.Team.Finance.ProjectId         = projectId;
                postCreateRenewal.Team.Finance.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.Finance.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.Finance.RoleCode          = ProjectUserRoleCode.Finance;
                postCreateRenewal.Team.Finance.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ENUS);
                postCreateRenewal.Team.Finance.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.Finance);

                postCreateRenewal.Team.PM.Id                = Guid.NewGuid();
                postCreateRenewal.Team.PM.ProjectId         = projectId;
                postCreateRenewal.Team.PM.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.PM.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.PM.RoleCode          = ProjectUserRoleCode.PM;
                postCreateRenewal.Team.PM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ENUS);
                postCreateRenewal.Team.PM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.PM);

                postCreateRenewal.Team.Legal.Id                = Guid.NewGuid();
                postCreateRenewal.Team.Legal.ProjectId         = projectId;
                postCreateRenewal.Team.Legal.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.Legal.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.Legal.RoleCode          = ProjectUserRoleCode.Legal;
                postCreateRenewal.Team.Legal.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ENUS);
                postCreateRenewal.Team.Legal.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.Legal);

                postCreateRenewal.Team.AssetMgr.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetMgr.ProjectId         = projectId;
                postCreateRenewal.Team.AssetMgr.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetMgr.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetMgr.RoleCode          = ProjectUserRoleCode.AssetManager;
                postCreateRenewal.Team.AssetMgr.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetMgr.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetMgr);

                postCreateRenewal.Team.CM.Id                = Guid.NewGuid();
                postCreateRenewal.Team.CM.ProjectId         = projectId;
                postCreateRenewal.Team.CM.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.CM.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.CM.RoleCode          = ProjectUserRoleCode.CM;
                postCreateRenewal.Team.CM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ENUS);
                postCreateRenewal.Team.CM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.CM);

                ProjectUsers.Add(projectUsers.ToArray());

                postCreateRenewal.Viewers.ForEach(v =>
                {
                    v.Id                = Guid.NewGuid();
                    v.ProjectId         = projectId;
                    v.CreateDate        = DateTime.Now;
                    v.CreateUserAccount = ClientCookie.UserCode;
                    v.RoleCode          = ProjectUserRoleCode.View;
                });
                ProjectUsers.Add(postCreateRenewal.Viewers.ToArray());
                //postCreateRenewal.NecessaryViewers.ForEach(v =>
                //{
                //    v.Id = Guid.NewGuid();
                //    v.ProjectId = projectId;
                //    v.CreateDate = DateTime.Now;
                //    v.CreateUserAccount = ClientCookie.UserCode;
                //    v.RoleCode = ProjectUserRoleCode.View;
                //});
                //ProjectUsers.Add(postCreateRenewal.NecessaryViewers.ToArray());
                Remind.SendRemind(projectId, FlowCode.Renewal, projectUsers);
                Remind.SendRemind(projectId, FlowCode.Renewal, postCreateRenewal.Viewers);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_Letter);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_LLNegotiation);
                postCreateRenewal.Entity.CreateAttachmentsMemo();
                ProjectNode.GenerateOnCreate(FlowCode.Renewal, projectId);
                ProjectProgress.SetProgress(projectId, "10%");
                tranScope.Complete();
            }
        }
Ejemplo n.º 7
0
        public void UpdateFromProjectList()
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var oldInfo  = RenewalInfo.Get(this.ProjectId);
                var consInfo = RenewalConsInfo.Get(this.ProjectId);
                var analysis = RenewalAnalysis.Get(this.ProjectId);
                analysis.LeaseTenureAndTerm = string.Format("{0} years,from {1:yyyy-MM-dd} to {2:yyyy-MM-dd}", this.RenewalYears, this.NewLeaseStartDate, this.NewLeaseEndDate);
                analysis.Update();
                if (oldInfo.NeedProjectCostEst != this.NeedProjectCostEst)
                {
                    consInfo.HasReinvenstment = this.NeedProjectCostEst;
                    consInfo.Update();
                    if (ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Letter) &&
                        ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_LLNegotiation))
                    {
                        if (!this.NeedProjectCostEst)
                        {
                            TaskWork.Cancel(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ConsInfo);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                if (!TaskWork.Any(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_Tool))
                                {
                                    GenerateSubmitTask(FlowCode.Renewal_Tool);
                                }
                            }
                        }
                        else
                        {
                            ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_ConsInfo);

                            GenerateSubmitTask(FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                TaskWork.Cancel(e => e.RefID == this.ProjectId && e.TypeCode == FlowCode.Renewal_Tool && e.Status == TaskWorkStatus.UnFinish);
                                ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool);
                            }
                        }
                    }
                }

                if (oldInfo.RenewalYears != this.RenewalYears)
                {
                    if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_Analysis))
                    {
                        if (this.RenewalYears <= 2)
                        {
                            TaskWork.Finish(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ClearanceReport);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ClearanceReport);
                        }
                        else
                        {
                            if (!TaskWork.Any(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_ClearanceReport && e.Status == TaskWorkStatus.UnFinish))
                            {
                                GenerateSubmitTask(FlowCode.Renewal_ClearanceReport);
                            }
                        }
                    }
                }
                this.Update();
                tranScope.Complete();
            }
        }
Ejemplo n.º 8
0
        public static ReopenMemo GetReopenMemo(string projectId)
        {
            var  memo        = FirstOrDefault(e => e.ProjectId.Equals(projectId));
            bool isEmptyMemo = false;

            if (memo == null)
            {
                memo        = new ReopenMemo();
                isEmptyMemo = true;
            }

            memo.ProjectId = projectId;
            if (projectId.ToLower().IndexOf("rebuild") >= 0)
            {
                var rbdInfo = new RebuildInfo();
                memo.RbdInfo = rbdInfo.GetRebuildInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RbdInfo.USCode);
                var consInfo = new RebuildConsInfo();
                consInfo = consInfo.GetConsInfo(projectId);
                var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = GBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;

                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("reimage") >= 0)
            {
                memo.RmgInfo = ReimageInfo.GetReimageInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RmgInfo.USCode);
                var consInfo = ReimageConsInfo.GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = ReimageGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("majorlease") >= 0)
            {
                var mjrInfo = new MajorLeaseInfo().GetMajorLeaseInfo(projectId);
                memo.ReopenDate = mjrInfo.ReopenDate;
                memo.Store      = StoreBasicInfo.GetStore(mjrInfo.USCode);
                var consInfo = new MajorLeaseConsInfo().GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = MajorLeaseGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("renewal") >= 0)
            {
                var renewalInfo = RenewalInfo.Get(projectId);
                memo.ReopenDate = renewalInfo.NewLeaseStartDate;
                memo.Store      = StoreBasicInfo.GetStore(renewalInfo.USCode);
                var consInfo = RenewalConsInfo.Get(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = RenewalGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            if (isEmptyMemo)
            {
                if (memo.ReinvestInfo != null)
                {
                    if (memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value)
                    {
                        memo.NewMcCafe = true;
                    }
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.NewKiosk = true;
                    }
                    if (memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value)
                    {
                        memo.NewMDS = true;
                    }
                    if (memo.ReinvestInfo.NewTwientyFourHour.HasValue && memo.ReinvestInfo.NewTwientyFourHour.Value)
                    {
                        memo.Is24H = true;
                    }
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.NewOperationSize))
                    //{
                    //    memo.AftOperationSize = memo.ReinvestInfo.NewOperationSize;
                    //}
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.EstimatedSeatNo))
                    //{
                    //    memo.AftARSN = memo.ReinvestInfo.EstimatedSeatNo;
                    //}
                }
                memo.TTMNetSales = GetTTFinanceData(memo.Store.StoreBasicInfo.StoreCode);
            }
            memo.PriceTiter = GetPriceTier(memo.Store.StoreBasicInfo.StoreCode);
            //if (string.IsNullOrEmpty(memo.AftARPT))
            //{
            //    memo.AftARPT = memo.PriceTiter;
            //}
            //if (memo.Store != null)
            //{
            //    memo.OriginalOperationSize = memo.Store.StoreSTLocation.TotalArea;
            //    memo.OriginalSeatNumber = memo.Store.StoreSTLocation.TotalSeatsNo;
            //}
            memo.YearMonthList = GetSelectYearMonth(memo.Store.StoreBasicInfo.StoreCode);
            if (isEmptyMemo)
            {
                SaveReopenMemo(memo);
            }
            return(memo);
        }