public string DownloadToolTemplate() { var templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.RenewalTool_Template); string fileName = string.Format("{0}/{1}.xlsx", SiteFilePath.TEMP_DIRECTORY, Guid.NewGuid()); File.Copy(templateFileName, fileName); FileInfo fileInfo = new FileInfo(fileName); ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.RenewalTool); ExcelInputDTO excelDto = new ExcelInputDTO(); var info = RenewalInfo.Get(this.ProjectId); var storeBasic = StoreBasicInfo.GetStorInfo(info.USCode); var storeContract = StoreContractInfo.Get(info.USCode); var finInput = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id); var wfAndReinCost = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id); excelDto.USCode = info.USCode; excelDto.Market = storeBasic.Market; excelDto.StoreName = storeBasic.NameZHCN + "/" + storeBasic.NameENUS; excelDto.OpenDate = storeBasic.OpenDate; if (storeContract.EndDate.HasValue) { excelDto.LeaseExpirationDate = storeContract.EndDate.Value; } excelDto.RenewalYears = info.RenewalYears; excelDto.ProductSales = finInput.ProductSalesAdjustment; excelDto.Pac = finInput.PacAdjustment; excelDto.Rent = finInput.RentAdjustment; excelDto.DepreciationLhi = finInput.DepreciationLhiAdjustment; excelDto.InterestLhi = finInput.InterestLhiAdjustment; excelDto.ServiceFee = finInput.ServiceFeeAdjustment; excelDto.Accounting = finInput.AccountingAdjustment; excelDto.Insurance = finInput.InsuranceAdjustment; excelDto.TaxesAndLicenses = finInput.TaxesAndLicensesAdjustment; excelDto.DepreciationEssd = finInput.DepreciationEssdAdjustment; excelDto.InterestEssd = finInput.InterestEssdAdjustment; excelDto.OtherIncExp = finInput.OtherIncExpAdjustment; excelDto.NonProductSales = finInput.NonProductSalesAdjustment; excelDto.NonProductCosts = finInput.NonProductCostsAdjustment; excelDto.REII = wfAndReinCost.REII; excelDto.LHIII = wfAndReinCost.LHIII; excelDto.ESSDII = wfAndReinCost.ESSDII; excelDto.RENBV = wfAndReinCost.RENBV; if (wfAndReinCost.LHINBV.HasValue) { excelDto.LHINBV = wfAndReinCost.LHINBV.Value; } if (wfAndReinCost.ESSDNBV.HasValue) { excelDto.ESSDNBV = wfAndReinCost.ESSDNBV.Value; } excelDto.RECost = wfAndReinCost.RECost; excelDto.LHICost = wfAndReinCost.LHICost; excelDto.ESSDCost = wfAndReinCost.ESSDCost; excelDto.TotalWriteOff = wfAndReinCost.REWriteOff + wfAndReinCost.LHIWriteOff + wfAndReinCost.ESSDWriteOff; excelDto.RentalStructure = !string.IsNullOrEmpty(finInput.RentalStructure) ? (Nullable <decimal>)decimal.Parse(finInput.RentalStructure) : null; excelDto.ContributionMargin = finInput.ContributionMargin; excelDto.SalesCompYr1 = finInput.SalesCompYr1; excelDto.SalesCompYr2 = finInput.SalesCompYr2; excelDto.SalesCompYr3 = finInput.SalesCompYr3; excelDto.SalesCompYr4 = finInput.SalesCompYr4; excelDto.SalesCompYr5 = finInput.SalesCompYr5; excelDto.SalesCompYr6 = finInput.SalesCompYr6; excelDto.SalesCompYr7 = finInput.SalesCompYr7; excelDto.SalesCompYr8 = finInput.SalesCompYr8; excelDto.SalesCompYr9 = finInput.SalesCompYr9; excelDto.SalesCompYr10 = finInput.SalesCompYr10; excelDto.SalesCompYr11 = finInput.SalesCompYr11; excelDto.SalesCompYr12 = finInput.SalesCompYr12; excelDto.SalesCompYr13 = finInput.SalesCompYr13; excelDto.SalesCompYr14 = finInput.SalesCompYr14; excelDto.SalesCompYr15 = finInput.SalesCompYr15; excelDto.SalesCompYr16 = finInput.SalesCompYr16; excelDto.SalesCompYr17 = finInput.SalesCompYr17; excelDto.SalesCompYr18 = finInput.SalesCompYr18; excelDto.SalesCompYr19 = finInput.SalesCompYr19; excelDto.SalesCompYr20 = finInput.SalesCompYr20; excelDto.ComSalesDesc = this.ComSalesDesc; excelDto.CompSales = finInput.CompSalesAdjustment; excelDto.FinanceYear = finInput.FinanceYear; excelDto.FinanceMonth = finInput.FinanceMonth; excelDirector.Input(excelDto); return(fileName); }
public override string Edit() { string url; using (var tranScope = new TransactionScope()) { var info = RenewalInfo.Get(this.ProjectId); var tool = Duplicator.AutoCopy(this); tool.Id = Guid.NewGuid(); tool.IsHistory = false; tool.CreateTime = DateTime.Now; tool.CreateUserAccount = ClientCookie.UserCode; tool.Add(); NewEntityId = tool.Id; IsHistory = true; this.Update(); ProjectInfo.Reset(ProjectId, this.WorkflowCode); var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty); attachments.ForEach(att => { att.RefTableID = tool.Id.ToString(); att.ID = Guid.NewGuid(); }); Attachment.Add(attachments.ToArray()); var FinMI = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id); var newFinMI = Duplicator.AutoCopy(FinMI); newFinMI.Id = Guid.NewGuid(); newFinMI.ToolId = tool.Id; newFinMI.Add(); var WfRc = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id); var newWfRc = Duplicator.AutoCopy(WfRc); newWfRc.Id = Guid.NewGuid(); newWfRc.ToolId = tool.Id; newWfRc.Add(); var FinMO = RenewalToolFinMeasureOutput.GetByToolId(this.Id); var newFinMO = Duplicator.AutoCopy(FinMO); newFinMO.Id = Guid.NewGuid(); newFinMO.ToolId = tool.Id; newFinMO.Add(); var package = RenewalPackage.Get(this.ProjectId); package.ToolId = tool.Id; package.Update(); var oldTasks = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && new string[] { this.WorkflowCode, FlowCode.Renewal_Analysis }.Contains(t.TypeCode)).ToList(); oldTasks.ForEach(t => { t.Status = TaskWorkStatus.Cancel; }); TaskWork.Update(oldTasks.ToArray()); var anlysisProj = ProjectInfo.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Analysis && e.Status == ProjectStatus.UnFinish && e.ProjectId == ProjectId); if (anlysisProj != null) { var taskAnlysis = TaskWork.FirstOrDefault(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish); if (taskAnlysis != null) { taskAnlysis.Status = TaskWorkStatus.Finished; taskAnlysis.FinishTime = DateTime.Now; taskAnlysis.Update(); } } var task = info.GenerateSubmitTask(this.WorkflowCode); url = task.Url; tranScope.Complete(); } return(url); }
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") : "" }); }
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); }
public override void Finish(TaskWorkStatus status, TaskWork task) { RenewalInfo info = RenewalInfo.Get(this.ProjectId); switch (status) { case TaskWorkStatus.K2ProcessApproved: //var toolUploadTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId // && t.TypeCode == FlowCode.Renewal_Tool // && t.ReceiverAccount == info.AssetActorAccount // && t.ActivityName == "AssetActor" // && t.Status == TaskWorkStatus.Cancel); //if (toolUploadTask != null) //{ // toolUploadTask.Status = TaskWorkStatus.UnFinish; // toolUploadTask.Update(); //} //else if (!ProjectInfo.IsFlowStarted(this.ProjectId, FlowCode.Renewal_Tool)) //{ // info.GenerateSubmitTask(FlowCode.Renewal_Tool); //} var tool = RenewalTool.Get(ProjectId); Guid entityId; var toolProj = ProjectInfo.FirstOrDefault(e => e.Status == ProjectStatus.Finished && e.ProjectId == ProjectId && e.FlowCode == FlowCode.Renewal_Tool); if (toolProj != null) { NoticeToActor(info.AssetActorAccount, info.USCode); tool.Edit(); entityId = tool.NewEntityId; } else { entityId = tool.Id; ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool); info.GenerateSubmitTask(FlowCode.Renewal_Tool); } var entity = RenewalToolWriteOffAndReinCost.FirstOrDefault(w => w.ToolId == entityId); if (entity == null) { entity = new RenewalToolWriteOffAndReinCost(); entity.Id = Guid.NewGuid(); entity.ToolId = tool.Id; entity.Add(); } var writeOffAmount = WriteOffAmount.GetByConsInfoId(this.Id); var reinCost = ReinvestmentCost.GetByConsInfoId(this.Id); if (writeOffAmount != null) { entity.REWriteOff = DataConverter.ToDecimal(writeOffAmount.REWriteOff); entity.LHIWriteOff = DataConverter.ToDecimal(writeOffAmount.LHIWriteOff); entity.ESSDWriteOff = DataConverter.ToDecimal(writeOffAmount.ESSDWriteOff); } else { entity.REWriteOff = 0; entity.LHIWriteOff = 0; entity.ESSDWriteOff = 0; } if (reinCost != null) { entity.RECost = DataConverter.ToDecimal(reinCost.RECostNorm); entity.LHICost = DataConverter.ToDecimal(reinCost.LHINorm); entity.ESSDCost = DataConverter.ToDecimal(reinCost.ESSDNorm); } else { entity.RECost = 0; entity.LHICost = 0; entity.ESSDCost = 0; } Log4netHelper.WriteInfo(JsonConvert.SerializeObject(new { desc = "renewal tool info:", entityId, tool, writeOffAmount, reinCost, Id })); entity.Update(); if (HasReinvenstment) { ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_ConsInfo_Approval); } break; case TaskWorkStatus.K2ProcessDeclined: break; } task.Finish(); }