public async Task <IActionResult> DeleteJobPhase([FromBody] JobPhaseView view) { JobPhaseModule invMod = new JobPhaseModule(); JobPhase jobPhase = await invMod.JobPhase.Query().MapToEntity(view); invMod.JobPhase.DeleteJobPhase(jobPhase).Apply(); return(Ok(view)); }
public async Task TestAddUpdatDelete() { JobCostLedgerModule JobCostLedgerMod = new JobCostLedgerModule(); Contract contract = await JobCostLedgerMod.Contract.Query().GetEntityById(6); JobMaster jobMaster = await JobCostLedgerMod.JobMaster.Query().GetEntityById(40); JobPhase jobPhase = await JobCostLedgerMod.JobPhase.Query().GetEntityById(180); JobCostType jobCostType = await JobCostLedgerMod.JobCostType.Query().GetEntityById(2); JobCostLedgerView view = new JobCostLedgerView() { JobMasterId = jobMaster.JobMasterId, ContractId = contract.ContractId, EstimatedHours = 0, EstimatedAmount = 0, JobPhaseId = jobPhase.JobPhaseId, ActualHours = 0, ActualCost = 0, ProjectedHours = 0, CommittedHours = 0, CommittedAmount = 100M, Description = "JC Ledger Detail", TransactionType = "PO", Source = "Job Costing", JobCostTypeId = jobCostType.JobCostTypeId }; NextNumber nnNextNumber = await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber(); view.JobCostLedgerNumber = nnNextNumber.NextNumberValue; JobCostLedger jobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().MapToEntity(view); JobCostLedgerMod.JobCostLedger.AddJobCostLedger(jobCostLedger).Apply(); JobCostLedger newJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().GetEntityByNumber(view.JobCostLedgerNumber); Assert.NotNull(newJobCostLedger); newJobCostLedger.Description = "JobCostLedger Test Update"; JobCostLedgerMod.JobCostLedger.UpdateJobCostLedger(newJobCostLedger).Apply(); JobCostLedgerView updateView = await JobCostLedgerMod.JobCostLedger.Query().GetViewById(newJobCostLedger.JobCostLedgerId); Assert.Same(updateView.Description, "JobCostLedger Test Update"); JobCostLedgerMod.JobCostLedger.DeleteJobCostLedger(newJobCostLedger).Apply(); JobCostLedger lookupJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().GetEntityById(view.JobCostLedgerId); Assert.Null(lookupJobCostLedger); }
public async Task <IActionResult> UpdateJobPhase([FromBody] JobPhaseView view) { JobPhaseModule invMod = new JobPhaseModule(); JobPhase jobPhase = await invMod.JobPhase.Query().MapToEntity(view); invMod.JobPhase.UpdateJobPhase(jobPhase).Apply(); JobPhaseView retView = await invMod.JobPhase.Query().GetViewById(jobPhase.JobPhaseId); return(Ok(retView)); }
public async Task <IActionResult> AddJobPhase([FromBody] JobPhaseView view) { JobPhaseModule invMod = new JobPhaseModule(); NextNumber nnJobPhase = await invMod.JobPhase.Query().GetNextNumber(); view.JobPhaseNumber = nnJobPhase.NextNumberValue; JobPhase jobPhase = await invMod.JobPhase.Query().MapToEntity(view); invMod.JobPhase.AddJobPhase(jobPhase).Apply(); JobPhaseView newView = await invMod.JobPhase.Query().GetViewByNumber(view.JobPhaseNumber); return(Ok(newView)); }
public async Task TestAddUpdatDelete() { JobPhaseModule JobPhaseMod = new JobPhaseModule(); JobMaster jobMaster = await JobPhaseMod.JobMaster.Query().GetEntityById(3); Contract contract = await JobPhaseMod.Contract.Query().GetEntityById(5); JobCostType jobCostType = await JobPhaseMod.JobCostType.Query().GetEntityById(4); JobPhaseView view = new JobPhaseView() { JobMasterId = jobMaster.JobMasterId, JobDescription = jobMaster.JobDescription, ContractId = contract.ContractId, ContractTitle = contract.Title, PhaseGroup = 1, Phase = "Site Preparation", JobCostTypeId = jobCostType.JobCostTypeId, CostCode = jobCostType.CostCode }; NextNumber nnNextNumber = await JobPhaseMod.JobPhase.Query().GetNextNumber(); view.JobPhaseNumber = nnNextNumber.NextNumberValue; JobPhase jobPhase = await JobPhaseMod.JobPhase.Query().MapToEntity(view); JobPhaseMod.JobPhase.AddJobPhase(jobPhase).Apply(); JobPhase newJobPhase = await JobPhaseMod.JobPhase.Query().GetEntityByNumber(view.JobPhaseNumber); Assert.NotNull(newJobPhase); newJobPhase.Phase = "JobPhase Test Update"; JobPhaseMod.JobPhase.UpdateJobPhase(newJobPhase).Apply(); JobPhaseView updateView = await JobPhaseMod.JobPhase.Query().GetViewById(newJobPhase.JobPhaseId); Assert.Same(updateView.Phase, "JobPhase Test Update"); JobPhaseMod.JobPhase.DeleteJobPhase(newJobPhase).Apply(); JobPhase lookupJobPhase = await JobPhaseMod.JobPhase.Query().GetEntityById(view.JobPhaseId); Assert.Null(lookupJobPhase); }
public async Task <ApiResponse> Handle(AddEditPhaseCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { if (request.JobPhaseId == 0 || request.JobPhaseId == null) { JobPhase obj = new JobPhase(); obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.IsDeleted = false; obj.Phase = request.Phase; _mapper.Map(request, obj); await _dbContext.JobPhases.AddAsync(obj); await _dbContext.SaveChangesAsync(); response.data.phaseById = obj; response.StatusCode = StaticResource.successStatusCode; response.Message = "Phase added Successfully"; } else { JobPhase obj = await _dbContext.JobPhases.FirstOrDefaultAsync(x => x.JobPhaseId == request.JobPhaseId); obj.ModifiedById = request.ModifiedById; obj.ModifiedDate = request.ModifiedDate; _mapper.Map(request, obj); await _dbContext.SaveChangesAsync(); response.data.phaseById = obj; response.StatusCode = StaticResource.successStatusCode; response.Message = "Phase updated successfully"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(GetPhaseByIdQuery request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { JobPhase obj = await _dbContext.JobPhases.AsNoTracking().AsQueryable().FirstOrDefaultAsync(x => x.JobPhaseId == request.JobPhaseId && x.IsDeleted == false); response.data.phaseById = obj; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
private void FillGridMain() { string[] searchTokens = textSearch.Text.ToLower().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); long[] userNums = new long[0]; JobCategory[] jobCats = new JobCategory[0]; JobPhase[] jobPhases = new JobPhase[0]; long[] jobPriorities = new long[0]; if (listBoxUsers.SelectedIndices.Count > 0 && !listBoxUsers.SelectedIndices.Contains(0)) { userNums = listBoxUsers.SelectedIndices.Cast <int>().Select(x => _listUsers[x - 1].UserNum).ToArray(); } if (listBoxCategory.SelectedIndices.Count > 0 && !listBoxCategory.SelectedIndices.Contains(0)) { jobCats = listBoxCategory.SelectedIndices.Cast <int>().Select(x => (JobCategory)(x - 1)).ToArray(); } if (listBoxPhases.SelectedIndices.Count > 0 && !listBoxPhases.SelectedIndices.Contains(0)) { jobPhases = listBoxPhases.SelectedIndices.Cast <int>().Select(x => (JobPhase)(x - 1)).ToArray(); } if (listBoxPriorities.SelectedIndices.Count > 0 && !listBoxPriorities.SelectedIndices.Contains(0)) { jobPriorities = listBoxPriorities.GetListSelected <Def>().Select(x => x.DefNum).ToArray(); } Action actionCloseProgress = ODProgress.Show(ODEventType.Job, typeof(JobEvent), "Getting job data..."); #region Get Missing Data //This entire section will go out to the database and get any data that is unknown based on some of the filters. //The other filters will be applied later via the cached lists. try { List <Job> listJobs = Jobs.GetForSearch(dateFrom.Value, dateTo.Value, jobPhases.ToList(), jobPriorities.ToList(), _listJobsAll.Select(x => x.JobNum).ToList()); Jobs.FillInMemoryLists(listJobs, true); _listJobsAll.AddRange(listJobs); } catch (OutOfMemoryException oome) { actionCloseProgress(); oome.DoNothing(); MsgBox.Show(this, "Not enough memory to complete the search. Please refine search filters."); return; } //Only get the feature request entries that we care about. JobEvent.Fire(ODEventType.Job, "Getting feature request data..."); List <long> listFeatureRequestNums = _listJobsAll.SelectMany(x => x.ListJobLinks) .Where(x => x.LinkType == JobLinkType.Request) .Select(x => x.FKey) .Distinct() .ToList(); //Don't download any feature requests that we already know about. listFeatureRequestNums.RemoveAll(x => x.In(_listFeatureRequestsAll.Select(y => y.FeatReqNum))); if (!listFeatureRequestNums.IsNullOrEmpty()) { _listFeatureRequestsAll.AddRange(FeatureRequests.GetAll(listFeatureRequestNums)); } //Only get the bug entries that we care about. JobEvent.Fire(ODEventType.Job, "Getting bug data..."); List <long> listBugIds = _listJobsAll.SelectMany(x => x.ListJobLinks) .Where(x => x.LinkType == JobLinkType.Bug) .Select(x => x.FKey) .Distinct() .ToList(); //Don't download any bugs that we already know about. listBugIds.RemoveAll(x => x.In(_listBugsAll.Select(y => y.BugId))); if (!listBugIds.IsNullOrEmpty()) { _listBugsAll.AddRange(Bugs.GetMany(listBugIds)); } #endregion JobEvent.Fire(ODEventType.Job, "Filling grid..."); gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); gridMain.ListGridColumns.Add(new GridColumn("Job\r\nNum", 50, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Priority", 50, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("Phase", 85)); gridMain.ListGridColumns.Add(new GridColumn("Category", 80)); gridMain.ListGridColumns.Add(new GridColumn("Job Title", -1)); gridMain.ListGridColumns.Add(new GridColumn("Version", 80)); gridMain.ListGridColumns.Add(new GridColumn("Est. Version", 80)); gridMain.ListGridColumns.Add(new GridColumn("Expert", 75)); gridMain.ListGridColumns.Add(new GridColumn("Engineer", 75)); gridMain.ListGridColumns.Add(new GridColumn("Est.\r\nHours", 60, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Act.\r\nHours", 60, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Job\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("Bug\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("FR\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridRows.Clear(); _listJobsFiltered = new List <Job>(); foreach (Job jobCur in _listJobsAll) { if (jobCats.Length > 0 && !jobCats.Contains(jobCur.Category)) { continue; } if (jobPhases.Length > 0 && !jobPhases.Contains(jobCur.PhaseCur)) { continue; } if (jobPriorities.Length > 0 && !jobPriorities.Contains(jobCur.Priority)) { continue; } if (userNums.Length > 0 && !userNums.All(x => Jobs.GetUserNums(jobCur).Contains(x))) { continue; } if (!jobCur.DateTimeEntry.Between(dateFrom.Value, dateTo.Value)) { continue; } bool isJobMatch = false; bool isBugMatch = false; bool isFeatureReqMatch = false; if (searchTokens.Length > 0) { bool addRow = false; List <Bug> listBugs = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Bug) .Select(x => _listBugsAll.FirstOrDefault(y => x.FKey == y.BugId)) .Where(x => x != null) .ToList(); List <FeatureRequest> listFeatures = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Request) .Select(x => _listFeatureRequestsAll.FirstOrDefault(y => x.FKey == y.FeatReqNum)) .Where(x => x != null) .ToList(); foreach (string token in searchTokens.Distinct()) { bool isFound = false; //JOB MATCHES if (jobCur.Title.ToLower().Contains(token) || jobCur.Implementation.ToLower().Contains(token) || jobCur.Requirements.ToLower().Contains(token) || jobCur.Documentation.ToLower().Contains(token) || jobCur.JobNum.ToString().Contains(token)) { isFound = true; isJobMatch = true; } //BUG MATCHES if (!isFound || !isBugMatch) { if (listBugs.Any(x => x.Description.ToLower().Contains(token) || x.Discussion.ToLower().Contains(token))) { isFound = true; isBugMatch = true; } } //FEATURE REQUEST MATCHES if (!isFound || !isFeatureReqMatch) { if (listFeatures.Any(x => x.Description.Contains(token) || x.FeatReqNum.ToString().ToLower().Contains(token))) { isFound = true; isFeatureReqMatch = true; } } addRow = isFound; if (!isFound) { break; //stop looking for additional tokens, we didn't find this one. } } if (!addRow) { continue; //we did not find one of the search terms. } } _listJobsFiltered.Add(jobCur); Def jobPriority = _listJobPriorities.FirstOrDefault(y => y.DefNum == jobCur.Priority); GridRow row = new GridRow(); row.Cells.Add(jobCur.JobNum.ToString()); row.Cells.Add(new GridCell(jobPriority.ItemName) { ColorBackG = jobPriority.ItemColor, ColorText = (jobCur.Priority == _listJobPriorities.FirstOrDefault(y => y.ItemValue.Contains("Urgent")).DefNum) ? Color.White : Color.Black, }); row.Cells.Add(jobCur.PhaseCur.ToString()); row.Cells.Add(jobCur.Category.ToString()); row.Cells.Add(jobCur.Title); row.Cells.Add(jobCur.JobVersion.ToString()); row.Cells.Add(jobCur.ProposedVersion.ToString()); row.Cells.Add(Userods.GetName(jobCur.UserNumExpert)); row.Cells.Add(Userods.GetName(jobCur.UserNumEngineer)); row.Cells.Add(jobCur.HoursEstimate.ToString()); row.Cells.Add(jobCur.HoursActual.ToString()); row.Cells.Add(isJobMatch ? "X" : ""); row.Cells.Add(isBugMatch ? "X" : ""); row.Cells.Add(new GridCell(isFeatureReqMatch ? "X" : "") { ColorBackG = _listFeatureRequestsAll.Count == 0 ? Control.DefaultBackColor : Color.Empty }); row.Tag = jobCur; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); actionCloseProgress(); }
///<summary>Fills with jobs that are attached to the selected sprint and are not complete. Ordered by owner and then category.</summary> private void FillGridQueue() { gridSprintQueue.BeginUpdate(); gridSprintQueue.ListGridColumns.Clear(); gridSprintQueue.ListGridColumns.Add(new GridColumn("Priority",90,HorizontalAlignment.Center)); gridSprintQueue.ListGridColumns.Add(new GridColumn("Owner",55,HorizontalAlignment.Center)); gridSprintQueue.ListGridColumns.Add(new GridColumn("Owner Action",110)); gridSprintQueue.ListGridColumns.Add(new GridColumn("EstHrs",60,HorizontalAlignment.Center,GridSortingStrategy.AmountParse)); gridSprintQueue.ListGridColumns.Add(new GridColumn("ActHrs",60,HorizontalAlignment.Center,GridSortingStrategy.AmountParse)); gridSprintQueue.ListGridColumns.Add(new GridColumn("",300)); gridSprintQueue.ListGridRows.Clear(); List<Job> listQueue=_listAttachedJobs.Where(x => x.PhaseCur.In(JobPhase.Concept,JobPhase.Definition,JobPhase.Quote)).ToList(); listQueue=listQueue.OrderBy(x => x.OwnerNum!=0) //This is the reverse order of the actual priority of different categories of jobs //Purposefully put in this order so they appear correctly in the list. .ThenBy(x => x.Category==JobCategory.NeedNoApproval) .ThenBy(x => x.Category==JobCategory.Research) .ThenBy(x => x.Category==JobCategory.Conversion) .ThenBy(x => x.Category==JobCategory.HqRequest) .ThenBy(x => x.Category==JobCategory.InternalRequest) .ThenBy(x => x.Category==JobCategory.Feature) .ThenBy(x => x.Category==JobCategory.Query) .ThenBy(x => x.Category==JobCategory.ProgramBridge) .ThenBy(x => x.Category==JobCategory.Enhancement) .ThenBy(x => x.Category==JobCategory.Bug) .ThenBy(x => _listJobPriorities.FirstOrDefault(y => y.DefNum==x.Priority).ItemOrder).ToList(); Dictionary<JobPhase,List<Job>> dictPhases=new Dictionary<JobPhase,List<Job>>(); foreach(Job job in listQueue) { JobPhase phase=job.PhaseCur; if(!dictPhases.ContainsKey(phase)) { dictPhases[phase]=new List<Job>(); } dictPhases[phase].Add(job); } //sort dictionary so actions will appear in same order //This is in reverse order in the code so it is correct in the UI dictPhases=dictPhases.OrderBy(x => x.Key==JobPhase.Concept) .ThenBy(x => x.Key==JobPhase.Quote) .ThenBy(x => x.Key==JobPhase.Definition).ToDictionary(x => x.Key,x => x.Value); foreach(KeyValuePair<JobPhase,List<Job>> kvp in dictPhases) { if(listQueue.Count==0) { continue; } gridSprintQueue.ListGridRows.Add(new GridRow("","","","","",kvp.Key.ToString()) { ColorBackG=Color.FromArgb(223,234,245),Bold=true }); foreach(Job job in kvp.Value) { Color backColor=Color.White; Def jobPriority=_listJobPriorities.FirstOrDefault(y => y.DefNum==job.Priority); gridSprintQueue.ListGridRows.Add( new GridRow( new GridCell(jobPriority.ItemName) { ColorBackG=jobPriority.ItemColor, ColorText=(job.Priority==_listJobPriorities.FirstOrDefault(y => y.ItemValue.Contains("Urgent")).DefNum) ? Color.White : Color.Black, }, new GridCell(job.OwnerNum==0 ? "-" : Userods.GetName(job.OwnerNum)), new GridCell(job.OwnerAction.GetDescription()), new GridCell(job.HoursEstimate.ToString()), new GridCell(job.HoursActual.ToString()), new GridCell(job.ToString()) ) { Tag=job, ColorBackG=backColor } ); } } gridSprintQueue.EndUpdate(); }
private void FillGridMain() { if (!_IsSearchReady) { return; } Cursor = Cursors.WaitCursor; gridMain.BeginUpdate(); gridMain.Columns.Clear(); //TODO: change columns gridMain.Columns.Add(new ODGridColumn("Job\r\nNum", 50)); gridMain.Columns.Add(new ODGridColumn("Phase", 85)); gridMain.Columns.Add(new ODGridColumn("Category", 80)); gridMain.Columns.Add(new ODGridColumn("Job Title", 300)); gridMain.Columns.Add(new ODGridColumn("Version", 80)); gridMain.Columns.Add(new ODGridColumn("Expert", 75)); gridMain.Columns.Add(new ODGridColumn("Engineer", 75)); gridMain.Columns.Add(new ODGridColumn("Job\r\nMatch", 45) { TextAlign = HorizontalAlignment.Center }); gridMain.Columns.Add(new ODGridColumn("Bug\r\nMatch", 45) { TextAlign = HorizontalAlignment.Center }); gridMain.Columns.Add(new ODGridColumn("Feature\r\nRequest\r\nMatch", 45) { TextAlign = HorizontalAlignment.Center }); gridMain.Rows.Clear(); string[] searchTokens = textSearch.Text.ToLower().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); _listJobsFiltered = new List <Job>(); long[] userNums = new long[0]; JobCategory[] jobCats = new JobCategory[0]; JobPhase[] jobPhases = new JobPhase[0]; if (listBoxUsers.SelectedIndices.Count > 0 && !listBoxUsers.SelectedIndices.Contains(0)) { userNums = listBoxUsers.SelectedIndices.Cast <int>().Select(x => _listUsers[x - 1].UserNum).ToArray(); } if (listBoxCategory.SelectedIndices.Count > 0 && !listBoxCategory.SelectedIndices.Contains(0)) { jobCats = listBoxCategory.SelectedIndices.Cast <int>().Select(x => (JobCategory)(x - 1)).ToArray(); } if (listBoxStatus.SelectedIndices.Count > 0 && !listBoxStatus.SelectedIndices.Contains(0)) { jobPhases = listBoxStatus.SelectedIndices.Cast <int>().Select(x => (JobPhase)(x - 1)).ToArray(); } foreach (Job jobCur in _listJobsAll) { if (jobCats.Length > 0 && !jobCats.Contains(jobCur.Category)) { continue; } if (jobPhases.Length > 0 && !jobPhases.Contains(jobCur.PhaseCur)) { continue; } if (userNums.Length > 0 && !userNums.All(x => Jobs.GetUserNums(jobCur).Contains(x))) { continue; } bool isJobMatch = false; bool isBugMatch = false; bool isFeatureReqMatch = false; if (searchTokens.Length > 0) { bool addRow = false; List <Bug> listBugs = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Bug).Select(x => _listBugsAll.FirstOrDefault(y => x.FKey == y.BugId)).Where(x => x != null).ToList(); List <FeatureRequest> listFeatures = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Request).Select(x => _listFeatureRequestsAll.FirstOrDefault(y => x.FKey == y.FeatReqNum)).Where(x => x != null).ToList(); foreach (string token in searchTokens.Distinct()) { bool isFound = false; //JOB MATCHES if (jobCur.Title.ToLower().Contains(token) || jobCur.Implementation.ToLower().Contains(token) || jobCur.Requirements.ToLower().Contains(token) || jobCur.Documentation.ToLower().Contains(token) || jobCur.JobNum.ToString().Contains(token)) { isFound = true; isJobMatch = true; } //BUG MATCHES if (!isFound || !isBugMatch) { if (listBugs.Any(x => x.Description.ToLower().Contains(token) || x.Discussion.ToLower().Contains(token))) { isFound = true; isBugMatch = true; } } //FEATURE REQUEST MATCHES if (!isFound || !isFeatureReqMatch) { if (listFeatures.Any(x => x.Description.Contains(token) || x.FeatReqNum.ToString().ToLower().Contains(token))) { isFound = true; isFeatureReqMatch = true; } } addRow = isFound; if (!isFound) { break; //stop looking for additional tokens, we didn't find this one. } } if (!addRow) { continue; //we did not find one of the search terms. } } _listJobsFiltered.Add(jobCur); ODGridRow row = new ODGridRow(); row.Cells.Add(jobCur.JobNum.ToString()); row.Cells.Add(jobCur.PhaseCur.ToString()); row.Cells.Add(jobCur.Category.ToString()); row.Cells.Add(jobCur.Title.Left(53, true)); row.Cells.Add(jobCur.JobVersion.ToString()); row.Cells.Add(Userods.GetName(jobCur.UserNumExpert)); row.Cells.Add(Userods.GetName(jobCur.UserNumEngineer)); row.Cells.Add(isJobMatch ? "X" : ""); row.Cells.Add(isBugMatch ? "X" : ""); row.Cells.Add(new ODGridCell(isFeatureReqMatch ? "X" : "") { CellColor = _listFeatureRequestsAll.Count == 0 ? Control.DefaultBackColor : Color.Empty }); row.Tag = jobCur; gridMain.Rows.Add(row); } gridMain.EndUpdate(); Cursor = Cursors.Default; }
private static async Task ProcessCCAsync(XElement ccInfo) { string apexJobID = ccInfo.Element("job_num").Value.Trim().PadLeft(12); if (String.IsNullOrEmpty(apexJobID.Trim())) { return; } string[] jcc_cc = ccInfo.Element("jcc_cc").Value.Split('-'); if (jcc_cc.Length != 2 && jcc_cc.Length != 3) { Console.WriteLine($"Unexpected cost code for job {apexJobID}"); return; } string apexCostCode; string apexPhase = jcc_cc[0]; if (jcc_cc.Length == 2) { apexCostCode = jcc_cc[1].PadLeft(9); } else { apexCostCode = jcc_cc[2].PadLeft(9); } using (var dc = new ApexDataDataContext()) { var apexCC = dc.JobPhCcds.Where(v => v.Job == apexJobID && v.Phase == apexPhase && v.CostCode == apexCostCode).SingleOrDefault(); bool newWBS = (apexCC == null); if (newWBS) { apexCC = new JobPhCcd(); } apexCC.Job = apexJobID; apexCC.Phase = apexPhase; apexCC.CostCode = apexCostCode; apexCC.Description = LoadValue(ccInfo.Element("jcc_desc").Value, 35); apexCC.Act = "A"; if (newWBS) { dc.JobPhCcds.InsertOnSubmit(apexCC); if (!dc.JobPhases.Where(p => p.Job == apexJobID && p.Phase == apexPhase).Any()) { JobPhase jp = new JobPhase { Job = apexJobID, Phase = apexPhase, Description = $"Phase {apexPhase}", Act = "A" }; dc.JobPhases.InsertOnSubmit(jp); } } try { dc.SubmitChanges(); Console.WriteLine($" Cost Code {apexJobID}, {apexPhase}-{apexCostCode} processed."); } catch (Exception ex) { Console.WriteLine($"Error on Cost Code {apexJobID}, {apexPhase}-{apexCostCode}, {ex}"); } } }
public async Task TestAddUpdatDelete() { JobMasterModule JobMasterMod = new JobMasterModule(); Customer customer = await JobMasterMod.Customer.Query().GetEntityById(12); AddressBook addressBookCustomer = await JobMasterMod.AddressBook.Query().GetEntityById(customer?.AddressId); Contract contract = await JobMasterMod.Contract.Query().GetEntityById(5); //public long? ProjectManagerId { get; set; } JobMasterView view = new JobMasterView() { CustomerId = customer.CustomerId, CustomerName = addressBookCustomer?.Name, ContractId = contract.ContractId, ContractTitle = contract?.Title, JobDescription = "Kuna 4 plex project", Address1 = " 123 ABC", City = "Kuna", State = "Id", Zipcode = "83709", TotalCommittedAmount = 600000, RemainingCommittedAmount = 400000, RetainageAmount = 200000, JobMasterNumber = (await JobMasterMod.JobMaster.Query().GetNextNumber()).NextNumberValue }; JobMaster jobMaster = await JobMasterMod.JobMaster.Query().MapToEntity(view); JobMasterMod.JobMaster.AddJobMaster(jobMaster).Apply(); JobMaster newJobMaster = await JobMasterMod.JobMaster.Query().GetEntityByNumber(view.JobMasterNumber); JobCostType jobPhaseCostTypeMisc = await JobMasterMod.JobCostType.Query().GetEntityById(4); Assert.NotNull(newJobMaster); IList <JobPhaseView> listJobPhaseViews = new List <JobPhaseView> { new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Work Site Preparation - Safety", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode }, new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Foundations", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode }, new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Building Structure", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode } , new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Facade", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode } , new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Interior Construction", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode } , new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Commissioning", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode } , new JobPhaseView { ContractId = contract.ContractId, ContractTitle = contract.Title, JobMasterId = newJobMaster.JobMasterId, JobDescription = newJobMaster.JobDescription, PhaseGroup = 1, Phase = "Grading and Landscaping", JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue, JobCostTypeId = jobPhaseCostTypeMisc.JobCostTypeId, CostCode = jobPhaseCostTypeMisc.CostCode } }; IList <JobPhase> listJobPhases = await JobMasterMod.JobPhase.Query().MapToEntity(listJobPhaseViews); JobMasterMod.JobPhase.AddJobPhases(listJobPhases.ToList <JobPhase>()).Apply(); //Add Purchase Order PurchaseOrderModule PurchaseOrderMod = new PurchaseOrderModule(); ChartOfAccount chartOfAccount = await PurchaseOrderMod.ChartOfAccount.Query().GetEntityById(16); Supplier supplier = await PurchaseOrderMod.Supplier.Query().GetEntityById(3); AddressBook addressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(supplier?.AddressId); Contract pocontract = await PurchaseOrderMod.Contract.Query().GetEntityById(5); Buyer buyer = await PurchaseOrderMod.Buyer.Query().GetEntityById(1); AddressBook buyerAddressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(buyer?.AddressId); TaxRatesByCode taxRatesByCode = await PurchaseOrderMod.TaxRatesByCode.Query().GetEntityById(1); //create purchase order and detail PurchaseOrderView viewPurchaseOrder = new PurchaseOrderView() { DocType = "STD", PaymentTerms = "Net 30", Amount = (24 * 75) + 25, AmountPaid = 0, Remark = " installation not included ", Gldate = DateTime.Parse("1/14/2020"), AccountId = chartOfAccount.AccountId, Location = chartOfAccount.Location, BusUnit = chartOfAccount.BusUnit, Subsidiary = chartOfAccount.Subsidiary, SubSub = chartOfAccount.SubSub, Account = chartOfAccount.Account, AccountDescription = chartOfAccount.Description, SupplierId = supplier.SupplierId, CustomerId = contract?.CustomerId, SupplierName = addressBook.Name, ContractId = contract?.ContractId, Description = " Standard doors - white", Ponumber = "PO-123", TakenBy = "David Nishimoto", ShippedToName = " abc corp", ShippedToAddress1 = " 123 abc", ShippedToAddress2 = " zone 1", ShippedToCity = "Kuna", ShippedToState = "ID", ShippedToZipcode = "83709", BuyerId = buyer.BuyerId, BuyerName = buyerAddressBook?.Name, RequestedDate = DateTime.Parse("1/20/2014"), PromisedDeliveredDate = DateTime.Parse("1/20/2014"), Tax = 24 * 75 * taxRatesByCode.TaxRate, TransactionDate = DateTime.Parse("1/14/2020"), TaxCode1 = taxRatesByCode.TaxCode, TaxCode2 = "", TaxRate = taxRatesByCode.TaxRate ?? 0, PurchaseOrderNumber = (await PurchaseOrderMod.PurchaseOrder.Query().GetNextNumber()).NextNumberValue }; PurchaseOrder purchaseOrder = await PurchaseOrderMod.PurchaseOrder.Query().MapToEntity(viewPurchaseOrder); PurchaseOrderMod.PurchaseOrder.AddPurchaseOrder(purchaseOrder).Apply(); PurchaseOrder newPurchaseOrder = await PurchaseOrderMod.PurchaseOrder.Query().GetEntityByNumber(viewPurchaseOrder.PurchaseOrderNumber); Supplier supplierPODetail = await PurchaseOrderMod.Supplier.Query().GetEntityById(newPurchaseOrder?.SupplierId); AddressBook addressBookSupplier = await PurchaseOrderMod.AddressBook.Query().GetEntityById(supplierPODetail?.AddressId); IList <PurchaseOrderDetailView> listPurchaseOrderDetailViews = new List <PurchaseOrderDetailView> { new PurchaseOrderDetailView() { PurchaseOrderId = newPurchaseOrder.PurchaseOrderId, Amount = 75 * 24, OrderedQuantity = 24, LineDescription = "Standard Door", LineNumber = 1, UnitPrice = 75, UnitOfMeasure = "Each", ExpectedDeliveryDate = DateTime.Parse("1/30/2020"), OrderDate = DateTime.Parse("1/16/2020"), ReceivedQuantity = 0, RemainingQuantity = 24, SupplierId = newPurchaseOrder.SupplierId, SupplierName = addressBookSupplier?.Name, PurchaseOrderDetailNumber = (await PurchaseOrderMod.PurchaseOrderDetail.Query().GetNextNumber()).NextNumberValue }, new PurchaseOrderDetailView() { PurchaseOrderId = newPurchaseOrder.PurchaseOrderId, Amount = 25 * 1, OrderedQuantity = 25, LineDescription = "Door Hinges", LineNumber = 2, UnitPrice = 25, UnitOfMeasure = "Box", ExpectedDeliveryDate = DateTime.Parse("1/30/2020"), OrderDate = DateTime.Parse("1/16/2020"), ReceivedQuantity = 0, RemainingQuantity = 24, SupplierId = newPurchaseOrder.SupplierId, SupplierName = addressBookSupplier?.Name, PurchaseOrderDetailNumber = (await PurchaseOrderMod.PurchaseOrderDetail.Query().GetNextNumber()).NextNumberValue } }; IList <PurchaseOrderDetail> listPurchaseOrderDetail = await PurchaseOrderMod.PurchaseOrderDetail.Query().MapToEntity(listPurchaseOrderDetailViews); PurchaseOrderMod.PurchaseOrderDetail.AddPurchaseOrderDetails(listPurchaseOrderDetail.ToList <PurchaseOrderDetail>()).Apply(); IList <PurchaseOrderDetail> listNewPurchaseOrderDetail = await PurchaseOrderMod.PurchaseOrderDetail.Query().GetEntitiesByPurchaseOrderId(newPurchaseOrder.PurchaseOrderId); //*****************Create Accounts Payable AccountPayableModule AccountPayableMod = new AccountPayableModule(); ChartOfAccount chartOfAccount2 = await AccountPayableMod.ChartOfAccount.Query().GetEntityById(17); AccountPayableView accountPayableView = new AccountPayableView() { DocNumber = (await AccountPayableMod.AccountPayable.Query().GetNextDocNumber()), GrossAmount = newPurchaseOrder.Amount, Tax = newPurchaseOrder.Tax, DiscountAmount = null, Remark = null, Gldate = DateTime.Now, SupplierId = newPurchaseOrder.SupplierId, ContractId = newPurchaseOrder.ContractId, PoquoteId = null, Description = newPurchaseOrder.Description, PurchaseOrderId = newPurchaseOrder.PurchaseOrderId, AccountId = chartOfAccount.AccountId, DocType = "STD", PaymentTerms = newPurchaseOrder.PaymentTerms, DiscountPercent = 0, AmountOpen = newPurchaseOrder.Amount, OrderNumber = newPurchaseOrder.Ponumber, AmountPaid = 0, AccountPayableNumber = (await AccountPayableMod.AccountPayable.Query().GetNextNumber()).NextNumberValue }; AccountPayable accountPayable = await AccountPayableMod.AccountPayable.Query().MapToEntity(accountPayableView); AccountPayableMod.AccountPayable.AddAccountPayable(accountPayable).Apply(); AccountPayable lookupAccountPayable = await AccountPayableMod.AccountPayable.Query().GetEntityByNumber(accountPayableView.AccountPayableNumber); //****************Create the invoice payment InvoiceModule invoiceMod = new InvoiceModule(); Supplier supplier2 = await invoiceMod.Supplier.Query().GetEntityById(purchaseOrder.SupplierId); AddressBook addressBookSupplinvModier2 = await invoiceMod.AddressBook.Query().GetEntityById(supplier?.AddressId); TaxRatesByCode taxRatesByCode2 = await invoiceMod.TaxRatesByCode.Query().GetEntityByTaxCode(purchaseOrder.TaxCode1); NextNumber nextNumber = await invoiceMod.Invoice.Query().GetNextNumber(); InvoiceView invoiceView = new InvoiceView { InvoiceDocument = "Inv-" + nextNumber.NextNumberValue.ToString(), InvoiceDate = DateTime.Parse("1/17/2020"), Amount = purchaseOrder.Amount, SupplierId = supplier2?.SupplierId, SupplierName = addressBookCustomer?.Name, Description = purchaseOrder.Description, PaymentTerms = purchaseOrder.PaymentTerms, TaxAmount = taxRatesByCode2.TaxRate * purchaseOrder.Amount, CompanyId = 1, TaxRatesByCodeId = taxRatesByCode2.TaxRatesByCodeId, InvoiceNumber = nextNumber.NextNumberValue }; Invoice invoice = await invoiceMod.Invoice.Query().MapToEntity(invoiceView); invoiceMod.Invoice.AddInvoice(invoice).Apply(); Invoice newInvoice = await invoiceMod.Invoice.Query().GetEntityByNumber(invoiceView.InvoiceNumber); InvoiceDetailModule invDetailMod = new InvoiceDetailModule(); IList <InvoiceDetailView> listInvoiceDetailViews = new List <InvoiceDetailView>(); foreach (var item in listNewPurchaseOrderDetail) { InvoiceDetailView invoiceDetailView = new InvoiceDetailView() { Amount = item.Amount, InvoiceId = newInvoice.InvoiceId, InvoiceDetailNumber = (await invDetailMod.InvoiceDetail.Query().GetNextNumber()).NextNumberValue, UnitOfMeasure = item.UnitOfMeasure, Quantity = (int)item.OrderedQuantity, UnitPrice = item.UnitPrice, DiscountPercent = 0, DiscountAmount = 0, SupplierId = item.SupplierId, SupplierName = (await(invDetailMod.AddressBook.Query().GetEntityById((await invDetailMod.Supplier.Query().GetEntityById(item.SupplierId)).AddressId))).Name, PurchaseOrderId = item.PurchaseOrderId, PurchaseOrderDetailId = item.PurchaseOrderDetailId, ExtendedDescription = item.LineDescription }; listInvoiceDetailViews.Add(invoiceDetailView); } List <InvoiceDetail> listInvoiceDetails = (await invDetailMod.InvoiceDetail.Query().MapToEntity(listInvoiceDetailViews)).ToList <InvoiceDetail>(); invDetailMod.InvoiceDetail.AddInvoiceDetails(listInvoiceDetails).Apply(); IList <InvoiceDetail> listLookupInvoiceDetails = await invDetailMod.InvoiceDetail.Query().GetEntitiesByInvoiceId(newInvoice.InvoiceId); //Update Accounts Payable - by invoices associated to a po IList <Invoice> listInvoiceByPurchaseOrder = await invoiceMod.Invoice.Query().GetEntitiesByPurchaseOrderId(newPurchaseOrder.PurchaseOrderId); lookupAccountPayable.AmountOpen = lookupAccountPayable.GrossAmount - listInvoiceByPurchaseOrder.Sum(e => e.Amount); AccountPayableMod.AccountPayable.UpdateAccountPayable(lookupAccountPayable).Apply(); //add to job costing PO JobCostLedgerModule JobCostLedgerMod = new JobCostLedgerModule(); JobPhase jobPhase2 = await JobMasterMod.JobPhase.Query().GetEntityByJobIdAndPhase(newJobMaster.JobMasterId, "Work Site Preparation - Safety"); JobCostType jobCostTypeMisc = await JobMasterMod.JobCostType.Query().GetEntityById(2); JobCostType jobCostTypeMaterial = await JobMasterMod.JobCostType.Query().GetEntityById(1); IList <JobCostLedgerView> listJobCostLedgerView = new List <JobCostLedgerView> { new JobCostLedgerView() { JobMasterId = jobMaster.JobMasterId, ContractId = jobMaster.ContractId, EstimatedHours = 0, EstimatedAmount = 0, JobPhaseId = jobPhase2.JobPhaseId, ActualHours = 0, ActualCost = 0, ProjectedHours = 0, CommittedHours = 0, PurchaseOrderId = newPurchaseOrder.PurchaseOrderId, SupplierId = newPurchaseOrder.SupplierId, CommittedAmount = newPurchaseOrder.Amount, Description = newPurchaseOrder.Description, TransactionType = "PO", Source = "Job Costing", JobCostTypeId = jobCostTypeMisc.JobCostTypeId, JobCostLedgerNumber = (await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber()).NextNumberValue }, new JobCostLedgerView() { JobMasterId = jobMaster.JobMasterId, ContractId = jobMaster.ContractId, EstimatedHours = 0, EstimatedAmount = 0, JobPhaseId = jobPhase2.JobPhaseId, ActualHours = 0, ActualCost = lookupAccountPayable.AmountPaid, ProjectedHours = 0, CommittedHours = 0, PurchaseOrderId = lookupAccountPayable.PurchaseOrderId, SupplierId = lookupAccountPayable.SupplierId, CommittedAmount = 0, Description = lookupAccountPayable.Description, TransactionType = "AP", Source = "Job Costing", TaxAmount = lookupAccountPayable.Tax, JobCostTypeId = jobCostTypeMaterial.JobCostTypeId, JobCostLedgerNumber = (await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber()).NextNumberValue } }; IList <JobCostLedger> listJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().MapToEntity(listJobCostLedgerView); JobCostLedgerMod.JobCostLedger.AddJobCostLedgers(listJobCostLedger.ToList <JobCostLedger>()).Apply(); //Create the general ledger entry //Create the supplier ledger entry //Create Pay Roll //Add Pay Roll to job costing invDetailMod.InvoiceDetail.DeleteInvoiceDetails((listLookupInvoiceDetails).ToList <InvoiceDetail>()).Apply(); invoiceMod.Invoice.DeleteInvoice(newInvoice).Apply(); AccountPayableMod.AccountPayable.DeleteAccountPayable(lookupAccountPayable).Apply(); PurchaseOrderMod.PurchaseOrderDetail.DeletePurchaseOrderDetails(listPurchaseOrderDetail.ToList <PurchaseOrderDetail>()).Apply(); JobMasterMod.JobPhase.DeleteJobPhases(listJobPhases.ToList <JobPhase>()).Apply(); IList <JobPhase> lookupListJobPhases = await JobMasterMod.JobPhase.Query().GetEntitiesByJobMasterId(newJobMaster.JobMasterId); if (lookupListJobPhases.Count > 0) { Assert.True(false); } newJobMaster.JobDescription = "JobMaster Test Update"; JobMasterMod.JobMaster.UpdateJobMaster(newJobMaster).Apply(); JobMasterView updateView = await JobMasterMod.JobMaster.Query().GetViewById(newJobMaster.JobMasterId); Assert.Same(updateView.JobDescription, "JobMaster Test Update"); JobMasterMod.JobMaster.DeleteJobMaster(newJobMaster).Apply(); JobMaster lookupJobMaster = await JobMasterMod.JobMaster.Query().GetEntityById(view.JobMasterId); Assert.Null(lookupJobMaster); }
public IFluentJobPhase DeleteJobPhase(JobPhase deleteObject) { unitOfWork.jobPhaseRepository.DeleteObject(deleteObject); this.processStatus = CreateProcessStatus.Delete; return(this as IFluentJobPhase); }
public IFluentJobPhase UpdateJobPhase(JobPhase updateObject) { unitOfWork.jobPhaseRepository.UpdateObject(updateObject); this.processStatus = CreateProcessStatus.Update; return(this as IFluentJobPhase); }
public IFluentJobPhase AddJobPhase(JobPhase newObject) { unitOfWork.jobPhaseRepository.AddObject(newObject); this.processStatus = CreateProcessStatus.Insert; return(this as IFluentJobPhase); }